X-Git-Url: http://git.pld-linux.org/?p=packages%2Frpm.git;a=blobdiff_plain;f=gem_helper.rb;h=feea121af50c028beb44336ad71689f2de5fc1d3;hp=66615752063fbddd5556a6bca1b655800e7a210a;hb=4a1b849efcf4311f0687a32d339de92f82914242;hpb=63194730d5c6853e7e29d5390e93cbf6e7e8fb5b diff --git a/gem_helper.rb b/gem_helper.rb index 6661575..feea121 100755 --- a/gem_helper.rb +++ b/gem_helper.rb @@ -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.gsub(/^@/,'')] = 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