]> git.pld-linux.org Git - packages/rpm.git/blobdiff - gem_helper.rb
Release: 29
[packages/rpm.git] / gem_helper.rb
index 66615752063fbddd5556a6bca1b655800e7a210a..2a6bfab756df3a3b22239786c685aaf9899ae2dc 100755 (executable)
@@ -6,8 +6,9 @@
 #++
 
 require 'optparse'
+require 'rubygems'
 
-if ARGV[0] == "build" or ARGV[0] == "install"
+if ARGV[0] == "build" or ARGV[0] == "install" or ARGV[0] == "spec"
   require 'yaml'
   require 'zlib'
 
@@ -57,14 +58,26 @@ if ARGV[0] == "build" or ARGV[0] == "install"
     argv.delete_at(0)
   end
 
-  file_data = Zlib::GzipReader.open("metadata.gz")
+  file_data = Zlib::GzipReader.open("metadata.gz") {|io| io.read}
   header = YAML::load(file_data)
-  file_data.close()
-  body = header.instance_variable_get :@ivars
+  body = {}
+  # I don't know any better.. :/
+  header.instance_variables.each do |iv|
+         body[iv.to_s.sub(/^@/,'')] = header.instance_variable_get(iv)
+  end
 
-  require 'rubygems'
   spec = Gem::Specification.from_yaml(YAML.dump(header))
 
+  if ARGV[0] == "spec"
+    # Write the .gemspec specification (in Ruby)
+    file_name = spec.full_name.untaint + '.gemspec'
+    File.open(file_name, "w") do |file|
+      file.puts spec.to_ruby_for_cache
+    end
+    print "Wrote: %s\n" % file_name
+    exit(0)
+  end
+
   if ARGV[0] == "install"
     system("gem %s %s.gem" % [ARGV.join(' '), spec.full_name])
     if !keepcache
This page took 0.071676 seconds and 4 git commands to generate.