Thursday, October 9, 2008

Auto-generate your Manifest and Gemspec using Hoe

If you've ever built a rubygem and found it frustrating, the first thing you should do if you haven't already is get familiar with hoe. Hoe is a tool for sowing and raking gems. That is, hoe provides the "sow" command for creating a gem file structure, and rake tasks for cultivating your gem. It also has rake tasks for taking your gems to market -- that is, rubyforge.

Here are a couple tricks to automate things a little further with hoe:
Automatically generate your Manifest.txt (assuming Manifest.txt exists):

rake check_manifest | grep -v "(in " | patch


Generate a gemspec file -- necessary on github to provide a gem:
rake debug_gem | grep -v "(in " > `basename \`pwd\``.gemspec
Note: this names your gemspec the same as the directory it sits in.


You can package these together and drop them somewhere in your Rakefile, like this:
task :cultivate do
system "touch Manifest.txt; rake check_manifest | grep -v \"(in \" | patch"
system "rake debug_gem | grep -v \"(in \" > `basename \\`pwd\\``.gemspec"
end

Then just type "rake cultivate" to auto-generate your Manifest.txt and Gemspec!

2 comments:

Anonymous said...

Hey very nice blog!! Man .. Beautiful .. Amazing .. I will bookmark your blog and take the feeds also...

Anonymous said...

You are a very smart person!