trello_flow 1.0.1 → 1.1.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: 8f0ce6169233ed20673ae5080ce673ddd14d4398
4
- data.tar.gz: dc35673dc8731152e0d359d8a31adedf94e2a373
3
+ metadata.gz: b9b61ff2672d0fa326c6dc1cbe6bd3c7c9b4038a
4
+ data.tar.gz: 17387dd7a408af04b868f598a37982707b27d8ba
5
5
  SHA512:
6
- metadata.gz: 1f4c4761746ec6e8a6a5aa68490c03959657f3053cc3d2db356bbea602c0e332c12dff98ff44d2cc1070dc7ffd5170b6485bbcd20e90f9a9f32bb8fe55aeedb6
7
- data.tar.gz: cd43daa56ca0d8f689ae28c086da9b8fe6a361210a262d775cfc62bbf90c4e115cca08f9ae98dd931914cb7dc93953021063ccec5a858ea23093e59bd9f355b7
6
+ metadata.gz: e25a710855067d8b89321fb580e93b88190d81dec096ca6f719f683ce0c736e938159adefc96333e3bff6811844eace52b19681aec43073bc50d3b495dc28f2d
7
+ data.tar.gz: d1ddf470c49c36ff2905706478daf619c9d1a5928732ce25b07b40f5f5fa951b1c38cfa8a3d374fbc9c00b8028cdc8c136dab8d95b8d7179cab481ce0e690113
@@ -4,8 +4,10 @@ require "trello_flow/api/json_parser"
4
4
  module TrelloFlow
5
5
  module Api
6
6
  class Base < Spyke::Base
7
+ require "trello_flow/api/board"
7
8
  require "trello_flow/api/card"
8
9
  require "trello_flow/api/checklist"
10
+ require "trello_flow/api/list"
9
11
  require "trello_flow/api/member"
10
12
  require "trello_flow/api/item"
11
13
 
@@ -0,0 +1,12 @@
1
+ module TrelloFlow
2
+ module Api
3
+ class Board < Base
4
+ has_many :lists
5
+ scope :active, -> { where(filter: "open") }
6
+
7
+ def self.fields
8
+ [:name]
9
+ end
10
+ end
11
+ end
12
+ end
@@ -17,7 +17,7 @@ module TrelloFlow
17
17
  end
18
18
 
19
19
  def find_or_create_checklist
20
- Table.new(checklists).pick || Checklist.create(idCard: id, name: "To-Do")
20
+ Table.pick(checklists) || Checklist.create(idCard: id, name: "To-Do")
21
21
  end
22
22
 
23
23
  def url
@@ -10,12 +10,11 @@ module TrelloFlow
10
10
  [:name]
11
11
  end
12
12
 
13
- def select_or_create_item
14
- if items.none?
15
- item_name = Cli.ask("Input to-do [#{card.name}]:").presence || card.name
16
- add_item(item_name)
13
+ def select_or_create_item(item_name = nil)
14
+ if item_name.present? || items.none?
15
+ add_item (Cli.ask("Input to-do [#{card.name}]:").presence || card.name)
17
16
  else
18
- Table.new(items).pick("#{card.name} (#{name})")
17
+ Table.pick(items, title: "#{card.name} (#{name})")
19
18
  end
20
19
  end
21
20
 
@@ -29,10 +28,12 @@ module TrelloFlow
29
28
  attributes[:idCard]
30
29
  end
31
30
 
32
- def add_item(name)
33
- Item.with("checklists/:checklist_id/checkItems").where(checklist_id: id).create(name: name)
34
- # items.create(name: name)
35
- end
31
+ private
32
+
33
+ def add_item(name)
34
+ Item.with("checklists/:checklist_id/checkItems").where(checklist_id: id).create(name: name)
35
+ # items.create(name: name)
36
+ end
36
37
  end
37
38
  end
38
39
  end
@@ -0,0 +1,11 @@
1
+ module TrelloFlow
2
+ module Api
3
+ class List < Base
4
+ has_many :cards
5
+
6
+ def self.fields
7
+ [:name]
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,6 +1,8 @@
1
1
  module TrelloFlow
2
2
  module Api
3
3
  class Member < Base
4
+ has_many :boards
5
+
4
6
  def self.current
5
7
  with("tokens/#{token}/member").find_one
6
8
  end
@@ -4,14 +4,18 @@ module TrelloFlow
4
4
  @config = config
5
5
  end
6
6
 
7
- def start(input)
8
- if input.to_s.start_with?("http")
9
- start_with_url(input)
10
- elsif input.present?
11
- start_new_item(input)
7
+ def start(name)
8
+ if name.to_s.start_with?("http")
9
+ card = Api::Card.find_by_url(name)
10
+ name = nil
12
11
  else
13
- start_blank
12
+ card = find_or_create_card(name)
14
13
  end
14
+
15
+ checklist = card.find_or_create_checklist
16
+ item = checklist.select_or_create_item(name)
17
+ item.assign(username)
18
+ Branch.from_item(item).checkout
15
19
  end
16
20
 
17
21
  def open
@@ -31,28 +35,22 @@ module TrelloFlow
31
35
 
32
36
  private
33
37
 
34
- def start_with_url(url)
35
- card = Api::Card.find_by_url(url)
36
- checklist = card.find_or_create_checklist
37
- item = checklist.select_or_create_item
38
- item.assign(username)
39
- Branch.from_item(item).checkout
38
+ def find_or_create_card(name)
39
+ if Cli.ask("(n)ew or (e)xisting card?") == "n"
40
+ create_new_card(name)
41
+ else
42
+ pick_existing_card
43
+ end
40
44
  end
41
45
 
42
- def start_blank
43
- card = Table.new(Api::Card.for(username)).pick
44
- checklist = card.find_or_create_checklist
45
- item = checklist.select_or_create_item
46
- item.assign(username)
47
- Branch.from_item(item).checkout
46
+ def create_new_card(name)
47
+ board = Table.pick(Api::Member.current.boards.active)
48
+ list = Table.pick(board.lists)
49
+ list.cards.create name: Cli.ask("Input card title [#{name}]:").presence || name
48
50
  end
49
51
 
50
- def start_new_item(name)
51
- card = Table.new(Api::Card.for(username)).pick
52
- checklist = card.find_or_create_checklist
53
- item = checklist.add_item(name)
54
- item.assign(username)
55
- Branch.from_item(item).checkout
52
+ def pick_existing_card
53
+ Table.pick Api::Card.for(username)
56
54
  end
57
55
 
58
56
  def username
@@ -2,6 +2,10 @@ 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)
7
+ end
8
+
5
9
  def initialize(records)
6
10
  @records = records.to_a.sort_by(&:position)
7
11
  end
@@ -1,3 +1,3 @@
1
1
  module TrelloFlow
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
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: 1.0.1
4
+ version: 1.1.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: 2016-10-24 00:00:00.000000000 Z
11
+ date: 2016-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -230,10 +230,12 @@ files:
230
230
  - exe/git-start
231
231
  - lib/trello_flow.rb
232
232
  - lib/trello_flow/api/base.rb
233
+ - lib/trello_flow/api/board.rb
233
234
  - lib/trello_flow/api/card.rb
234
235
  - lib/trello_flow/api/checklist.rb
235
236
  - lib/trello_flow/api/item.rb
236
237
  - lib/trello_flow/api/json_parser.rb
238
+ - lib/trello_flow/api/list.rb
237
239
  - lib/trello_flow/api/member.rb
238
240
  - lib/trello_flow/branch.rb
239
241
  - lib/trello_flow/cleanup.rb