X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;ds=sidebyside;f=gem_helper.rb;h=11de3be2fe0faaed59f12916d7d852462a8e791e;hb=34865f27901a6b75d0e12d61fd5609b9a403ab84;hp=65f45e431def207aab1c29e08098ae3d36a56dc9;hpb=b56af183f570ba9c2b055c65318818ce061a37cb;p=packages%2Frpm.git diff --git a/gem_helper.rb b/gem_helper.rb index 65f45e4..11de3be 100755 --- a/gem_helper.rb +++ b/gem_helper.rb @@ -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' @@ -58,20 +74,18 @@ if ARGV[0] == "build" or ARGV[0] == "install" or ARGV[0] == "spec" 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 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