cardigan 0.0.9 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. data/.gemtest +0 -0
  2. data/Rakefile +6 -0
  3. data/bin/cardigan +2 -0
  4. data/lib/cardigan/cli.rb +18 -20
  5. data/lib/cardigan/command/add_transitions.rb +27 -0
  6. data/lib/cardigan/command/batch_update_cards.rb +15 -14
  7. data/lib/cardigan/command/change_status.rb +18 -11
  8. data/lib/cardigan/command/change_value.rb +11 -10
  9. data/lib/cardigan/command/claim_cards.rb +15 -13
  10. data/lib/cardigan/command/commit_changes.rb +15 -0
  11. data/lib/cardigan/command/count_cards.rb +6 -2
  12. data/lib/cardigan/command/create_card.rb +14 -11
  13. data/lib/cardigan/command/destroy_cards.rb +15 -13
  14. data/lib/cardigan/command/edit_value.rb +12 -11
  15. data/lib/cardigan/command/export_cards.rb +9 -4
  16. data/lib/cardigan/command/filter_cards.rb +6 -0
  17. data/lib/cardigan/command/import_cards.rb +18 -4
  18. data/lib/cardigan/command/list_cards.rb +5 -0
  19. data/lib/cardigan/command/open_card.rb +20 -12
  20. data/lib/cardigan/command/open_workflow.rb +14 -12
  21. data/lib/cardigan/command/remove_transitions.rb +25 -0
  22. data/lib/cardigan/command/show_entry.rb +12 -10
  23. data/lib/cardigan/command/specify_display_columns.rb +6 -0
  24. data/lib/cardigan/command/specify_sort_columns.rb +6 -0
  25. data/lib/cardigan/command/total_cards.rb +6 -2
  26. data/lib/cardigan/command/unclaim_cards.rb +13 -13
  27. data/lib/cardigan/command/unfilter_cards.rb +6 -0
  28. data/lib/cardigan/commands.rb +10 -0
  29. data/lib/cardigan/entry_context.rb +7 -12
  30. data/lib/cardigan/filtered_repository.rb +9 -5
  31. data/lib/cardigan/io.rb +1 -1
  32. data/lib/cardigan/root_context.rb +21 -23
  33. data/lib/cardigan/workflow_context.rb +12 -29
  34. data/lib/cardigan/workflow_repository.rb +18 -10
  35. data/spec/command/add_transitions_spec.rb +35 -0
  36. data/spec/command/batch_update_cards_spec.rb +9 -0
  37. data/spec/command/change_status_spec.rb +9 -0
  38. data/spec/command/change_value_spec.rb +9 -0
  39. data/spec/command/claim_cards_spec.rb +9 -0
  40. data/spec/command/commit_changes_spec.rb +9 -0
  41. data/spec/command/count_cards_spec.rb +68 -0
  42. data/spec/command/create_card_spec.rb +9 -0
  43. data/spec/command/destroy_cards_spec.rb +9 -0
  44. data/spec/command/edit_value_spec.rb +9 -0
  45. data/spec/command/export_cards_spec.rb +9 -0
  46. data/spec/command/filter_cards_spec.rb +9 -0
  47. data/spec/command/import_cards_spec.rb +9 -0
  48. data/spec/command/list_cards_spec.rb +9 -0
  49. data/spec/command/open_card_spec.rb +9 -0
  50. data/spec/command/open_workflow_spec.rb +9 -0
  51. data/spec/command/remove_transitions_spec.rb +25 -0
  52. data/spec/command/show_entry_spec.rb +9 -0
  53. data/spec/command/specify_display_columns_spec.rb +9 -0
  54. data/spec/command/specify_sort_columns_spec.rb +9 -0
  55. data/spec/command/total_cards_spec.rb +82 -0
  56. data/spec/command/unfilter_cards_spec.rb +9 -0
  57. data/spec/spec_helper.rb +25 -0
  58. data/spec/text_report_formatter_spec.rb +47 -0
  59. metadata +100 -35
  60. data/lib/cardigan/command/select_columns.rb +0 -20
  61. data/lib/cardigan/context.rb +0 -60
  62. data/lib/cardigan/directory.rb +0 -34
  63. data/lib/cardigan/repository.rb +0 -54
  64. data/lib/cardigan/symbol_extensions.rb +0 -3
@@ -0,0 +1,82 @@
1
+ require File.dirname(__FILE__)+'/../spec_helper'
2
+ require 'cardigan/command/total_cards'
3
+
4
+ describe Cardigan::Command::TotalCards do
5
+ with_usage '<numeric field> <grouping field>*'
6
+ with_help 'Calculates totals for the specified numeric field aggregated across the specified grouping fields'
7
+
8
+ before do
9
+ @repository, @prompt = stub(:repository), MockPrompt.new
10
+ @command = Cardigan::Command::TotalCards.new @repository, @prompt
11
+ end
12
+
13
+ [nil, ''].each do |parameter|
14
+ it "should count single row when called with #{parameter}" do
15
+ @command.execute parameter
16
+ @prompt.should have_received "missing required numeric total field"
17
+ end
18
+ end
19
+
20
+ it 'should extract value for single row when no grouping fields are provided' do
21
+ @repository.stub!(:cards).and_return [{'points' => '1'}]
22
+ @command.execute "points"
23
+
24
+ @prompt.messages.should == [
25
+ ' --------',
26
+ '| points |',
27
+ ' --------',
28
+ '| 1 |',
29
+ ' --------'
30
+ ]
31
+ end
32
+
33
+ it 'should generate total for multiple rows when no grouping fields are provided' do
34
+ @repository.stub!(:cards).and_return [{'points' => '1'},{'points' => '2'}]
35
+ @command.execute "points"
36
+
37
+ @prompt.messages.should == [
38
+ ' --------',
39
+ '| points |',
40
+ ' --------',
41
+ '| 3 |',
42
+ ' --------'
43
+ ]
44
+ end
45
+
46
+ it 'should generate total for multiple rows when grouping fields are provided' do
47
+ @repository.stub!(:cards).and_return [
48
+ {'points' => '1', 'priority' => '1'},
49
+ {'points' => '2', 'priority' => '2'},
50
+ {'points' => '3', 'priority' => '1'}
51
+ ]
52
+ @command.execute "points priority"
53
+
54
+ @prompt.messages.should == [
55
+ ' -------------------',
56
+ '| priority | points |',
57
+ ' -------------------',
58
+ '| 1 | 4 |',
59
+ '| 2 | 2 |',
60
+ ' -------------------'
61
+ ]
62
+ end
63
+
64
+ it 'should generate total for multiple rows when multiple grouping fields are provided' do
65
+ @repository.stub!(:cards).and_return [
66
+ {'points' => '1', 'priority' => '1', 'complexity' => '2'},
67
+ {'points' => '2', 'priority' => '2', 'complexity' => '2'},
68
+ {'points' => '3', 'priority' => '1', 'complexity' => '1'}
69
+ ]
70
+ @command.execute "points priority complexity"
71
+
72
+ @prompt.messages.should == [
73
+ ' --------------------------------',
74
+ '| priority | complexity | points |',
75
+ ' --------------------------------',
76
+ '| 1 | 1 | 3 |',
77
+ '| 1 | 2 | 1 |',
78
+ '| 2 | 2 | 2 |',
79
+ ' --------------------------------'
80
+ ]
81
+ end
82
+ end
@@ -0,0 +1,9 @@
1
+ require File.dirname(__FILE__)+'/../spec_helper'
2
+ require 'cardigan/command/unfilter_cards'
3
+
4
+ describe Cardigan::Command::UnfilterCards do
5
+ with_usage ''
6
+ with_help 'Removes the current filter (or does nothing if no filter has been specified)'
7
+
8
+ before { @command = Cardigan::Command::UnfilterCards.new(nil,nil) }
9
+ end
@@ -0,0 +1,25 @@
1
+ $:.unshift File.dirname(__FILE__)+'/../lib'
2
+
3
+ class MockPrompt
4
+ def initialize
5
+ @said = []
6
+ end
7
+
8
+ def say message
9
+ @said << message
10
+ end
11
+
12
+ def has_received? message
13
+ @said.include? message
14
+ end
15
+
16
+ def messages
17
+ @said
18
+ end
19
+ end
20
+
21
+ require 'shell_shock/command_spec'
22
+
23
+ RSpec.configure do |config|
24
+ config.extend ShellShock::CommandSpec
25
+ end
@@ -0,0 +1,47 @@
1
+ require File.dirname(__FILE__)+'/spec_helper'
2
+ require 'cardigan/text_report_formatter'
3
+
4
+ describe Cardigan::TextReportFormatter do
5
+ before do
6
+ @io = MockPrompt.new
7
+ @formatter = Cardigan::TextReportFormatter.new @io
8
+ end
9
+
10
+ it 'should write nothing with no columns or rows' do
11
+ @formatter.output []
12
+ @io.messages.should be_empty
13
+ end
14
+
15
+ it 'should write a heading with a column but no rows' do
16
+ @formatter.add_column 'foo', 10
17
+ @formatter.output []
18
+ @io.messages.should.should == [
19
+ ' --------------------',
20
+ '| index | foo |',
21
+ ' --------------------',
22
+ ' --------------------'
23
+ ]
24
+ end
25
+
26
+ it 'should write a heading with a column but no rows' do
27
+ @formatter.add_column 'foo', 10
28
+ @formatter.output [], :suppress_index => true
29
+ @io.messages.should.should == [
30
+ ' ------------',
31
+ '| foo |',
32
+ ' ------------',
33
+ ' ------------'
34
+ ]
35
+ end
36
+
37
+ it 'should resize column according to size of heading' do
38
+ @formatter.add_column 'foo', 0
39
+ @formatter.output [], :suppress_index => true
40
+ @io.messages.should.should == [
41
+ ' -----',
42
+ '| foo |',
43
+ ' -----',
44
+ ' -----'
45
+ ]
46
+ end
47
+ end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cardigan
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 9
9
- version: 0.0.9
4
+ prerelease:
5
+ version: 0.1.0
10
6
  platform: ruby
11
7
  authors:
12
8
  - Mark Ryall
@@ -14,51 +10,97 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2010-04-11 00:00:00 +10:00
13
+ date: 2011-07-02 00:00:00 +10:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
21
- name: splat
17
+ name: flat_hash
22
18
  prerelease: false
23
19
  requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
24
21
  requirements:
25
22
  - - ~>
26
23
  - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- - 1
30
- - 0
31
- version: 0.1.0
24
+ version: "0"
32
25
  type: :runtime
33
26
  version_requirements: *id001
34
27
  - !ruby/object:Gem::Dependency
35
- name: uuidtools
28
+ name: splat
36
29
  prerelease: false
37
30
  requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
38
32
  requirements:
39
33
  - - ~>
40
34
  - !ruby/object:Gem::Version
41
- segments:
42
- - 2
43
- - 1
44
- - 1
45
- version: 2.1.1
35
+ version: "0"
46
36
  type: :runtime
47
37
  version_requirements: *id002
48
38
  - !ruby/object:Gem::Dependency
49
- name: activesupport
39
+ name: shell_shock
50
40
  prerelease: false
51
41
  requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
52
43
  requirements:
53
44
  - - ~>
54
45
  - !ruby/object:Gem::Version
55
- segments:
56
- - 2
57
- - 3
58
- - 5
59
- version: 2.3.5
46
+ version: "0"
60
47
  type: :runtime
61
48
  version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: uuidtools
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ version: "2"
58
+ type: :runtime
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: activesupport
62
+ prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: "3"
69
+ type: :runtime
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: i18n
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ type: :runtime
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: rake
84
+ prerelease: false
85
+ requirement: &id007 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: "0.8"
91
+ type: :development
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: rspec
95
+ prerelease: false
96
+ requirement: &id008 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: "2"
102
+ type: :development
103
+ version_requirements: *id008
62
104
  description: |
63
105
  A command line utility that manages cards as individual files so that they can be added to a version control system
64
106
 
@@ -72,10 +114,12 @@ extra_rdoc_files: []
72
114
  files:
73
115
  - lib/cardigan/card_editor.rb
74
116
  - lib/cardigan/cli.rb
117
+ - lib/cardigan/command/add_transitions.rb
75
118
  - lib/cardigan/command/batch_update_cards.rb
76
119
  - lib/cardigan/command/change_status.rb
77
120
  - lib/cardigan/command/change_value.rb
78
121
  - lib/cardigan/command/claim_cards.rb
122
+ - lib/cardigan/command/commit_changes.rb
79
123
  - lib/cardigan/command/count_cards.rb
80
124
  - lib/cardigan/command/create_card.rb
81
125
  - lib/cardigan/command/destroy_cards.rb
@@ -86,27 +130,50 @@ files:
86
130
  - lib/cardigan/command/list_cards.rb
87
131
  - lib/cardigan/command/open_card.rb
88
132
  - lib/cardigan/command/open_workflow.rb
89
- - lib/cardigan/command/select_columns.rb
133
+ - lib/cardigan/command/remove_transitions.rb
90
134
  - lib/cardigan/command/show_entry.rb
91
135
  - lib/cardigan/command/specify_display_columns.rb
92
136
  - lib/cardigan/command/specify_sort_columns.rb
93
137
  - lib/cardigan/command/total_cards.rb
94
138
  - lib/cardigan/command/unclaim_cards.rb
95
139
  - lib/cardigan/command/unfilter_cards.rb
96
- - lib/cardigan/context.rb
97
- - lib/cardigan/directory.rb
140
+ - lib/cardigan/commands.rb
98
141
  - lib/cardigan/entry_context.rb
99
142
  - lib/cardigan/filtered_repository.rb
100
143
  - lib/cardigan/io.rb
101
- - lib/cardigan/repository.rb
102
144
  - lib/cardigan/root_context.rb
103
- - lib/cardigan/symbol_extensions.rb
104
145
  - lib/cardigan/text_report_formatter.rb
105
146
  - lib/cardigan/workflow_context.rb
106
147
  - lib/cardigan/workflow_repository.rb
107
148
  - bin/cardigan
149
+ - spec/command/add_transitions_spec.rb
150
+ - spec/command/batch_update_cards_spec.rb
151
+ - spec/command/change_status_spec.rb
152
+ - spec/command/change_value_spec.rb
153
+ - spec/command/claim_cards_spec.rb
154
+ - spec/command/commit_changes_spec.rb
155
+ - spec/command/count_cards_spec.rb
156
+ - spec/command/create_card_spec.rb
157
+ - spec/command/destroy_cards_spec.rb
158
+ - spec/command/edit_value_spec.rb
159
+ - spec/command/export_cards_spec.rb
160
+ - spec/command/filter_cards_spec.rb
161
+ - spec/command/import_cards_spec.rb
162
+ - spec/command/list_cards_spec.rb
163
+ - spec/command/open_card_spec.rb
164
+ - spec/command/open_workflow_spec.rb
165
+ - spec/command/remove_transitions_spec.rb
166
+ - spec/command/show_entry_spec.rb
167
+ - spec/command/specify_display_columns_spec.rb
168
+ - spec/command/specify_sort_columns_spec.rb
169
+ - spec/command/total_cards_spec.rb
170
+ - spec/command/unfilter_cards_spec.rb
171
+ - spec/spec_helper.rb
172
+ - spec/text_report_formatter_spec.rb
108
173
  - README.rdoc
109
174
  - MIT-LICENSE
175
+ - .gemtest
176
+ - Rakefile
110
177
  has_rdoc: true
111
178
  homepage: http://github.com/markryall/cardigan
112
179
  licenses: []
@@ -117,23 +184,21 @@ rdoc_options: []
117
184
  require_paths:
118
185
  - lib
119
186
  required_ruby_version: !ruby/object:Gem::Requirement
187
+ none: false
120
188
  requirements:
121
189
  - - ">="
122
190
  - !ruby/object:Gem::Version
123
- segments:
124
- - 0
125
191
  version: "0"
126
192
  required_rubygems_version: !ruby/object:Gem::Requirement
193
+ none: false
127
194
  requirements:
128
195
  - - ">="
129
196
  - !ruby/object:Gem::Version
130
- segments:
131
- - 0
132
197
  version: "0"
133
198
  requirements: []
134
199
 
135
200
  rubyforge_project:
136
- rubygems_version: 1.3.6
201
+ rubygems_version: 1.6.2
137
202
  signing_key:
138
203
  specification_version: 3
139
204
  summary: command line utility for managing cards (tasks, bugs, stories or whatever)
@@ -1,20 +0,0 @@
1
- module Cardigan
2
- module Command
3
- class SpecifyDisplayColumns
4
- def initialize repository, io
5
- @repository, @io = repository, io
6
- end
7
-
8
- def execute text
9
- if text
10
- @repository.columns = text.scan(/\w+/)
11
- else
12
- @io.say "current columns: #{@repository.columns.join(',')}"
13
- columns = Set.new
14
- @repository.cards.each {|card| columns += card.keys }
15
- @io.say "available columns: #{columns.sort.join(',')}"
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,60 +0,0 @@
1
- require 'readline'
2
- require 'rubygems'
3
- require 'active_support/inflector'
4
-
5
- module Cardigan
6
- module Command
7
- end
8
-
9
- module Context
10
- def command name, *args
11
- require "cardigan/command/#{name}"
12
- Command.const_get(name.to_s.camelize).new(*args)
13
- end
14
-
15
- def refresh
16
- commands = respond_to?(:refresh_commands) ? refresh_commands : []
17
- Readline.completion_proc = lambda do |text|
18
- (commands + @commands.keys + ['quit', 'exit']).grep( /^#{Regexp.escape(text)}/ ).sort
19
- end
20
- Readline.completer_word_break_characters = ''
21
- end
22
-
23
- def push
24
- refresh
25
- begin
26
- while line = Readline.readline(@prompt_text, true)
27
- line.strip!
28
- case line
29
- when 'quit','exit'
30
- return
31
- when /(\w+) (.*)/
32
- process_command $1, $2
33
- when /(\w+)/
34
- process_command $1
35
- else
36
- puts 'unknown command'
37
- end
38
- puts
39
- refresh
40
- end
41
- rescue Interrupt => e
42
- return
43
- end
44
- puts
45
- end
46
-
47
- def process_command name, parameter=nil
48
- m = "#{name}_command".to_sym
49
- if respond_to?(m)
50
- send(m, parameter)
51
- return
52
- end
53
- if @commands[name]
54
- @commands[name].execute parameter
55
- else
56
- @io.say 'unknown command'
57
- end
58
- end
59
- end
60
- end
@@ -1,34 +0,0 @@
1
- require 'yaml'
2
- require 'fileutils'
3
-
4
- module Cardigan
5
- class Directory
6
- def initialize path
7
- @path = File.expand_path(path)
8
- end
9
-
10
- def has_file? file
11
- File.exist? File.join(@path, file)
12
- end
13
-
14
- def load file
15
- YAML::load File.read(File.join(@path, file))
16
- end
17
-
18
- def store file, hash
19
- File.open(File.join(@path, file), 'w') {|f| f.print hash.to_yaml}
20
- end
21
-
22
- def delete file
23
- FileUtils.rm File.join(@path, file)
24
- end
25
-
26
- def create
27
- FileUtils.mkdir_p @path
28
- end
29
-
30
- def find pattern
31
- Dir.glob(File.join(@path, pattern)).map {|path| YAML::load File.read(path) }
32
- end
33
- end
34
- end
@@ -1,54 +0,0 @@
1
- require 'rubygems'
2
- require 'uuidtools'
3
- require 'set'
4
- require 'cardigan/directory'
5
-
6
- module Cardigan
7
- class Repository
8
- attr_reader :cards
9
-
10
- def initialize path
11
- @directory = Directory.new(path)
12
- @directory.create
13
- end
14
-
15
- def refresh
16
- @cards = @directory.find('*.card')
17
- end
18
-
19
- def find_card name
20
- @cards.find {|card| card['name'] == name}
21
- end
22
-
23
- def save card
24
- @directory.store "#{card['id']}.card", card
25
- end
26
-
27
- def destroy card
28
- @directory.delete "#{card['id']}.card"
29
- end
30
-
31
- def find_or_create name
32
- find_card(name) or create('name' => name)
33
- end
34
-
35
- def each
36
- @cards.each {|card| yield card}
37
- end
38
-
39
- def columns
40
- columns = Set.new
41
- each {|card| columns += card.keys }
42
- columns.to_a
43
- end
44
-
45
- def load id
46
- file = "#{id}.card"
47
- @directory.has_file?(file) ? @directory.load(file) : nil
48
- end
49
-
50
- def create hash={}
51
- { 'id' => UUIDTools::UUID.random_create.to_s }.merge hash
52
- end
53
- end
54
- end
@@ -1,3 +0,0 @@
1
- class Symbol
2
- def
3
- end