Class: Crab::Rally
Instance Method Summary
collapse
Methods included from Utilities
#add_or_update_options, #credentials_file, #current_project_name, #sanitize_options, #state_after, #state_before, #state_from, #valid_credentials_file, #valid_project_name
Constructor Details
#initialize(dry_run) ⇒ Rally
Returns a new instance of Rally.
6
7
8
9
10
11
12
13
|
# File 'lib/crab/rally.rb', line 6
def initialize(dry_run)
@dry_run = dry_run
if block_given?
connect
yield self
end
end
|
Instance Method Details
#connect ⇒ Object
15
16
17
18
|
# File 'lib/crab/rally.rb', line 15
def connect
get_credentials
@rally = ::RallyRestAPI.new :username => @username, :password => @password
end
|
#create_story(opts) ⇒ Object
63
64
65
66
67
68
69
|
# File 'lib/crab/rally.rb', line 63
def create_story(opts)
if @dry_run
Crab::DryRun::Story.new opts
else
Crab::Story.new(@rally.create(:hierarchical_requirement, opts), @dry_run)
end
end
|
#create_test_case(story_id, name, opts) ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/crab/rally.rb', line 71
def create_test_case(story_id, name, opts)
story = find_story_with_id story_id
opts = {:name => name, :work_product => story.rally_object, :project => story.rally_object.project}.merge(opts)
if @dry_run
puts "Would create test case for story with ID #{story_id} with #{opts.inspect}"
else
tc = @rally.create(:test_case, opts)
Crab::TestCase.new(tc, @dry_run)
end
end
|
#find_all_stories(opts = {}) ⇒ Object
29
30
31
32
33
|
# File 'lib/crab/rally.rb', line 29
def find_all_stories(opts={})
@rally.find_all(:hierarchical_requirement, {:fetch => true}.merge(opts)).map do |story|
Crab::Story.new(story, @dry_run)
end
end
|
#find_iteration_by_name(name) ⇒ Object
55
56
57
|
# File 'lib/crab/rally.rb', line 55
def find_iteration_by_name(name)
@rally.find(:iteration) { equal :name, name }.first
end
|
#find_project(name) ⇒ Object
51
52
53
|
# File 'lib/crab/rally.rb', line 51
def find_project(name)
@rally.find(:project, :fetch => true) { equal :name, name }.first
end
|
#find_release_by_name(name) ⇒ Object
59
60
61
|
# File 'lib/crab/rally.rb', line 59
def find_release_by_name(name)
@rally.find(:release) { equal :name, name }.first
end
|
#find_stories(project, pattern = []) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/crab/rally.rb', line 35
def find_stories(project, pattern=[])
return find_all_stories :project => project if pattern.empty?
rally_stories = @rally.find(:hierarchical_requirement, :fetch => true, :project => project) do
pattern.each do |word|
_or_ do
contains :name, word
contains :description, word
contains :notes, word
end
end
end
rally_stories.map {|story| Crab::Story.new(story, @dry_run) }
end
|
#find_story_with_id(story_id) ⇒ Object
24
25
26
27
|
# File 'lib/crab/rally.rb', line 24
def find_story_with_id story_id
story = @rally.find(:hierarchical_requirement) { equal :formatted_i_d, story_id }.first
Crab::Story.new(story, @dry_run)
end
|
#find_test_case(tc_id) ⇒ Object
83
84
85
|
# File 'lib/crab/rally.rb', line 83
def find_test_case(tc_id)
Crab::TestCase.new(@rally.find(:test_case) { equal :formatted_i_d, tc_id }.first, @dry_run)
end
|
#get_credentials ⇒ Object
20
21
22
|
# File 'lib/crab/rally.rb', line 20
def get_credentials
@username, @password = File.read(valid_credentials_file).split /\n/
end
|