BT
x Your opinion matters! Please fill in the InfoQ Survey about your reading habits!

3 Ruby Project Time Savers: Hoe 2.0.0, YARD, Whenever

by Werner Schuster on Jun 12, 2009 |

Let's take a look at 3 Ruby tools that help cut down on some of the yak shaving involved in creating and deploying Ruby projects.

The first step in a project's life is the creation: setting up a directory and creating the basic files such as the Rakefile, Gems metadata, and more. Hoe automates all of these steps. After installation (sudo gem install hoe), creating a project is easy:

sow my_project_name

creates a new project, directory and all the necessary files, set up with the project name. More importantly, the project's set up with tasks that automate various processes such as building the Gem, pushing it to RubyForge, announce the release, and more. A list of tasks can be seen by running

rake --describe

in the project directory.
Hoe can be configured in the project's Rakefile:

Hoe.new('my_project_name, my_project_name::VERSION) do |p|
 # config options as Ruby code
end

Hoe 2.0.0 was recently released with some improvements, eg. it's now extensible with modules.

After the project's set up it's time to write the code - hopefully with with sufficient documentation. Ruby developers are familiar with RDoc, but a competitor is available with YARD. YARD offers extensibility and Javadoc-style annotations for Ruby code. While development (YARD Github repository) was slow according to its developer, the new release brings some improvements.
One of the changes of the 0.2.3 release is a new way to parse Ruby code. Tools like RDoc or YARD need to parse Ruby code to find out the classes, methods and other aspects in the Ruby source code.
While YARD still uses its home grown Ruby parser on 1.8.x, on Ruby 1.9.x it now uses Ripper to get the AST from Ruby source code. Using Ripper brings more performance and accuracy of the parsing results (writing a complete Ruby parser from scratch takes a while - Ripper provides access to the parse tree used in the Ruby VM).

Finally - when a project's deployed, it can be necessary to set up or modify repeating tasks. The tool of choice, on Unix systems, is cron. Creating entries in cron's crontab file them can now be automated with a bit of Ruby code using Whenever.
Whenever is configured using the same approach to embedded DSLs as Rake, Hoe and others. An example from the Whenever Wiki:

every 2.days, :at => '4:30am' do
  command "/usr/bin/my_great_command" 
end

is translated to a cron entry:

30 4 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31 * * /usr/bin/my_great_command

The Whenever configuration is more readable and probably easier to modify - even for developers who never got around to understanding the crontab format.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT