On Friday 23 January 2009, Luis Lavena wrote:
>
> Oh yeha, my fault:
>
> gem spec pg --version '0.7.9.2008.10.13' --remote >
> specifications/pg-0.7.9.2008.10.13.gemspec
>
Thanks Luis, we're getting closer and closer.
Still, the output from the aboce command starts with:
--- !ruby/object:Gem::Specification
name: pg
version: !ruby/object:Gem::Version
version: 0.7.9.2008.10.13
platform: ruby
authors:
...
It looks like YAML.
A .gemspec file is like:
Gem::Specification.new do |s|
s.name = %q{commandline}
s.version = "0.7.10"
s.specification_version = 1 if s.respond_to? :specification_version=
...
end
The missing link would appear to be a function that can dump a
Gem::Specification object in .gemspec form.
I found them, and can report that the following works fine:
#!/usr/bin/env ruby
require 'yaml'
require 'rubygems'
require 'rubygems/specification'
require 'tempfile'
require 'fileutils'
gem = ARGV[0]
raise 'give name (gem-version)' if gem.nil?
out = "#{Gem::dir}/specifications/#{gem}.gemspec"
raise "#{out} already exists" if test(?f, out)
pkt, version = gem.split('-', 2)
IO.popen("gem spec #{pkt} --version '#{version}' --remote") do |io|
Tempfile.open('gem') do |temp|
temp.puts Gem::Specification.from_yaml(io).to_ruby
FileUtils.mv(temp.path, out)
end
end
Thanks a lot for your help.
Cheers,
Han Holl
_______________________________________________
Rubygems-developers mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rubygems-developers