diff --git a/examples/.gitignore b/examples/.gitignore index bc66d83..1af2437 100644 --- a/examples/.gitignore +++ b/examples/.gitignore @@ -1,2 +1,2 @@ -00-config.rb +MyVars.rb *~ diff --git a/examples/00-config.rb b/examples/00-config.rb new file mode 100644 index 0000000..9c1d082 --- /dev/null +++ b/examples/00-config.rb @@ -0,0 +1,21 @@ + +#Custom headers +headers = RallyAPI::CustomHttpHeader.new() +headers.name = "Company Name" +headers.vendor = "Vendor Name" +headers.version = "Version client software" + +# Config parameters +@config = {} +@config[:base_url] = "https://trial.rallydev.com/slm" +@config[:username] = "user@company.com" +@config[:password] = "password" +@config[:api_key] = "_Rd3...................................t8EU" # if present; this overrides un/pw +@config[:workspace] = "Workspace" +@config[:project] = "Project" +@config[:version] = "v2.0" +@config[:headers] = headers + +if FileTest.exist?( './MyVars.rb' ) + require './MyVars.rb' +end diff --git a/examples/00-config.rb.template b/examples/00-config.rb.template index 17c56bf..bba32bf 100644 --- a/examples/00-config.rb.template +++ b/examples/00-config.rb.template @@ -15,3 +15,4 @@ headers.version = "Version client software" @config[:version] = "1.42" # If not set, will use default version defined in gem. @config[:headers] = headers +require 'MyVars.rb' diff --git a/examples/09-get-attachment.rb b/examples/09-get-attachment.rb old mode 100644 new mode 100755 index 62f8007..d496b4a --- a/examples/09-get-attachment.rb +++ b/examples/09-get-attachment.rb @@ -1,4 +1,4 @@ -#! /usr/bin/env ruby +#!/usr/bin/env ruby require 'pp' require 'base64' diff --git a/examples/12-attachment-query.rb b/examples/12-attachment-query.rb new file mode 100755 index 0000000..d54a40d --- /dev/null +++ b/examples/12-attachment-query.rb @@ -0,0 +1,59 @@ +#! /usr/bin/env ruby + +require 'rally_api' + +#Configuration for rally connection specified in 00-config.rb +require_relative '00-config' + +def commatize(integer) + return integer.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1,').reverse +end + +def show_results(title,results) + puts title + puts "-----------" + h1 = ' Size FormattedID DisplayName CreationDate Name' + h2 = ' ------------ ----------- ----------- ------------------------ ---------------------------------' + puts h1,h2 + total_size = 0 + sorted = results.sort_by {|r| r.Size} + sorted.each_with_index do |result,result_index| + printf("[%4d/%4d]: %12s %11s %11s %-24s %s\n", + result_index+1, + results.length, + commatize(result.Size.to_i), + result.Artifact.FormattedID, + result.User.DisplayName, + result.CreationDate, + result.Name + ) + total_size += result.Size + end + puts h2,h1 + puts "" + puts "Total Count: #{results.length}" + puts "Total Sizes: #{commatize(total_size)} bytes" +end + +begin + rally = RallyAPI::RallyRestJson.new(@config) + + # + # Get all attachments + # + query = RallyAPI::RallyQuery.new() + query.type = 'attachment' + query.fetch = 'Name,CreationDate,Size,Artifact,User,FormattedID,DisplayName' + query.page_size = 2000 + query.project_scope_up = true + query.project_scope_down = true + + results = rally.find(query) + show_results("All Attachemnts",results) + +rescue Exception=>boom + puts "Rescued #{boom.class}" + puts "Error Message: #{boom}" +end + +#[the end]# diff --git a/lib/rally_api/rally_query.rb b/lib/rally_api/rally_query.rb index e98b9ae..71acc73 100644 --- a/lib/rally_api/rally_query.rb +++ b/lib/rally_api/rally_query.rb @@ -50,6 +50,7 @@ def make_query_params query_params[:projectScopeDown] = @project_scope_down unless @project_scope_down.nil? query_params[:order] = @order unless @order.nil? query_params[:pagesize] = @page_size unless @page_size.nil? + query_params[:limit] = @limit unless @limit.nil? query_params[:search] = @search unless @search.nil? query_params[:types] = @types unless @types.nil? @@ -128,6 +129,9 @@ def parse_query_hash(query_hash) @project_scope_down = query_hash[:project_scope_down] @project_scope_up = query_hash[:project_scope_up] @order = query_hash[:order] + if !query_hash[:pagesize].nil? && query_hash[:page_size].nil? + query_hash[:page_size] = query_hash[:pagesize] + end @page_size = query_hash[:page_size] @limit = query_hash[:limit] @workspace = query_hash[:workspace] diff --git a/lib/rally_api/version.rb b/lib/rally_api/version.rb index 9964fc7..7701575 100644 --- a/lib/rally_api/version.rb +++ b/lib/rally_api/version.rb @@ -4,5 +4,5 @@ #of the applicable Subscription Agreement between your company and #Rally Software Development Corp. module RallyAPI - VERSION = "1.2.0" + VERSION = "1.2.1" end