trollolo 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +21 -2
  3. data/.rubocop_todo.yml +105 -270
  4. data/CHANGELOG.md +10 -0
  5. data/CONTRIBUTING.md +6 -4
  6. data/Gemfile +1 -1
  7. data/README.md +10 -1
  8. data/Rakefile +4 -4
  9. data/bin/trollolo +2 -2
  10. data/lib/backup.rb +21 -23
  11. data/lib/burndown_chart.rb +46 -49
  12. data/lib/burndown_data.rb +21 -21
  13. data/lib/card.rb +23 -32
  14. data/lib/checklist.rb +13 -1
  15. data/lib/cli.rb +105 -110
  16. data/lib/column.rb +11 -10
  17. data/lib/empty_column.rb +2 -2
  18. data/lib/scrum/backlog_mover.rb +3 -3
  19. data/lib/scrum/card_type_detection.rb +1 -1
  20. data/lib/scrum/creator.rb +7 -7
  21. data/lib/scrum/prioritizer.rb +1 -1
  22. data/lib/scrum/sprint_board.rb +4 -4
  23. data/lib/scrum/sprint_cleaner.rb +3 -3
  24. data/lib/scrum/sprint_planning_board.rb +2 -4
  25. data/lib/scrum_board.rb +3 -3
  26. data/lib/settings.rb +29 -27
  27. data/lib/trello_service.rb +1 -1
  28. data/lib/trello_wrapper.rb +9 -9
  29. data/lib/version.rb +1 -1
  30. data/spec/data/card.json +19 -0
  31. data/spec/data/trollolorc +3 -0
  32. data/spec/integration/command_line_spec.rb +14 -14
  33. data/spec/integration/create_burndown_spec.rb +25 -25
  34. data/spec/integration/integration_spec_helper.rb +1 -1
  35. data/spec/integration/wrapper/credentials_input_wrapper +7 -11
  36. data/spec/integration/wrapper/empty_config_trollolo_wrapper +2 -2
  37. data/spec/integration/wrapper/trollolo_wrapper +2 -2
  38. data/spec/unit/backup_spec.rb +14 -14
  39. data/spec/unit/burndown_chart_spec.rb +176 -184
  40. data/spec/unit/burndown_data_spec.rb +21 -23
  41. data/spec/unit/card_spec.rb +38 -24
  42. data/spec/unit/cli_spec.rb +57 -57
  43. data/spec/unit/empty_column_spec.rb +1 -1
  44. data/spec/unit/retrieve_data_spec.rb +13 -13
  45. data/spec/unit/scrum/backlog_mover_spec.rb +8 -8
  46. data/spec/unit/scrum/card_type_detection_spec.rb +12 -12
  47. data/spec/unit/scrum/creator_spec.rb +8 -8
  48. data/spec/unit/scrum/prioritizer_spec.rb +19 -19
  49. data/spec/unit/scrum/priority_name_spec.rb +16 -16
  50. data/spec/unit/scrum/sprint_board_spec.rb +3 -3
  51. data/spec/unit/scrum/sprint_cleaner_spec.rb +15 -15
  52. data/spec/unit/scrum/sprint_planning_board_spec.rb +2 -2
  53. data/spec/unit/scrum_board_spec.rb +56 -56
  54. data/spec/unit/settings_spec.rb +23 -23
  55. data/spec/unit/spec_helper.rb +3 -3
  56. data/spec/unit/support/test_data_operations.rb +4 -0
  57. data/spec/unit/support/update_webmock_data +9 -11
  58. data/spec/unit/support/vcr.rb +3 -3
  59. data/spec/unit/support/webmocks.rb +21 -12
  60. data/spec/unit/trello_wrapper_spec.rb +40 -29
  61. data/trollolo.gemspec +3 -3
  62. metadata +8 -5
@@ -20,13 +20,14 @@ class Card
20
20
  ESTIMATED_REGEX = /\(([\d.]+)\)/
21
21
  SPRINT_NUMBER_REGEX = /\ASprint (\d+)/
22
22
 
23
- def initialize(board_data, card_id)
24
- init_data(board_data, card_id)
23
+ def initialize(board_data, card_id, settings = nil)
24
+ init_data(board_data, card_id, settings)
25
25
  end
26
26
 
27
- def init_data(board_data, card_id)
27
+ def init_data(board_data, card_id, settings = nil)
28
28
  @board_data = board_data
29
- @card_data = @board_data["cards"].find{|c| c["id"] == card_id}
29
+ @settings = settings
30
+ @card_data = @board_data['cards'].find{|c| c['id'] == card_id}
30
31
  end
31
32
 
32
33
  def as_json
@@ -43,52 +44,42 @@ class Card
43
44
  end
44
45
 
45
46
  def done_tasks
46
- count = 0
47
- @card_data["checklists"].each do |checklist|
48
- if checklist["name"] != "Feedback"
49
- checklist["checkItems"].each do |checklist_item|
50
- if checklist_item["state"] == "complete"
51
- count += 1
52
- end
53
- end
54
- end
55
- end
56
- count
47
+ filtered_checklists.map(&:done_tasks).sum
57
48
  end
58
49
 
59
50
  def tasks
60
- count = 0
61
- @card_data["checklists"].each do |checklist|
62
- if checklist["name"] != "Feedback"
63
- count += checklist["checkItems"].count
64
- end
65
- end
66
- count
51
+ filtered_checklists.map(&:tasks).sum
67
52
  end
68
53
 
69
54
  def card_labels
70
- @card_data["labels"]
55
+ @card_data['labels']
71
56
  end
72
57
 
73
58
  def checklists
74
- @card_data["checklists"].map do |checklist|
59
+ @card_data['checklists'].map do |checklist|
75
60
  Checklist.new(checklist)
76
61
  end
77
62
  end
78
63
 
64
+ def filtered_checklists
65
+ checklists.reject do |checklist|
66
+ @settings && @settings.no_task_checklists.include?(checklist.name)
67
+ end
68
+ end
69
+
79
70
  def desc
80
- @card_data["desc"]
71
+ @card_data['desc']
81
72
  end
82
73
 
83
74
  def extra?
84
- self.card_labels.any? do |label|
75
+ card_labels.any? do |label|
85
76
  label['name'].include?('BelowWaterline') ||
86
77
  label['name'].include?('Under waterline')
87
78
  end
88
79
  end
89
80
 
90
81
  def unplanned?
91
- self.card_labels.any? do |label|
82
+ card_labels.any? do |label|
92
83
  label['name'].include?('Unplanned')
93
84
  end
94
85
  end
@@ -104,13 +95,13 @@ class Card
104
95
 
105
96
  def fast_lane?
106
97
  # TODO: move to settings
107
- self.card_labels.map{|l| l['name']}.include?('FastLane')
98
+ card_labels.map{|l| l['name']}.include?('FastLane')
108
99
  end
109
100
 
110
101
  # TODO: rethink storage for meta data for sprint
111
102
  def self.parse_yaml_from_description(description)
112
103
  description =~ /```(yaml)?\n(.*)```/m
113
- yaml = $2
104
+ yaml = Regexp.last_match(2)
114
105
  if yaml
115
106
  return YAML.load(yaml) # throws an exception for invalid yaml
116
107
  else
@@ -119,14 +110,14 @@ class Card
119
110
  end
120
111
 
121
112
  def name
122
- @card_data["name"]
113
+ @card_data['name']
123
114
  end
124
115
 
125
116
  def name=(str)
126
- @card_data["name"] = str
117
+ @card_data['name'] = str
127
118
  end
128
119
 
129
120
  def id
130
- @card_data["id"]
121
+ @card_data['id']
131
122
  end
132
123
  end
@@ -4,6 +4,18 @@ class Checklist
4
4
  end
5
5
 
6
6
  def name
7
- @checklist_data["name"]
7
+ @checklist_data['name']
8
+ end
9
+
10
+ def checklist_items
11
+ @checklist_data['checkItems']
12
+ end
13
+
14
+ def done_tasks
15
+ checklist_items.count { |list_item| list_item['state'] == 'complete' }
16
+ end
17
+
18
+ def tasks
19
+ checklist_items.count
8
20
  end
9
21
  end
data/lib/cli.rb CHANGED
@@ -19,16 +19,16 @@ class Cli < Thor
19
19
 
20
20
  default_task :global
21
21
 
22
- class_option :version, :type => :boolean, :desc => "Show version"
23
- class_option :verbose, :type => :boolean, :desc => "Verbose mode"
24
- class_option :raw, :type => :boolean, :desc => "Raw mode"
25
- class_option "board-id", :type => :string, :desc => "id of Trello board"
22
+ class_option :version, type: :boolean, desc: 'Show version'
23
+ class_option :verbose, type: :boolean, desc: 'Verbose mode'
24
+ class_option :raw, type: :boolean, desc: 'Raw mode'
25
+ class_option 'board-id', type: :string, desc: 'id of Trello board'
26
26
 
27
- def self.settings= s
27
+ def self.settings=(s)
28
28
  @@settings = s
29
29
  end
30
30
 
31
- desc "global", "Global options", :hide => true
31
+ desc 'global', 'Global options', hide: true
32
32
  def global
33
33
  if options[:version]
34
34
  puts "Trollolo: #{@@settings.version}"
@@ -37,7 +37,7 @@ class Cli < Thor
37
37
  end
38
38
  end
39
39
 
40
- desc "get-raw [URL-FRAGMENT]", "Get raw JSON from Trello API"
40
+ desc 'get-raw [URL-FRAGMENT]', 'Get raw JSON from Trello API'
41
41
  long_desc <<EOT
42
42
  Get raw JSON from Trello using the given URL fragment. Trollolo adds the server
43
43
  part and API version as well as the credentials from the Trollolo configuration.
@@ -57,9 +57,9 @@ EOT
57
57
 
58
58
  url = "https://api.trello.com/1/#{url_fragment}"
59
59
  if url_fragment =~ /\?/
60
- url += "&"
60
+ url += '&'
61
61
  else
62
- url += "?"
62
+ url += '?'
63
63
  end
64
64
  url += "key=#{@@settings.developer_public_key}&token=#{@@settings.member_token}"
65
65
  STDERR.puts "Calling #{url}"
@@ -68,14 +68,14 @@ EOT
68
68
  print JSON.pretty_generate(JSON.parse(response.body))
69
69
  end
70
70
 
71
- desc "get-lists", "Get lists"
72
- option "board-id", :desc => "Id of Trello board", :required => true
71
+ desc 'get-lists', 'Get lists'
72
+ option 'board-id', desc: 'Id of Trello board', required: true
73
73
  def get_lists
74
74
  process_global_options options
75
75
  require_trello_credentials
76
76
 
77
77
  trello = TrelloWrapper.new(@@settings)
78
- board = trello.board(board_id(options["board-id"]))
78
+ board = trello.board(board_id(options['board-id']))
79
79
  lists = board.columns
80
80
 
81
81
  if @@settings.raw
@@ -87,14 +87,14 @@ EOT
87
87
  end
88
88
  end
89
89
 
90
- desc "get-cards", "Get cards"
91
- option "board-id", :desc => "Id of Trello board", :required => true
90
+ desc 'get-cards', 'Get cards'
91
+ option 'board-id', desc: 'Id of Trello board', required: true
92
92
  def get_cards
93
93
  process_global_options options
94
94
  require_trello_credentials
95
95
 
96
96
  trello = TrelloWrapper.new(@@settings)
97
- board = trello.board(board_id(options["board-id"]))
97
+ board = trello.board(board_id(options['board-id']))
98
98
  cards = board.cards
99
99
 
100
100
  if @@settings.raw
@@ -102,9 +102,9 @@ EOT
102
102
  cards.each do |card|
103
103
  cards_as_json.push(card.as_json)
104
104
  end
105
- puts "["
106
- puts cards_as_json.join(",")
107
- puts "]"
105
+ puts '['
106
+ puts cards_as_json.join(',')
107
+ puts ']'
108
108
  else
109
109
  cards.each do |card|
110
110
  puts card.name
@@ -112,14 +112,14 @@ EOT
112
112
  end
113
113
  end
114
114
 
115
- desc "get-checklists", "Get checklists"
116
- option "board-id", :desc => "Id of Trello board", :required => true
115
+ desc 'get-checklists', 'Get checklists'
116
+ option 'board-id', desc: 'Id of Trello board', required: true
117
117
  def get_checklists
118
118
  process_global_options options
119
119
  require_trello_credentials
120
120
 
121
121
  trello = TrelloWrapper.new(@@settings)
122
- board = trello.board(board_id(options["board-id"]))
122
+ board = trello.board(board_id(options['board-id']))
123
123
  board.cards.each do |card|
124
124
  card.checklists.each do |checklist|
125
125
  puts checklist.name
@@ -127,17 +127,15 @@ EOT
127
127
  end
128
128
  end
129
129
 
130
- desc "burndowns", "run multiple burndowns"
131
- option "board-list", :desc => "path to board-list.yaml", :required => true
132
- option :plot, :type => :boolean, :desc => "also plot the new data"
133
- option :output, :aliases => :o, :desc => "Output directory"
130
+ desc 'burndowns', 'run multiple burndowns'
131
+ option 'board-list', desc: 'path to board-list.yaml', required: true
132
+ option :plot, type: :boolean, desc: 'also plot the new data'
133
+ option :output, aliases: :o, desc: 'Output directory'
134
134
  def burndowns
135
135
  process_global_options options
136
- board_list = YAML.load_file(options["board-list"])
136
+ board_list = YAML.load_file(options['board-list'])
137
137
  board_list.keys.each do |name|
138
- if name =~ /[^[:alnum:]. _]/ # sanitize
139
- raise "invalid character in team name"
140
- end
138
+ raise 'invalid character in team name' if name =~ /[^[:alnum:]. _]/ # sanitize
141
139
  board = board_list[name]
142
140
  if options['output']
143
141
  destdir = File.join(options['output'], name)
@@ -145,36 +143,35 @@ EOT
145
143
  destdir = name
146
144
  end
147
145
  chart = BurndownChart.new @@settings
148
- if !File.directory?(destdir)
149
- chart.setup(destdir, board["boardid"])
150
- end
151
- chart.update({'output' => destdir, plot: options[:plot]})
146
+ chart.setup(destdir, board['boardid']) unless File.directory?(destdir)
147
+ chart.update('output' => destdir, plot: options[:plot])
152
148
  end
153
149
  end
154
150
 
155
- desc "burndown-init", "Initialize burndown chart"
156
- option :output, :aliases => :o, :desc => "Output directory", :required => true
157
- option "board-id", :desc => "Id of Trello board", :required => true
158
- def burndown_init command = nil
151
+ desc 'burndown-init', 'Initialize burndown chart'
152
+ option :output, aliases: :o, desc: 'Output directory', required: false
153
+ option 'board-id', desc: 'Id of Trello board', required: true
154
+ def burndown_init(command = nil)
159
155
  process_global_options options
160
156
  require_trello_credentials
161
157
 
162
158
  chart = BurndownChart.new @@settings
163
- puts "Preparing directory..."
164
- chart.setup(options[:output], board_id(options["board-id"]))
159
+ puts 'Preparing directory...'
160
+ chart.setup(options[:output] || Dir.pwd, board_id(options['board-id']))
165
161
  end
166
162
 
167
- desc "burndown", "Update burndown chart"
168
- option :output, :aliases => :o, :desc => "Output directory", :required => false
169
- option :new_sprint, :aliases => :n, :desc => "Create new sprint"
170
- option :sprint_number, type: :numeric, :desc => "Provide the number of the sprint"
171
- option :total_days, type: :numeric, desc: "Provide how many days the sprint longs. 10 days by default"
172
- option :weekend_lines, type: :array, desc: "Set the weekend_lines. [3.5, 8.5] by default"
173
- option :plot, :type => :boolean, :desc => "also plot the new data"
174
- option :plot_to_board, :type => :boolean, :desc => "Send the plotted data to the board"
175
- option 'with-fast-lane', :desc => "Plot Fast Lane with new cards bars", :required => false, :type => :boolean
176
- option 'no-tasks', :desc => "Do not plot tasks line", :required => false, :type => :boolean
177
- option 'push-to-api', :desc => 'Push collected data to api endpoint (in json)', :required => false
163
+ desc 'burndown', 'Update burndown chart'
164
+ option :output, aliases: :o, desc: 'Output directory', required: false
165
+ option :new_sprint, aliases: :n, desc: 'Create new sprint'
166
+ option :sprint_number, type: :numeric, desc: 'Provide the number of the sprint'
167
+ option :total_days, type: :numeric, desc: 'Provide how many days the sprint longs. 10 days by default'
168
+ option :weekend_lines, type: :array, desc: 'Set the weekend_lines. [3.5, 8.5] by default'
169
+ option :plot, type: :boolean, desc: 'also plot the new data'
170
+ option :plot_to_board, type: :boolean, desc: 'Send the plotted data to the board'
171
+ option 'with-fast-lane', desc: 'Plot Fast Lane with new cards bars', required: false, type: :boolean
172
+ option 'no-tasks', desc: 'Do not plot tasks line', required: false, type: :boolean
173
+ option 'push-to-api', desc: 'Push collected data to api endpoint (in json)', required: false
174
+ option 'board-id', desc: 'Id of Trello Board'
178
175
  def burndown
179
176
  process_global_options options
180
177
  require_trello_credentials
@@ -192,25 +189,25 @@ EOT
192
189
  end
193
190
  end
194
191
 
195
- desc "plot SPRINT-NUMBER [--output] [--no-tasks] [--with-fast-lane]", "Plot burndown chart for given sprint"
196
- option :output, :aliases => :o, :desc => "Output directory", :required => false
197
- option 'with-fast-lane', :desc => "Plot Fast Lane with new cards bars", :required => false, :type => :boolean
198
- option 'no-tasks', :desc => "Do not plot tasks line", :required => false, :type => :boolean
192
+ desc 'plot SPRINT-NUMBER [--output] [--no-tasks] [--with-fast-lane]', 'Plot burndown chart for given sprint'
193
+ option :output, aliases: :o, desc: 'Output directory', required: false
194
+ option 'with-fast-lane', desc: 'Plot Fast Lane with new cards bars', required: false, type: :boolean
195
+ option 'no-tasks', desc: 'Do not plot tasks line', required: false, type: :boolean
199
196
  def plot(sprint_number)
200
197
  process_global_options options
201
198
  BurndownChart.plot(sprint_number, options)
202
199
  end
203
200
 
204
- desc "backup", "Create backup of board"
205
- option "board-id", :desc => "Id of Trello board", :required => true
201
+ desc 'backup', 'Create backup of board'
202
+ option 'board-id', desc: 'Id of Trello board', required: true
206
203
  def backup
207
204
  process_global_options options
208
205
  require_trello_credentials
209
206
 
210
- Backup.new(@@settings).backup(board_id(options["board-id"]))
207
+ Backup.new(@@settings).backup(board_id(options['board-id']))
211
208
  end
212
209
 
213
- desc "list-backups", "List all backups"
210
+ desc 'list-backups', 'List all backups'
214
211
  def list_backups
215
212
  b = Backup.new @@settings
216
213
  b.list.each do |backup|
@@ -218,93 +215,93 @@ EOT
218
215
  end
219
216
  end
220
217
 
221
- desc "show-backup", "Show backup of board"
222
- option "board-id", :desc => "Id of Trello board", :required => true
223
- option "show-descriptions", :desc => "Show descriptions of cards", :required => false, :type => :boolean
218
+ desc 'show-backup', 'Show backup of board'
219
+ option 'board-id', desc: 'Id of Trello board', required: true
220
+ option 'show-descriptions', desc: 'Show descriptions of cards', required: false, type: :boolean
224
221
  def show_backup
225
- Backup.new(@@settings).show(board_id(options["board-id"]), options)
222
+ Backup.new(@@settings).show(board_id(options['board-id']), options)
226
223
  end
227
224
 
228
- desc "organization", "Show organization info"
229
- option "org-name", :desc => "Name of organization", :required => true
225
+ desc 'organization', 'Show organization info'
226
+ option 'org-name', desc: 'Name of organization', required: true
230
227
  def organization
231
228
  process_global_options options
232
229
  require_trello_credentials
233
230
 
234
- organization = TrelloWrapper.new(@@settings).organization(options["org-name"])
231
+ organization = TrelloWrapper.new(@@settings).organization(options['org-name'])
235
232
 
236
233
  puts "Display Name: #{organization.display_name}"
237
234
  puts "Home page: #{organization.url}"
238
235
  end
239
236
 
240
- desc "get-description", "Reads description"
241
- option "card-id", :desc => "Id of card", :required => true
237
+ desc 'get-description', 'Reads description'
238
+ option 'card-id', desc: 'Id of card', required: true
242
239
  def get_description
243
240
  process_global_options options
244
241
  require_trello_credentials
245
242
 
246
243
  trello = TrelloWrapper.new(@@settings)
247
244
 
248
- puts trello.get_description(options["card-id"])
245
+ puts trello.get_description(options['card-id'])
249
246
  end
250
247
 
251
- desc "set-description", "Writes description read from standard input"
252
- option "card-id", :desc => "Id of card", :required => true
248
+ desc 'set-description', 'Writes description read from standard input'
249
+ option 'card-id', desc: 'Id of card', required: true
253
250
  def set_description
254
251
  process_global_options options
255
252
  require_trello_credentials
256
253
 
257
- TrelloWrapper.new(@@settings).set_description(options["card-id"], STDIN.read)
254
+ TrelloWrapper.new(@@settings).set_description(options['card-id'], STDIN.read)
258
255
  end
259
256
 
260
- desc "organization-members", "Show organization members"
261
- option "org-name", :desc => "Name of organization", :required => true
257
+ desc 'organization-members', 'Show organization members'
258
+ option 'org-name', desc: 'Name of organization', required: true
262
259
  def organization_members
263
260
  process_global_options options
264
261
  require_trello_credentials
265
262
 
266
263
  trello = TrelloWrapper.new(@@settings)
267
264
 
268
- members = trello.organization(options["org-name"]).members.sort_by(&:username)
265
+ members = trello.organization(options['org-name']).members.sort_by(&:username)
269
266
 
270
267
  members.each do |member|
271
268
  puts "#{member.username} (#{member.full_name})"
272
269
  end
273
270
  end
274
271
 
275
- desc "set-cover <filename>", "Set cover picture"
276
- option "card-id", :desc => "Id of card", :required => true
272
+ desc 'set-cover <filename>', 'Set cover picture'
273
+ option 'card-id', desc: 'Id of card', required: true
277
274
  def set_cover(filename)
278
275
  process_global_options(options)
279
276
  require_trello_credentials
280
277
 
281
- TrelloWrapper.new(@@settings).add_attachment(options["card-id"], filename)
278
+ TrelloWrapper.new(@@settings).add_attachment(options['card-id'], filename)
282
279
  end
283
280
 
284
- desc "make-cover <filename>", "Make existing picture the cover"
285
- option "card-id", :desc => "Id of card", :required => true
281
+ desc 'make-cover <filename>', 'Make existing picture the cover'
282
+ option 'card-id', desc: 'Id of card', required: true
286
283
  def make_cover(filename)
287
284
  process_global_options(options)
288
285
  require_trello_credentials
289
286
 
290
- TrelloWrapper.new(@@settings).make_cover(options["card-id"], filename)
287
+ TrelloWrapper.new(@@settings).make_cover(options['card-id'], filename)
291
288
  end
292
289
 
293
- desc "list-member-boards", "List name and id of all boards"
294
- option "member-id", :desc => "Id of the member", :required => true
290
+ desc 'list-member-boards', 'List name and id of all boards'
291
+ option 'member-id', desc: 'Id of the member', required: true
295
292
  def list_member_boards
296
293
  process_global_options options
297
294
  require_trello_credentials
298
295
 
299
296
  trello = TrelloWrapper.new(@@settings)
300
- trello.get_member_boards(options["member-id"]).sort_by { |board|
301
- board["name"]
302
- }.each { |board|
303
- puts "#{board["name"]} - #{board["id"]}"
304
- }
297
+ trello.get_member_boards(options['member-id']).sort_by do |board|
298
+ board['name']
299
+ end.each do |board|
300
+ puts "#{board['name']} - #{board['id']}"
301
+ end
305
302
  end
306
303
 
307
- desc "setup-scrum", "Create necessary elements of our SCRUM setup"
304
+ desc 'setup-scrum', 'Create necessary elements of our SCRUM setup'
308
305
  long_desc <<-EOT
309
306
  Will create board, lists and labels with names as configured in trollolorc,
310
307
  or use the defaults.
@@ -317,58 +314,58 @@ EOT
317
314
  c.create
318
315
  end
319
316
 
320
- desc "set-priorities", "Set priority text into card titles"
317
+ desc 'set-priorities', 'Set priority text into card titles'
321
318
  long_desc <<EOT
322
319
  Add 'P<n>: ' to the beginning of every cards title in the 'Backlog' list,
323
320
  replace where already present. n is the current position of the list on
324
321
  the card.
325
322
  EOT
326
- option "board-id", :desc => "Id of the board", :required => true
327
- option "backlog-list-name", :desc => "Name of backlog list", :required => false
323
+ option 'board-id', desc: 'Id of the board', required: true
324
+ option 'backlog-list-name', desc: 'Name of backlog list', required: false
328
325
  def set_priorities
329
326
  process_global_options options
330
327
  require_trello_credentials
331
328
 
332
329
  p = Scrum::Prioritizer.new(@@settings)
333
- p.prioritize(board_id(options["board-id"]), options["backlog-list-name"])
330
+ p.prioritize(board_id(options['board-id']), options['backlog-list-name'])
334
331
  end
335
332
 
336
- desc "cleanup-sprint", "Move remaining cards to the planning board"
333
+ desc 'cleanup-sprint', 'Move remaining cards to the planning board'
337
334
  long_desc <<EOT
338
335
  After the sprint, move remaining cards from 'Sprint Backlog', 'Doing'
339
336
  and 'QA' lists back to the planning board into the 'Ready' list.
340
337
  EOT
341
- option "board-id", :desc => "Id of the board", :required => true
342
- option "target-board-id", :desc => "Id of the target board", :required => true
338
+ option 'board-id', desc: 'Id of the board', required: true
339
+ option 'target-board-id', desc: 'Id of the target board', required: true
343
340
  def cleanup_sprint
344
341
  process_global_options options
345
342
  require_trello_credentials
346
343
 
347
344
  s = Scrum::SprintCleaner.new(@@settings)
348
- s.cleanup(board_id(options["board-id"]),
349
- board_id(options["target-board-id"]))
345
+ s.cleanup(board_id(options['board-id']),
346
+ board_id(options['target-board-id']))
350
347
  end
351
348
 
352
- desc "move-backlog", "Move the planning backlog to the sprint board"
349
+ desc 'move-backlog', 'Move the planning backlog to the sprint board'
353
350
  long_desc <<-EOT
354
351
  Two separate boards are used, a planning board and a sprint board for the
355
352
  current sprint.
356
353
  After each planning meeting the cards are moved from the planning boards
357
354
  'Backlog' list to the sprint boards 'Sprint Backlog' list.
358
355
  EOT
359
- option "planning-board-id", desc: "Id of the planning board", required: true
360
- option "sprint-board-id", desc: "Id of the sprint board", required: true
356
+ option 'planning-board-id', desc: 'Id of the planning board', required: true
357
+ option 'sprint-board-id', desc: 'Id of the sprint board', required: true
361
358
  def move_backlog
362
359
  process_global_options options
363
360
  require_trello_credentials
364
361
 
365
362
  m = Scrum::BacklogMover.new(@@settings)
366
- m.move(board_id(options["planning-board-id"]), board_id(options["sprint-board-id"]))
363
+ m.move(board_id(options['planning-board-id']), board_id(options['sprint-board-id']))
367
364
  end
368
365
 
369
366
  private
370
367
 
371
- def process_global_options options
368
+ def process_global_options(options)
372
369
  @@settings.verbose = options[:verbose]
373
370
  @@settings.raw = options[:raw]
374
371
  end
@@ -376,24 +373,22 @@ EOT
376
373
  def require_trello_credentials
377
374
  write_back = false
378
375
 
379
- if !@@settings.developer_public_key
380
- puts "Put in Trello developer public key:"
376
+ unless @@settings.developer_public_key
377
+ puts 'Put in Trello developer public key:'
381
378
  @@settings.developer_public_key = STDIN.gets.chomp
382
379
  write_back = true
383
380
  end
384
381
 
385
- if !@@settings.member_token
386
- puts "Put in Trello member token:"
382
+ unless @@settings.member_token
383
+ puts 'Put in Trello member token:'
387
384
  @@settings.member_token = STDIN.gets.chomp
388
385
  write_back = true
389
386
  end
390
387
 
391
- if write_back
392
- @@settings.save_config
393
- end
388
+ @@settings.save_config if write_back
394
389
 
395
390
  if !@@settings.developer_public_key || !@@settings.member_token
396
- STDERR.puts "Require trello credentials in config file"
391
+ STDERR.puts 'Require trello credentials in config file'
397
392
  exit 1
398
393
  end
399
394
  end