[Rubygems-developers] Automating gems

Patrick Hurley phurley at gmail.com
Wed Mar 14 17:47:55 EDT 2007


Sorry, if I should have been able to find some docs to point me in the
right direction, but so far here is what I figured out from trial and
error and some source code reading.

I want to unpack a gem already on my machine:
gem unpack a_gem

Then I want to retrieve the gem spec
gem specification a_gem

(then more stuff but this will get me started)

So far I have the simple code:

require "rubygems"
Gem.manage_gems

if gem = ARGV.first
  puts "Processing #{gem}"
  runner = Gem::GemRunner.new
  puts "Unpack #{gem}"
  runner.run ['unpack', gem]
  runner.run(['specification', gem])
end

This works; however, the run command displays to the screen. Is there
an easy way to capture its output? I see there is a default interface
object, with a method called say I could grab, but that seems pretty
messy. I could also grab the stdout handle and play games there, but
again, I feel I am missing something.

Thanks in advance for your time
pth


More information about the Rubygems-developers mailing list