]> git.pld-linux.org Git - packages/rpm.git/blobdiff - gem_helper.rb
- release 48 (by relup.sh)
[packages/rpm.git] / gem_helper.rb
index feea121af50c028beb44336ad71689f2de5fc1d3..11de3be2fe0faaed59f12916d7d852462a8e791e 100755 (executable)
@@ -8,6 +8,22 @@
 require 'optparse'
 require 'rubygems'
 
+# 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'
@@ -63,18 +79,13 @@ if ARGV[0] == "build" or ARGV[0] == "install" or ARGV[0] == "spec"
   body = {}
   # I don't know any better.. :/
   header.instance_variables.each do |iv|
-         body[iv.to_s.gsub(/^@/,'')] = header.instance_variable_get(iv)
+         body[iv.to_s.sub(/^@/,'')] = header.instance_variable_get(iv)
   end
 
   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
+    writespec(spec)
     exit(0)
   end
 
This page took 0.03759 seconds and 4 git commands to generate.