Class: Crab::Rally
Instance Method Summary
collapse
Methods included from Utilities
#add_or_update_options, #credentials_file, #current_project_name, #sanitize, #sanitize_options, #state_after, #state_before, #state_from, #valid_credentials_file, #valid_project_name
Methods included from Logging
#logger
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
19
|
# File 'lib/crab/rally.rb', line 15
def connect
get_credentials
logger.info "Connecting to Rally as #{@username}..."
@rally = ::RallyRestAPI.new :username => @username, :password => @password
end
|
#create_story(opts) ⇒ Object
103
104
105
106
107
108
109
110
111
|
# File 'lib/crab/rally.rb', line 103
def create_story(opts)
logger.info "Creating story with #{opts.keys.inspect}"
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
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/crab/rally.rb', line 113
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)
logger.info "Creating test case with #{opts.keys.inspect}"
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_iteration_by_name(name, project) ⇒ Object
84
85
86
87
88
89
|
# File 'lib/crab/rally.rb', line 84
def find_iteration_by_name(name, project)
logger.info "Looking for iteration #{name.inspect} in #{project.name.inspect}"
iteration = @rally.find(:iteration, :project => project) { equal :name, name }.first
Trollop::die "Unknown iteration \"#{name}\"" if iteration.nil?
iteration
end
|
#find_iterations(project) ⇒ Object
79
80
81
82
|
# File 'lib/crab/rally.rb', line 79
def find_iterations(project)
logger.info "Looking for all iterations in #{project.name.inspect}"
@rally.find_all(:iteration, :project => project)
end
|
#find_project(name) ⇒ Object
74
75
76
77
|
# File 'lib/crab/rally.rb', line 74
def find_project(name)
logger.info "Looking for project #{name.inspect}"
@rally.find(:project, :fetch => true) { equal :name, name }.first
end
|
#find_release_by_name(name, project) ⇒ Object
96
97
98
99
100
101
|
# File 'lib/crab/rally.rb', line 96
def find_release_by_name(name, project)
logger.info "Looking for release #{name.inspect} in #{project.name.inspect}"
release = @rally.find(:release, :project => project) { equal :name, name }.first
Trollop::die "Unknown release \"#{name}\"" if release.nil?
release
end
|
#find_releases(project) ⇒ Object
91
92
93
94
|
# File 'lib/crab/rally.rb', line 91
def find_releases(project)
logger.info "Looking for all releases in #{project.name.inspect}"
@rally.find_all(:release, :project => project, :fetch => true)
end
|
#find_stories(project, pattern, opts) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/crab/rally.rb', line 55
def find_stories(project, pattern, opts)
logger.info "Looking for stories matching #{pattern.inspect} with options #{opts.keys.inspect} in #{project.name.inspect}"
if pattern.join.empty? && opts.empty?
return @rally.find_all(:hierarchical_requirement, :fetch => true, :project => project).map {|s| Crab::Story.new(s, @dry_run) }
end
rally_stories = @rally.find(:hierarchical_requirement, :fetch => true, :project => project) do
Crab::Rally.search_for_words_in pattern, self
equal :iteration, opts[:iteration] if opts[:iteration]
equal :release, opts[:release] if opts[:release]
equal :parent, opts[:parent].rally_object if opts[:parent]
end
rally_stories.map {|story| Crab::Story.new(story, @dry_run) }.tap do |stories|
logger.info "Found #{stories.size} stories"
end
end
|
#find_story_with_id(story_id) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/crab/rally.rb', line 26
def find_story_with_id story_id
logger.info "Looking up story with ID #{story_id}"
story = @rally.find(:hierarchical_requirement) { equal :formatted_i_d, story_id }.first
Trollop::die "Story with ID #{story_id.inspect} not found" if story.nil?
Crab::Story.new(story, @dry_run)
end
|
#find_test_case(tc_id) ⇒ Object
127
128
129
130
131
132
|
# File 'lib/crab/rally.rb', line 127
def find_test_case(tc_id)
logger.info "Looking up test case with ID #{tc_id}"
tc = @rally.find(:test_case) { equal :formatted_i_d, tc_id }.first
Trollop::die "Test case with ID #{tc_id.inspect} not found" if tc.nil?
Crab::TestCase.new(tc, @dry_run)
end
|
#find_testcases(project, pattern, opts) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/crab/rally.rb', line 33
def find_testcases(project, pattern, opts)
logger.info "Looking for testcases matching #{pattern.inspect} with options #{opts.keys.inspect} in #{project.name.inspect}"
if pattern.join.empty? && opts.empty?
return @rally.find_all(:test_case, :fetch => true, :project => project).map {|tc| Crab::TestCase.new(tc, @dry_run) }
end
rally_testcases = @rally.find(:test_case, :fetch => true, :project => project) do
Crab::Rally.search_for_words_in pattern, self
equal :work_product, opts[:story].rally_object if opts[:story]
equal :risk, opts[:risk].capitalize if opts[:risk]
equal :method, opts[:method].capitalize if opts[:method]
equal :priority, opts[:priority].capitalize if opts[:priority]
equal :type, opts[:type].capitalize if opts[:type]
end
rally_testcases.map {|tc| Crab::TestCase.new(tc, @dry_run) }.tap do |testcases|
logger.info "Found #{testcases.size} test cases"
end
end
|
#get_credentials ⇒ Object
21
22
23
24
|
# File 'lib/crab/rally.rb', line 21
def get_credentials
logger.info "Getting credentials..."
@username, @password = File.read(valid_credentials_file).split /\n/
end
|