crab 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ # vim: set ft=ruby:
3
+
4
+ require 'crab'
5
+
6
+ include Crab::Utilities
7
+
8
+ opts = Trollop::options do
9
+ banner <<-BANNER
10
+ crab iteration list: list iterations available in the current project
11
+
12
+ Usage: crab iteration list [options*]
13
+ BANNER
14
+ opt :project, "Project to use (required unless set by 'crab project')", :short => "-p", :type => String
15
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
16
+ end
17
+
18
+ pattern = ARGV.map(&:strip).reject(&:empty?)
19
+ project_name = valid_project_name(opts)
20
+
21
+ Crab::Rally.new(opts[:dry]) do |rally|
22
+ project = rally.find_project(project_name)
23
+ Trollop::die "Project #{opts[:project].inspect} not found" if project.nil?
24
+
25
+ rally.find_iterations(project).each do |iteration|
26
+ puts iteration.name
27
+ end
28
+ end
@@ -5,6 +5,7 @@ Usage: crab release <command> [options*]
5
5
 
6
6
  Available commands:
7
7
 
8
+ list List releases available in the current project
8
9
  help Show this help text
9
10
 
10
11
  --help, -h: Show this message
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ # vim: set ft=ruby:
3
+
4
+ require 'crab'
5
+
6
+ include Crab::Utilities
7
+
8
+ opts = Trollop::options do
9
+ banner <<-BANNER
10
+ crab release list: list releases available in the current project
11
+
12
+ Usage: crab release list [options*]
13
+ BANNER
14
+ opt :project, "Project to use (required unless set by 'crab project')", :short => "-p", :type => String
15
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
16
+ end
17
+
18
+ pattern = ARGV.map(&:strip).reject(&:empty?)
19
+ project_name = valid_project_name(opts)
20
+
21
+ Crab::Rally.new(opts[:dry]) do |rally|
22
+ project = rally.find_project(project_name)
23
+ Trollop::die "Project #{opts[:project].inspect} not found" if project.nil?
24
+
25
+ rally.find_releases(project).each do |release|
26
+ puts release.name
27
+ end
28
+ end
@@ -40,7 +40,7 @@ Crab::Rally.new(opts[:dry]) do |rally|
40
40
  story = rally.find_story_with_id ARGV.first
41
41
 
42
42
  if cmd_opts[:iteration_given]
43
- opts[:iteration] = rally.find_iteration_by_name cmd_opts[:iteration], story.project
43
+ opts[:iteration] = rally.find_iteration_by_name cmd_opts[:iteration], story.rally_object.project
44
44
  Trollop::die "Unknown iteration \"#{cmd_opts[:iteration]}\"" if opts[:iteration].nil?
45
45
  end
46
46
 
data/bin/crab-story-find CHANGED
@@ -10,7 +10,10 @@ crab story find: find a story in Rally
10
10
  Usage: crab story find [options*] [text]
11
11
  BANNER
12
12
  opt :project, "Project to use (required unless set by 'crab project')", :short => "-p", :type => String
13
- opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
13
+ opt :iteration, "Limit search to this iteration", :short => "-i", :type => String
14
+ opt :release, "Limit search to this release", :short => "-r", :type => String
15
+ opt :parent, "Limit search to children of this story", :short => "-P", :type => String
16
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
14
17
  end
15
18
 
16
19
  pattern = ARGV.map(&:strip).reject(&:empty?)
@@ -20,7 +23,12 @@ Crab::Rally.new(opts[:dry]) do |rally|
20
23
  project = rally.find_project(project_name)
21
24
  Trollop::die "Project #{opts[:project].inspect} not found" if project.nil?
22
25
 
23
- rally.find_stories(project, pattern).each do |story|
26
+ find_opts = {}
27
+ find_opts[:iteration] = rally.find_iteration_by_name opts[:iteration], project if opts[:iteration_given]
28
+ find_opts[:release] = rally.find_release_by_name opts[:release], project if opts[:release_given]
29
+ find_opts[:parent] = rally.find_story_with_id opts[:parent] if opts[:parent_given]
30
+
31
+ rally.find_stories(project, pattern, find_opts).each do |story|
24
32
  puts "#{story.formatted_id}: #{story.name} (#{story.state})"
25
33
  end
26
34
  end
data/bin/crab-story-list CHANGED
@@ -10,7 +10,10 @@ crab story find: find a story in Rally
10
10
  Usage: crab story find [options*] [text]
11
11
  BANNER
12
12
  opt :project, "Project to use (required unless set by 'crab project')", :short => "-p", :type => String
13
- opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
13
+ opt :iteration, "Limit search to this iteration", :short => "-i", :type => String
14
+ opt :release, "Limit search to this release", :short => "-r", :type => String
15
+ opt :parent, "Limit search to children of this story", :short => "-P", :type => String
16
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
14
17
  end
15
18
 
16
19
  pattern = ARGV.map(&:strip).reject(&:empty?)
@@ -20,7 +23,12 @@ Crab::Rally.new(opts[:dry]) do |rally|
20
23
  project = rally.find_project(project_name)
21
24
  Trollop::die "Project #{opts[:project].inspect} not found" if project.nil?
22
25
 
23
- rally.find_stories(project, pattern).each do |story|
26
+ find_opts = {}
27
+ find_opts[:iteration] = rally.find_iteration_by_name opts[:iteration], project if opts[:iteration_given]
28
+ find_opts[:release] = rally.find_release_by_name opts[:release], project if opts[:release_given]
29
+ find_opts[:parent] = rally.find_story_with_id opts[:parent] if opts[:parent_given]
30
+
31
+ rally.find_stories(project, pattern, find_opts).each do |story|
24
32
  puts "#{story.formatted_id}: #{story.name} (#{story.state})"
25
33
  end
26
34
  end
data/bin/crab-story-ls CHANGED
@@ -10,7 +10,10 @@ crab story find: find a story in Rally
10
10
  Usage: crab story find [options*] [text]
11
11
  BANNER
12
12
  opt :project, "Project to use (required unless set by 'crab project')", :short => "-p", :type => String
13
- opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
13
+ opt :iteration, "Limit search to this iteration", :short => "-i", :type => String
14
+ opt :release, "Limit search to this release", :short => "-r", :type => String
15
+ opt :parent, "Limit search to children of this story", :short => "-P", :type => String
16
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
14
17
  end
15
18
 
16
19
  pattern = ARGV.map(&:strip).reject(&:empty?)
@@ -20,7 +23,12 @@ Crab::Rally.new(opts[:dry]) do |rally|
20
23
  project = rally.find_project(project_name)
21
24
  Trollop::die "Project #{opts[:project].inspect} not found" if project.nil?
22
25
 
23
- rally.find_stories(project, pattern).each do |story|
26
+ find_opts = {}
27
+ find_opts[:iteration] = rally.find_iteration_by_name opts[:iteration], project if opts[:iteration_given]
28
+ find_opts[:release] = rally.find_release_by_name opts[:release], project if opts[:release_given]
29
+ find_opts[:parent] = rally.find_story_with_id opts[:parent] if opts[:parent_given]
30
+
31
+ rally.find_stories(project, pattern, find_opts).each do |story|
24
32
  puts "#{story.formatted_id}: #{story.name} (#{story.state})"
25
33
  end
26
34
  end
data/bin/crab-story-up CHANGED
@@ -40,7 +40,7 @@ Crab::Rally.new(opts[:dry]) do |rally|
40
40
  story = rally.find_story_with_id ARGV.first
41
41
 
42
42
  if cmd_opts[:iteration_given]
43
- opts[:iteration] = rally.find_iteration_by_name cmd_opts[:iteration], story.project
43
+ opts[:iteration] = rally.find_iteration_by_name cmd_opts[:iteration], story.rally_object.project
44
44
  Trollop::die "Unknown iteration \"#{cmd_opts[:iteration]}\"" if opts[:iteration].nil?
45
45
  end
46
46
 
@@ -40,7 +40,7 @@ Crab::Rally.new(opts[:dry]) do |rally|
40
40
  story = rally.find_story_with_id ARGV.first
41
41
 
42
42
  if cmd_opts[:iteration_given]
43
- opts[:iteration] = rally.find_iteration_by_name cmd_opts[:iteration], story.project
43
+ opts[:iteration] = rally.find_iteration_by_name cmd_opts[:iteration], story.rally_object.project
44
44
  Trollop::die "Unknown iteration \"#{cmd_opts[:iteration]}\"" if opts[:iteration].nil?
45
45
  end
46
46
 
@@ -1,10 +1,38 @@
1
- #!/usr/bin/env ruby
2
1
  # vim: set ft=ruby :
3
-
4
2
  require 'crab'
5
3
 
6
- puts <<-BANNER
7
- crab testcase find: find a test case in Rally
4
+ include Crab::Utilities
5
+
6
+ opts = Trollop::options do
7
+ banner <<-BANNER
8
+ crab testcase find: find a testcase in Rally
9
+
10
+ Usage: crab testcase find [options*] [text]
11
+ BANNER
12
+ opt :project, "Project to use (required unless set by 'crab project')", :short => "-p", :type => String
13
+ opt :story, "Limit search to testcases of this story", :short => "-s", :type => String
14
+ opt :priority, "Priority (one of: #{Crab::TestCase::PRIORITIES.join(" ")}", :short => '-P', :type => String
15
+ opt :risk, "Risk (one of: #{Crab::TestCase::RISKS.join(" ")})", :short => '-r', :type => String
16
+ opt :method, "Method (one of: #{Crab::TestCase::METHODS.join(" ")})", :short => '-m', :type => String
17
+ opt :type, "Type (one of: #{Crab::TestCase::TYPES.join(" ")})", :short => '-t', :type => String
18
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
19
+ end
20
+
21
+ pattern = ARGV.map(&:strip).reject(&:empty?)
22
+ project_name = valid_project_name(opts)
23
+
24
+ Crab::Rally.new(opts[:dry]) do |rally|
25
+ project = rally.find_project(project_name)
26
+ Trollop::die "Project #{opts[:project].inspect} not found" if project.nil?
27
+
28
+ find_opts = {}
29
+ find_opts[:story] = rally.find_story_with_id opts[:story] if opts[:story_given]
8
30
 
9
- Usage: crab testcase find <story> [options*]
10
- BANNER
31
+ rally.find_testcases(project, pattern, find_opts).each do |tc|
32
+ if tc.story
33
+ puts "#{tc.story.formatted_id}/#{tc.formatted_id}: #{tc.name} (#{tc.tags.join(" ")})"
34
+ else
35
+ puts "#{tc.formatted_id}: #{tc.name} (#{tc.tags.join(" ")})"
36
+ end
37
+ end
38
+ end
data/bin/crab-testcase-ls CHANGED
@@ -1,10 +1,38 @@
1
- #!/usr/bin/env ruby
2
1
  # vim: set ft=ruby :
3
-
4
2
  require 'crab'
5
3
 
6
- puts <<-BANNER
7
- crab testcase find: find a test case in Rally
4
+ include Crab::Utilities
5
+
6
+ opts = Trollop::options do
7
+ banner <<-BANNER
8
+ crab testcase find: find a testcase in Rally
9
+
10
+ Usage: crab testcase find [options*] [text]
11
+ BANNER
12
+ opt :project, "Project to use (required unless set by 'crab project')", :short => "-p", :type => String
13
+ opt :story, "Limit search to testcases of this story", :short => "-s", :type => String
14
+ opt :priority, "Priority (one of: #{Crab::TestCase::PRIORITIES.join(" ")}", :short => '-P', :type => String
15
+ opt :risk, "Risk (one of: #{Crab::TestCase::RISKS.join(" ")})", :short => '-r', :type => String
16
+ opt :method, "Method (one of: #{Crab::TestCase::METHODS.join(" ")})", :short => '-m', :type => String
17
+ opt :type, "Type (one of: #{Crab::TestCase::TYPES.join(" ")})", :short => '-t', :type => String
18
+ opt :dry, "Dry-run (don't change anything)", :short => "-D", :default => false
19
+ end
20
+
21
+ pattern = ARGV.map(&:strip).reject(&:empty?)
22
+ project_name = valid_project_name(opts)
23
+
24
+ Crab::Rally.new(opts[:dry]) do |rally|
25
+ project = rally.find_project(project_name)
26
+ Trollop::die "Project #{opts[:project].inspect} not found" if project.nil?
27
+
28
+ find_opts = {}
29
+ find_opts[:story] = rally.find_story_with_id opts[:story] if opts[:story_given]
8
30
 
9
- Usage: crab testcase find <story> [options*]
10
- BANNER
31
+ rally.find_testcases(project, pattern, find_opts).each do |tc|
32
+ if tc.story
33
+ puts "#{tc.story.formatted_id}/#{tc.formatted_id}: #{tc.name} (#{tc.tags.join(" ")})"
34
+ else
35
+ puts "#{tc.formatted_id}: #{tc.name} (#{tc.tags.join(" ")})"
36
+ end
37
+ end
38
+ end
@@ -26,6 +26,7 @@ Feature: Subcommand Help
26
26
  | release | Usage: crab release <command> [options*] |
27
27
  | story | Usage: crab story <command> [options*] |
28
28
  | testcase | Usage: crab testcase <command> [options*] |
29
+
29
30
  | story create | Usage: crab story create <name> [options*] |
30
31
  | story update | Usage: crab story update <id> [options*] |
31
32
  | story delete | Usage: crab story delete <id> [options*] |
@@ -35,11 +36,17 @@ Feature: Subcommand Help
35
36
  | story rename | Usage: crab story rename <id> <name> [options*] |
36
37
  | story show | Usage: crab story show <id> [options*] |
37
38
  | story help | Usage: crab story <command> [options*] |
39
+
38
40
  | testcase create | Usage: crab testcase create <story> <name> [options*] |
39
41
  | testcase update | Usage: crab testcase update <id> [options*] |
40
42
  | testcase delete | Usage: crab testcase delete <id> [options*] |
41
- | testcase find | Usage: crab testcase find <story> [options*] |
43
+ | testcase find | Usage: crab testcase find [options*] [text] |
42
44
  | testcase show | Usage: crab testcase show <id> [options*] |
43
45
  | testcase help | Usage: crab testcase <command> [options*] |
44
46
 
47
+ | release help | Usage: crab release <command> [options*] |
48
+ | release list | Usage: crab release list [options*] |
49
+
50
+ | iteration help | Usage: crab iteration <command> [options*] |
51
+ | iteration list | Usage: crab iteration list [options*] |
45
52
 
data/lib/crab/rally.rb CHANGED
@@ -23,26 +23,53 @@ module Crab
23
23
 
24
24
  def find_story_with_id story_id
25
25
  story = @rally.find(:hierarchical_requirement) { equal :formatted_i_d, story_id }.first
26
+ Trollop::die "Story with ID #{story_id.inspect} not found" if story.nil?
26
27
  Crab::Story.new(story, @dry_run)
27
28
  end
28
29
 
29
- def find_all_stories(opts={})
30
- @rally.find_all(:hierarchical_requirement, {:fetch => true}.merge(opts)).map do |story|
31
- Crab::Story.new(story, @dry_run)
30
+ def find_testcases(project, pattern, opts)
31
+ if pattern.join.empty? && opts.empty?
32
+ return @rally.find_all(:test_case, :fetch => true, :project => project).map {|tc| Crab::TestCase.new(tc, @dry_run) }
32
33
  end
34
+
35
+ rally_testcases = @rally.find(:test_case, :fetch => true, :project => project) do
36
+ _or_ do
37
+ (pattern.map(&:downcase) + pattern.map(&:capitalize)).each do |word|
38
+ contains :name, word
39
+ contains :description, word
40
+ contains :notes, word
41
+ end
42
+ end
43
+
44
+ equal :work_product, opts[:story].rally_object if opts[:story]
45
+
46
+ equal :risk, opts[:risk].capitalize if opts[:risk]
47
+ equal :method, opts[:method].capitalize if opts[:method]
48
+ equal :priority, opts[:priority].capitalize if opts[:priority]
49
+ equal :type, opts[:type].capitalize if opts[:type]
50
+ end
51
+
52
+ rally_testcases.map {|tc| Crab::TestCase.new(tc, @dry_run) }
33
53
  end
34
54
 
35
- def find_stories(project, pattern=[])
36
- return find_all_stories :project => project if pattern.empty?
55
+ def find_stories(project, pattern, opts)
56
+ if pattern.join.empty? && opts.empty?
57
+ return @rally.find_all(:hierarchical_requirement, :fetch => true, :project => project).map {|s| Crab::Story.new(s, @dry_run) }
58
+ end
59
+
60
+ p pattern
37
61
 
38
62
  rally_stories = @rally.find(:hierarchical_requirement, :fetch => true, :project => project) do
39
- pattern.each do |word|
40
- _or_ do
63
+ _or_ do
64
+ (pattern.map(&:downcase) + pattern.map(&:capitalize)).each do |word|
41
65
  contains :name, word
42
66
  contains :description, word
43
67
  contains :notes, word
44
68
  end
45
69
  end
70
+ equal :iteration, opts[:iteration] if opts[:iteration]
71
+ equal :release, opts[:release] if opts[:release]
72
+ equal :parent, opts[:parent].rally_object if opts[:parent]
46
73
  end
47
74
 
48
75
  rally_stories.map {|story| Crab::Story.new(story, @dry_run) }
@@ -52,10 +79,18 @@ module Crab
52
79
  @rally.find(:project, :fetch => true) { equal :name, name }.first
53
80
  end
54
81
 
82
+ def find_iterations(project)
83
+ @rally.find_all(:iteration, :project => project)
84
+ end
85
+
55
86
  def find_iteration_by_name(name, project)
56
87
  @rally.find(:iteration, :project => project) { equal :name, name }.first
57
88
  end
58
89
 
90
+ def find_releases(project)
91
+ @rally.find_all(:release, :project => project, :fetch => true)
92
+ end
93
+
59
94
  def find_release_by_name(name, project)
60
95
  @rally.find(:release, :project => project) { equal :name, name }.first
61
96
  end
data/lib/crab/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Crab
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crab
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Carlos Villela
@@ -152,11 +152,13 @@ executables:
152
152
  - crab-help
153
153
  - crab-iteration
154
154
  - crab-iteration-help
155
+ - crab-iteration-list
155
156
  - crab-login
156
157
  - crab-logout
157
158
  - crab-project
158
159
  - crab-release
159
160
  - crab-release-help
161
+ - crab-release-list
160
162
  - crab-story
161
163
  - crab-story-add
162
164
  - crab-story-change
@@ -208,11 +210,13 @@ files:
208
210
  - bin/crab-help
209
211
  - bin/crab-iteration
210
212
  - bin/crab-iteration-help
213
+ - bin/crab-iteration-list
211
214
  - bin/crab-login
212
215
  - bin/crab-logout
213
216
  - bin/crab-project
214
217
  - bin/crab-release
215
218
  - bin/crab-release-help
219
+ - bin/crab-release-list
216
220
  - bin/crab-story
217
221
  - bin/crab-story-add
218
222
  - bin/crab-story-change