How do I use the Ruby facade to the Rally Rest API

Print this topicEmail this topicSave as PDF

Rally has created a facade in Ruby to easily interact with the data in your subscription via the REST web services API. You can create, read, update, and delete via the Ruby REST API.

Since Ruby is a very flexible and extensible language, we were able to make access to the object model extremely simple. For example, if you have a User Story called 'story', the following code iterates over the tasks.

story.tasks.each { |task| print task.name }

There is no need to make a separate call to fetch Tasks. When you follow domain model 'links' in the Ruby code, the Rally Integrations Toolkit for Ruby automatically loads in the necessary objects for you.

The source code and documentation are stored at the Rally REST RubyForge site.

To start using the API, simply install Ruby (For Windows Users Click Here).

  1. Install the builder gem using the following command 'gem install builder'.
  2. Install the Rally Integrations Toolkit for Ruby Gem (library) using the following command 'gem install rally_rest_api'.

The example code below can be used as a first test.

Product: 
Unlimited
Enterprise
Trial
Community
On-Premise
Application Code: 
The following code logs in to Rally (our preview server), finds an  iteration, then prints all the User Stories along with their associated  Tasks.

require 'rubygems'
require 'rally_rest_api'

# Test

# 'Login to the Rally App'
slm = RallyRestAPI.new(:base_url =>
"https://preview.rallydev.com/slm",
  :username => "guest@company1.com",
  :password => "RallyDev")

# Find an iteration by name
query_result = slm.find(:iteration) {equal :name, "Iteration 6 (OM)"}
iteration = query_result.results.first

# Find all User Stories associated with the iteration
query_result = slm.find(:hierarchical_requirement, :fetch => true,
:order => :rank) {equal :iteration, iteration}
query_result.each { |story|
  puts story.name
 
  # Iterate over each Task in the User Story
  story.tasks.each { |task|
    print "  ", task.name, "\n"
    }
  }
Version:
1.0.3
Company:
Rally Software
© 2012 Rally Software Development Corp | Legal