Permalink
Browse files

Added taskpair to the suite

  • Loading branch information...
Eduardo Maçan
Eduardo Maçan committed Jan 2, 2013
1 parent 0bf6af4 commit b8ef0c607e98ceafad5fef5c0c6a10bee8829779
Showing with 92 additions and 0 deletions.
  1. +1 −0 Gemfile
  2. +1 −0 README.md
  3. +90 −0 taskpair
View
@@ -11,3 +11,4 @@ gem 'rally_rest_api'
gem 'prawn'
gem 'prawn-qrcode'
gem 'gruff'
+gem 'rmagick'
View
@@ -13,6 +13,7 @@ put your username and password in $HOME/.rallyutils , like this:
* addtask - adds a new task under an existing user story
* task - Changes the state of one or more tasks
* csv2tasks - adds a batch of tasks under existing user stories from a csv file
+ * taskpair - edits usernames in a custom 'Pair' tag in rally tasks
Example csv:
View
@@ -0,0 +1,90 @@
+#!/usr/bin/env ruby
+require 'csv'
+require 'rally_rest_api'
+require 'ostruct'
+require 'optparse'
+require 'yaml'
+require 'gruff'
+
+options = OpenStruct.new
+options.csvoutput = false
+options.pdfouput = false
+options.iteration = ""
+options.user = nil
+options.password = nil
+
+opts = OptionParser.new
+opts.banner = "Usage: taskpair [options] TASKID username , username ..."
+
+opts.on('-U username','--user=username','Provides a Rally User') do |user|
+ options.user = user
+end
+opts.on('-P password','--password=password','Provides a Rally Password') do |pass|
+ options.password = pass
+end
+
+opts.on('-r','--remove','Removes rally users from the task') do |user|
+ options.action='remove'
+end
+
+opts.on('-a','--add','Adds rally users to the task') do |user|
+ options.action='add'
+end
+
+opts.on_tail( '-h', '--help', 'Displays this screen' ) do
+ puts opts
+ exit
+end
+
+opts.parse!(ARGV)
+obj_name = ARGV.shift
+
+if !obj_name then
+ puts opts
+ exit
+end
+
+begin
+ config = YAML.load_file("#{Dir.home}/.rallyutils")
+rescue
+ if !options.user and !options.password then
+ puts opts
+ puts "\nERROR: #{Dir.home}/.rallyutils not found and no user/password provided"
+ exit
+ end
+end
+
+rally_user=options.user || config["user"]
+rally_pass=options.password || config["password"]
+
+#Queries iteratio
+rally = RallyRestAPI.new(:username => rally_user, :password => rally_pass)
+res = rally.find( :task ) { equal :formatted_i_d , obj_name }
+task = res.first
+
+pair = []
+if task.pair then
+ pair = task.pair.split(',')
+end
+
+
+if options.action == 'add' then
+ ARGV.each do |user|
+ if !pair.include?(user) then
+ pair.push(user)
+ end
+ end
+end
+
+if options.action == 'remove' then
+ ARGV.each do |user|
+ if pair.include?(user) then
+ pair.delete(user)
+ end
+ end
+end
+if options.action then
+ task.update(:pair => pair.join(','))
+else
+ puts pair
+end

0 comments on commit b8ef0c6

Please sign in to comment.