]> git.pld-linux.org Git - packages/rpm.git/blobdiff - gem_helper.rb
- release 48 (by relup.sh)
[packages/rpm.git] / gem_helper.rb
index 66615752063fbddd5556a6bca1b655800e7a210a..11de3be2fe0faaed59f12916d7d852462a8e791e 100755 (executable)
@@ -6,8 +6,25 @@
 #++
 
 require 'optparse'
+require 'rubygems'
 
-if ARGV[0] == "build" or ARGV[0] == "install"
+# Write the .gemspec specification (in Ruby)
+def writespec(spec)
+       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
+end
+
+# make gemspec self-contained
+if ARGV[0] == "spec-dump"
+       spec = eval(File.read(ARGV[1]))
+       writespec(spec)
+       exit(0)
+end
+
+if ARGV[0] == "build" or ARGV[0] == "install" or ARGV[0] == "spec"
   require 'yaml'
   require 'zlib'
 
@@ -57,14 +74,21 @@ 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"
+    writespec(spec)
+    exit(0)
+  end
+
   if ARGV[0] == "install"
     system("gem %s %s.gem" % [ARGV.join(' '), spec.full_name])
     if !keepcache
This page took 0.030065 seconds and 4 git commands to generate.