[Rubygems-developers] Automating gems

Patrick Hurley phurley at gmail.com
Sat Mar 17 17:44:25 EDT 2007


On 3/17/07, Eric Hodel <drbrain at segment7.net> wrote:
> On Mar 14, 2007, at 14:47, Patrick Hurley wrote:
>
> > 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.
>
> Don't use the runner interface at all, it doesn't do anything you
> need, and adds a bunch of crap you don't (redirecting output).
>
> Just call the Gem::Installer#unpack method directly.
>
> $ ri Gem::Installer#unpack
> -------------------------------------------------- Gem::Installer#unpack
>       unpack(directory)
> ------------------------------------------------------------------------
>       Unpacks the gem into the given directory.
>
> Just use to_yaml or to_ruby on Gem::Specification.
> _______________________________________________
> Rubygems-developers mailing list
> Rubygems-developers at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rubygems-developers
>

Thanks, this looks much closer to what I was hoping. My goal is to (in
an automated fashion), build a binary gem, save all of the generated
files and the original gem into a platform specific gem, that can then
be installed on servers without a C compiler.

Thanks
pth


More information about the Rubygems-developers mailing list