trello_flow 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3618ad36b3d55822f45748524afd2cd3e7586ee6
4
- data.tar.gz: dc9b1e38ba649fe530c0a216cbda31e04c23a88a
3
+ metadata.gz: bb65b09bb2642a2a35b11c83521afd71d52a5755
4
+ data.tar.gz: afc1e9fc26bb8b1fa171fcf16f48394fe952e5e5
5
5
  SHA512:
6
- metadata.gz: 52a3872c775e9253203ead4c1f01ff704d30cc525526a20c9530a8b7fb2c44c9e0ff5df40973a931aacf1ee1b9c3d6b9f04a17503ddc633124c24e33e8eefc48
7
- data.tar.gz: ee35f9e9a3a50296e965cd259ef01daefaf7c854fd5303644574ea5253c7f827dff14997c1d53863885e97ece84de0243f7b759a66ea98b5211cfe29e1150c51
6
+ metadata.gz: 35c000110daaceb8c86cdcff809b7a8ca803a39aa17e113a136d5381269bd4ef7f3e8a85a7ecfc72f26742eb31113af115f1ad7691f2f3329329e3aa42964b13
7
+ data.tar.gz: e21de46cfc3d833186d03fd0c9c1a4cef7eba5336bf6f14e36373aa0f5058375531a07af9a3cccbd7b677c2c2553b144c1646ff568cc6f6674b2f9b1c18cb458
@@ -6,6 +6,7 @@ module TrelloFlow
6
6
  class Base < Spyke::Base
7
7
  require "trello_flow/api/board"
8
8
  require "trello_flow/api/card"
9
+ require "trello_flow/api/label"
9
10
  require "trello_flow/api/list"
10
11
  require "trello_flow/api/member"
11
12
 
@@ -2,6 +2,7 @@ module TrelloFlow
2
2
  module Api
3
3
  class Board < Base
4
4
  has_many :lists
5
+ has_many :labels
5
6
  scope :active, -> { where(filter: "open") }
6
7
 
7
8
  def self.fields
@@ -25,6 +25,10 @@ module TrelloFlow
25
25
  self.class.with("cards/:id/members").where(id: id, value: user.id).post
26
26
  end
27
27
 
28
+ def add_label(label)
29
+ self.class.with("cards/:id/idLabels").where(id: id, value: label.id).post
30
+ end
31
+
28
32
  def url
29
33
  attributes[:shortUrl]
30
34
  end
@@ -0,0 +1,15 @@
1
+ module TrelloFlow
2
+ module Api
3
+ class Label < Base
4
+ has_many :cards
5
+
6
+ def self.fields
7
+ [:name]
8
+ end
9
+
10
+ def position
11
+ name.downcase
12
+ end
13
+ end
14
+ end
15
+ end
@@ -49,7 +49,10 @@ module TrelloFlow
49
49
  end
50
50
 
51
51
  def create_new_card(name)
52
- board.lists.backlog.cards.create name: name
52
+ card = board.lists.backlog.cards.create name: name
53
+ label = Table.pick board.labels, caption: "Add label:"
54
+ card.add_label(label)
55
+ card
53
56
  end
54
57
 
55
58
  def pick_existing_card
@@ -2,19 +2,18 @@ require "trello_flow/table/row"
2
2
 
3
3
  module TrelloFlow
4
4
  class Table
5
- def self.pick(records, title: nil)
6
- new(records).pick(title)
5
+ def self.pick(records, caption: "Pick one:")
6
+ new(records).pick(caption)
7
7
  end
8
8
 
9
9
  def initialize(records)
10
10
  @records = records.to_a.sort_by(&:position)
11
11
  end
12
12
 
13
- def pick(title = nil)
13
+ def pick(caption)
14
14
  return if records.none?
15
- Cli.title title if title
16
15
  render_table
17
- index = Cli.ask("Pick one:", Integer)
16
+ index = Cli.ask(caption, Integer)
18
17
  records[index - 1]
19
18
  end
20
19
 
@@ -3,33 +3,42 @@ module TrelloFlow
3
3
  class Row
4
4
  attr_reader :num
5
5
 
6
+ COLOR_TRANSLATIONS = {
7
+ "purple" => "magenta",
8
+ "orange" => "yellow",
9
+ "sky" => "cyan",
10
+ "pink" => "red",
11
+ "lime" => "green"
12
+ }
13
+
6
14
  def initialize(record, index)
7
15
  @record = record
8
16
  @num = index + 1
9
17
  end
10
18
 
11
19
  def to_h
12
- result = { "#": @num }
20
+ result = { "#": num }
13
21
  fields.each do |field|
14
- result[field] = colorize(@record.send(field))
22
+ result[field] = colorize record.send(field)
15
23
  end
16
24
  result
17
25
  end
18
26
 
19
27
  private
20
28
 
29
+ attr_reader :num, :record
30
+
21
31
  def colorize(str)
22
- return str unless str.respond_to?(color)
23
- str.send(color)
32
+ return str unless record.respond_to?(:color)
33
+ "■".send(color) + " #{str}"
24
34
  end
25
35
 
26
36
  def color
27
- custom_color = @record.color if @record.respond_to?(:color)
28
- custom_color || :white
37
+ COLOR_TRANSLATIONS[record.color] || record.color || :white
29
38
  end
30
39
 
31
40
  def fields
32
- @fields ||= @record.class.fields
41
+ @_fields ||= record.class.fields
33
42
  end
34
43
  end
35
44
  end
@@ -1,3 +1,3 @@
1
1
  module TrelloFlow
2
- VERSION = "2.1.0"
2
+ VERSION = "2.2.0"
3
3
  end
data/trello_flow.gemspec CHANGED
@@ -23,9 +23,11 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
  spec.add_development_dependency "minitest", "~> 5.0"
25
25
  spec.add_development_dependency 'minitest-line'
26
+ spec.add_development_dependency 'minitest-reporters'
26
27
  spec.add_development_dependency 'multi_json'
27
28
  spec.add_development_dependency "pry"
28
29
  spec.add_development_dependency 'webmock'
30
+
29
31
  spec.add_dependency "colored"
30
32
  spec.add_dependency "highline"
31
33
  spec.add_dependency "hirb"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trello_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Balvig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-05 00:00:00.000000000 Z
11
+ date: 2017-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest-reporters
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: multi_json
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -233,6 +247,7 @@ files:
233
247
  - lib/trello_flow/api/board.rb
234
248
  - lib/trello_flow/api/card.rb
235
249
  - lib/trello_flow/api/json_parser.rb
250
+ - lib/trello_flow/api/label.rb
236
251
  - lib/trello_flow/api/list.rb
237
252
  - lib/trello_flow/api/member.rb
238
253
  - lib/trello_flow/branch.rb