InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

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

Posted by Werner Schuster on Jun 12, 2009

Sections
Architecture & Design,
Development,
Operations & Infrastructure
Topics
Ruby ,
Domain Specific Languages ,
Deployment / Datacenter
Tags
Deployment ,
Rake ,
Automation

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.

No comments

Watch Thread Reply

Educational Content

Jesper Boeg on Priming Kanban

In this interview, Jesper Boeg, author of the new InfoQ book – Priming Kanban, discusses the keys to using Kanban effectively, and how to get started if you are currently using other approaches.

New-age Transactional Systems - Not Your Grandpa's OLTP

John Hugg discusses high volume transaction processing applications with high and low frequency profiles, and how VoltDB can be used for that purpose.

Cool Code

Kevlin Henney examines code samples to see what can be learned from them starting from the premise that one won’t write great code unless he knows how to read it.

Collaboration: At the Extremities of Extreme

Jason Ayers share the observations he made watching a team of developers collaborating in real time on the same code base, pushing XP, pair programming and continuous integration to their extremes.

Yesod Web Framework

Michael Snoyman presents Yesod, a web framework written in Haskell and containing a web server, templating, ORM, libraries (templating, gravatar, etc.).

Transactions without Transactions

Richard Kreuter and Kyle Banker on how to avoid classical RDBMS transactional systems by using compensation mechanisms, transactional messaging or transactional procedures.

Attila Szegedi on JVM and GC Performance Tuning at Twitter

Attila Szegedi talks about performance tuning Java and Scala programs at Twitter: how to approach GC problems, the importance of asynchronous I/O, when to use MySQL/Cassandra/Redis, and much more.

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.