2. RubyGems
• You know how to install a gem already.
• You probably have a ton of them installed.
• But have you ever thought of writing one?
• Isn't it time to share your own coding
brilliance with the Ruby community?
• But what are the steps for that?
3. Making a Gem
• Run and audit your tests
• Layout your files into the proper directories
• Create a manifest of files in the gem
• Create a Gem Specification file
• Run gem build on your gem specification
• Release the gem to your Rubyforge account
• Dump rdocs for your gem
• Upload to your website on Rubyforge
4. Fight Administrivia
• Those are a lot of manual steps there
• Worse still, you need to repeat them for
every gem you want to write
• Hoe can automate that administrivia for you
• More time for coding
• Faster releases
• Less mistakes
• More likely you'll actually write that gem
5. What Is Hoe?
• Very useful tool by Ryan Davis and Eric
Hodel of the Seattle Ruby Brigade.
• Hoe defines a set of useful rake tasks that
makes gem building simple.
• It also includes the sow script to create a
gem skeleton for you.
• Spade, trowel, shovel, plow, and till are all still
available for your naming needs.
6. Making Gems With Hoe
• gem install hoe ‐‐include‐dependencies
• Setup rubyforge gem
• sow your gem directory.
• Write your code and tests
• Use rake to test, build docs, release, etc.
• Think about the next gem you'll write
7. Amazon Hacks
• Introducing our contrived example...
• http://amazon-hacks.rubyforge.com
• It's simple, but it's my first gem.
• It's also my first Hoe gem.
• So, what exactly does it do?
• Pardon me for a little self-promotion...
9. Playing With Images
i = Amazon::Hacks::Image.build_from_url(url)
i.set_size! :medium
i.url
# => "http://images.amazon.com/images/P/0672328844.01._SCMZZZZZZZ_.jpg"
23. Don't Forget Testing
• rake audit - run ZenTest against your code
• rake multi - run tests against multiple versions
of Ruby
• rake test - run your tests
• rake test_deps - verify there are no hidden
dependencies in your tests
25. Further References
• http://rubygems.org/
• http://seattlerb.rubyforge.com/hoe
• http://seattlerb.rubyforge.org/hoedown.html
• A list of hoe‐built gems
• gem unpack any hoe-built gem and read
the code yourself
• and of course, rake ‐T in any hoe gem