Using rake to build gems

From WhyNotWiki

Jump to: navigation, search

Gems  edit   (Category  edit)


require 'rake/gempackagetask'
Rake::GemPackageTask.new(specification) do |package|
   package.need_zip = true
   package.need_tar = true
end
> rake pkg/MyGem-0.0.1.gem
(in /home/tyler/svn/code/gemables/MyGem)
  Successfully built RubyGem
  Name: MyGem
  Version: 0.0.1
  File: MyGem-0.0.1.gem
mv MyGem-0.0.1.gem pkg/MyGem-0.0.1.gem

Make sure you use the right spelling/capitalization that matches specification.name or it will just kinda look at you funny:

> rake pkg/my_gem-0.0.1.gem
(in /home/tyler/svn/code/gemables/whichever)
rake aborted!
Don't know how to build task 'pkg/my_gem-0.0.1.gem'

To build the same package again, you have to remove the existing package file. For example:

rm pkg/ruby_subversion-0.0.1.gem; rake pkg/ruby_subversion-0.0.1.gem
Personal tools