[Rake-devel] Incresing GemPackageTask Efficiency

TRANS transfire at gmail.com
Wed Jan 31 10:25:07 EST 2007


(I originally posted this to ruby-talk, but realized I should have
done so here.)

When using the GemPackageTask, one has to build the GemSpec in order
to define the task. For a large project and/or slow machine this
actually can take a second or so. So every time I run "rake -T" there's
a very noticeable delay (not to mention wasted CPU cycles). Not sure
what other solutions there might be, but one is to have GemPackageTask
accept the parameters that will build the GemSpec when needed, but not
before. So, instead of

     spec = Gem::Specification.new do |s|
       s.platform = Gem::Platform::RUBY
       s.summary = "Ruby based make-like utility."
       s.name = 'rake'
       s.files = FileList.new('**/*').to_a

     Rake::GemPackageTask.new(spec) do |pkg|
       pkg.need_zip = true
       pkg.need_tar = true

It could be:

     Rake::GemPackageTask.new do |pkg|
       pkg.platform = 'ruby'
       pkg.summary = "Ruby based make-like utility."
       pkg.name = 'rake'
       pkg.files.include '**/*'
       pkg.need_zip = true
       pkg.need_tar = true

Note the difference in 'platform' and more importantly 'files'. The
GemPackageTask would work those out and build the GemSpec at runtime
rather then definition time.


More information about the Rake-devel mailing list