trello_flow 1.3.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/lib/trello_flow/api/base.rb +0 -2
- data/lib/trello_flow/api/card.rb +15 -7
- data/lib/trello_flow/api/list.rb +16 -0
- data/lib/trello_flow/branch.rb +11 -19
- data/lib/trello_flow/main.rb +13 -18
- data/lib/trello_flow/pull_request.rb +5 -5
- data/lib/trello_flow/table.rb +6 -5
- data/lib/trello_flow/version.rb +1 -1
- data/lib/trello_flow.rb +1 -0
- metadata +2 -4
- data/lib/trello_flow/api/checklist.rb +0 -39
- data/lib/trello_flow/api/item.rb +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25cffdf1ba58b120f8ac843494b1e10c928cf9c0
|
4
|
+
data.tar.gz: c5b25cf7d13abff425216edecddbb020c7f55248
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed517dc500c33843ab1f7ea9802558f421c9dfb68653b3d79952d5cb702f5212901188aba15f23031e6737107ff9b49fb1b55219272310a7f83a5ec8d7d8fdc5
|
7
|
+
data.tar.gz: 1cf7c109ec40c83768ba1ffe90353484ba4759e509c8f9b6ee3a1dc2d3275e882b076f16569c2f08319be04f3da1922929ad94b06efe859af27d9a6cf34ffbdb
|
data/README.md
CHANGED
@@ -10,11 +10,11 @@ gem install trello_flow
|
|
10
10
|
## Usage
|
11
11
|
|
12
12
|
```bash
|
13
|
-
git open # Open relevant card/all
|
14
|
-
git start #
|
15
|
-
git start <card URL> #
|
16
|
-
git start "Do this" #
|
17
|
-
git finish #
|
13
|
+
git open # Open relevant card/all user's cards in browser
|
14
|
+
git start # Pick a board to see backlog
|
15
|
+
git start <card URL> # Assigns self to card, moves to "started", and creates branch
|
16
|
+
git start "Do this" # Picking a board creates card "Do this" and starts it
|
17
|
+
git finish # Moves card to "in review" and opens PR
|
18
18
|
git cleanup # cleans up merged card branches
|
19
19
|
```
|
20
20
|
|
data/lib/trello_flow/api/base.rb
CHANGED
@@ -6,10 +6,8 @@ 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/checklist"
|
10
9
|
require "trello_flow/api/list"
|
11
10
|
require "trello_flow/api/member"
|
12
|
-
require "trello_flow/api/item"
|
13
11
|
|
14
12
|
include_root_in_json false
|
15
13
|
cattr_accessor :token
|
data/lib/trello_flow/api/card.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module TrelloFlow
|
2
2
|
module Api
|
3
3
|
class Card < Base
|
4
|
-
|
4
|
+
belongs_to :board, foreign_key: "idBoard"
|
5
5
|
|
6
6
|
def self.fields
|
7
7
|
[:name]
|
@@ -12,8 +12,12 @@ module TrelloFlow
|
|
12
12
|
find(id)
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
16
|
-
|
15
|
+
def start
|
16
|
+
move_to board.lists.started
|
17
|
+
end
|
18
|
+
|
19
|
+
def finish
|
20
|
+
move_to board.lists.finished
|
17
21
|
end
|
18
22
|
|
19
23
|
def add_member(user)
|
@@ -21,16 +25,20 @@ module TrelloFlow
|
|
21
25
|
self.class.with("cards/:id/members").where(id: id, value: user.id).post
|
22
26
|
end
|
23
27
|
|
24
|
-
def find_or_create_checklist
|
25
|
-
Table.pick(checklists) || Checklist.create(idCard: id, name: "To-Do")
|
26
|
-
end
|
27
|
-
|
28
28
|
def url
|
29
29
|
attributes[:shortUrl]
|
30
30
|
end
|
31
31
|
|
32
|
+
def to_param
|
33
|
+
name.parameterize[0..50]
|
34
|
+
end
|
35
|
+
|
32
36
|
private
|
33
37
|
|
38
|
+
def move_to(list)
|
39
|
+
self.class.with("cards/:id/idList").where(id: id, value: list.id).put
|
40
|
+
end
|
41
|
+
|
34
42
|
def member_ids
|
35
43
|
attributes["idMembers"] || []
|
36
44
|
end
|
data/lib/trello_flow/api/list.rb
CHANGED
@@ -1,11 +1,27 @@
|
|
1
1
|
module TrelloFlow
|
2
2
|
module Api
|
3
3
|
class List < Base
|
4
|
+
BACKLOG_INDEX = 0
|
5
|
+
STARTED_INDEX = 1
|
6
|
+
FINISHED_INDEX = 2
|
7
|
+
|
4
8
|
has_many :cards
|
5
9
|
|
6
10
|
def self.fields
|
7
11
|
[:name]
|
8
12
|
end
|
13
|
+
|
14
|
+
def self.backlog
|
15
|
+
all[BACKLOG_INDEX]
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.started
|
19
|
+
all[STARTED_INDEX]
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.finished
|
23
|
+
all[FINISHED_INDEX]
|
24
|
+
end
|
9
25
|
end
|
10
26
|
end
|
11
27
|
end
|
data/lib/trello_flow/branch.rb
CHANGED
@@ -11,8 +11,8 @@ module TrelloFlow
|
|
11
11
|
new Cli.read("git rev-parse --abbrev-ref HEAD")
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.
|
15
|
-
new("#{current.target}.#{
|
14
|
+
def self.from_card(card)
|
15
|
+
new("#{current.target}.#{card.to_param}.#{card.id}")
|
16
16
|
end
|
17
17
|
|
18
18
|
def checkout
|
@@ -24,16 +24,16 @@ module TrelloFlow
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def open_pull_request
|
27
|
-
PullRequest.new(
|
27
|
+
PullRequest.new(current_card, from: name, target: target).open
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
31
|
-
|
30
|
+
def finish_current_card
|
31
|
+
current_card.finish
|
32
32
|
end
|
33
33
|
|
34
34
|
def open_trello(user)
|
35
|
-
if
|
36
|
-
Cli.open_url
|
35
|
+
if current_card
|
36
|
+
Cli.open_url current_card.url
|
37
37
|
else
|
38
38
|
Cli.open_url "https://trello.com/#{user.username}/cards"
|
39
39
|
end
|
@@ -47,20 +47,12 @@ module TrelloFlow
|
|
47
47
|
|
48
48
|
attr_reader :name
|
49
49
|
|
50
|
-
def
|
51
|
-
|
50
|
+
def current_card
|
51
|
+
@_current_card ||= Api::Card.find(card_id) if card_id
|
52
52
|
end
|
53
53
|
|
54
|
-
def
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
def item_id
|
59
|
-
ids.last if ids.size == 2
|
60
|
-
end
|
61
|
-
|
62
|
-
def current_item
|
63
|
-
@_current_item ||= Api::Item.find(checklist_id, item_id) if item_id
|
54
|
+
def card_id
|
55
|
+
name.split(".").last
|
64
56
|
end
|
65
57
|
end
|
66
58
|
end
|
data/lib/trello_flow/main.rb
CHANGED
@@ -5,17 +5,10 @@ module TrelloFlow
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def start(name)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
card = find_or_create_card(name)
|
13
|
-
end
|
14
|
-
|
15
|
-
checklist = card.find_or_create_checklist
|
16
|
-
item = checklist.select_or_create_item(name)
|
17
|
-
item.assign(current_user)
|
18
|
-
Branch.from_item(item).checkout
|
8
|
+
card = create_or_pick_card(name)
|
9
|
+
card.add_member(current_user)
|
10
|
+
card.start
|
11
|
+
Branch.from_card(card).checkout
|
19
12
|
end
|
20
13
|
|
21
14
|
def open
|
@@ -26,7 +19,7 @@ module TrelloFlow
|
|
26
19
|
branch = Branch.current
|
27
20
|
branch.push
|
28
21
|
branch.open_pull_request
|
29
|
-
branch.
|
22
|
+
branch.finish_current_card
|
30
23
|
end
|
31
24
|
|
32
25
|
def cleanup
|
@@ -35,8 +28,10 @@ module TrelloFlow
|
|
35
28
|
|
36
29
|
private
|
37
30
|
|
38
|
-
def
|
39
|
-
if
|
31
|
+
def create_or_pick_card(name)
|
32
|
+
if name.to_s.start_with?("http")
|
33
|
+
Api::Card.find_by_url(name)
|
34
|
+
elsif name.present?
|
40
35
|
create_new_card(name)
|
41
36
|
else
|
42
37
|
pick_existing_card
|
@@ -44,13 +39,13 @@ module TrelloFlow
|
|
44
39
|
end
|
45
40
|
|
46
41
|
def create_new_card(name)
|
47
|
-
board = Table.pick(
|
48
|
-
|
49
|
-
list.cards.create name: Cli.ask("Input card title [#{name}]:").presence || name
|
42
|
+
board = Table.pick(current_user.boards.active)
|
43
|
+
board.lists.backlog.cards.create name: name
|
50
44
|
end
|
51
45
|
|
52
46
|
def pick_existing_card
|
53
|
-
Table.pick
|
47
|
+
board = Table.pick(current_user.boards.active)
|
48
|
+
Table.pick board.lists.backlog.cards
|
54
49
|
end
|
55
50
|
|
56
51
|
def current_user
|
@@ -2,8 +2,8 @@ require "trello_flow/repo"
|
|
2
2
|
|
3
3
|
module TrelloFlow
|
4
4
|
class PullRequest
|
5
|
-
def initialize(
|
6
|
-
@
|
5
|
+
def initialize(card, from:, target:)
|
6
|
+
@card = card
|
7
7
|
@from = from
|
8
8
|
@target = target
|
9
9
|
end
|
@@ -14,18 +14,18 @@ module TrelloFlow
|
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
|
-
attr_reader :
|
17
|
+
attr_reader :card, :from, :target
|
18
18
|
|
19
19
|
def url
|
20
20
|
repo.url + "/compare/#{target}...#{from}?expand=1&title=#{escape title_with_prefixes}&body=#{escape body}"
|
21
21
|
end
|
22
22
|
|
23
23
|
def title
|
24
|
-
|
24
|
+
card.name.gsub('"',"'")
|
25
25
|
end
|
26
26
|
|
27
27
|
def body
|
28
|
-
"Trello: #{
|
28
|
+
"Trello: #{card.url}"
|
29
29
|
end
|
30
30
|
|
31
31
|
def prefixes
|
data/lib/trello_flow/table.rb
CHANGED
@@ -11,18 +11,19 @@ module TrelloFlow
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def pick(title = nil)
|
14
|
-
return if
|
15
|
-
return @records.first if @records.one?
|
14
|
+
return if records.none?
|
16
15
|
Cli.title title if title
|
17
16
|
render_table
|
18
17
|
index = Cli.ask("Pick one:", Integer)
|
19
|
-
|
18
|
+
records[index - 1]
|
20
19
|
end
|
21
20
|
|
22
21
|
private
|
23
22
|
|
23
|
+
attr_reader :records
|
24
|
+
|
24
25
|
def render_table
|
25
|
-
if
|
26
|
+
if records.size > 0
|
26
27
|
Cli.table rows
|
27
28
|
else
|
28
29
|
Cli.say "No records found"
|
@@ -30,7 +31,7 @@ module TrelloFlow
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def rows
|
33
|
-
|
34
|
+
records.each_with_index.map do |record, index|
|
34
35
|
Row.new(record, index).to_h
|
35
36
|
end
|
36
37
|
end
|
data/lib/trello_flow/version.rb
CHANGED
data/lib/trello_flow.rb
CHANGED
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:
|
4
|
+
version: 2.0.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-
|
11
|
+
date: 2016-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -232,8 +232,6 @@ files:
|
|
232
232
|
- lib/trello_flow/api/base.rb
|
233
233
|
- lib/trello_flow/api/board.rb
|
234
234
|
- lib/trello_flow/api/card.rb
|
235
|
-
- lib/trello_flow/api/checklist.rb
|
236
|
-
- lib/trello_flow/api/item.rb
|
237
235
|
- lib/trello_flow/api/json_parser.rb
|
238
236
|
- lib/trello_flow/api/list.rb
|
239
237
|
- lib/trello_flow/api/member.rb
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require "trello_flow/table"
|
2
|
-
|
3
|
-
module TrelloFlow
|
4
|
-
module Api
|
5
|
-
class Checklist < Base
|
6
|
-
belongs_to :card
|
7
|
-
#has_many :items, uri: "checklists/:checklist_id/checkItems"
|
8
|
-
|
9
|
-
def self.fields
|
10
|
-
[:name]
|
11
|
-
end
|
12
|
-
|
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)
|
16
|
-
else
|
17
|
-
Table.pick(items, title: "#{card.name} (#{name})")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def items
|
22
|
-
attributes[:checkItems].map do |attr|
|
23
|
-
Item.new attr.merge(checklist_id: id)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def card_id
|
28
|
-
attributes[:idCard]
|
29
|
-
end
|
30
|
-
|
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
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/lib/trello_flow/api/item.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
module TrelloFlow
|
2
|
-
module Api
|
3
|
-
class Item < Base
|
4
|
-
delegate :card, :card_id, to: :checklist
|
5
|
-
|
6
|
-
def self.fields
|
7
|
-
[:description, :owners]
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.find(checklist_id, item_id)
|
11
|
-
with("checklists/#{checklist_id}/checkItems/#{item_id}").find_one
|
12
|
-
end
|
13
|
-
|
14
|
-
def description
|
15
|
-
if complete?
|
16
|
-
checkmark + name_without_mentions
|
17
|
-
else
|
18
|
-
name_without_mentions
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def owners
|
23
|
-
mentions.join(", ")
|
24
|
-
end
|
25
|
-
|
26
|
-
def color
|
27
|
-
:green if complete?
|
28
|
-
end
|
29
|
-
|
30
|
-
def assign(owner)
|
31
|
-
return if mentions.include?(owner.username)
|
32
|
-
self.class.request :put, "cards/#{card_id}/checklist/#{checklist_id}/checkItem/#{id}/name", value: name_without_mentions + " @#{owner.username}"
|
33
|
-
card.add_member(owner)
|
34
|
-
end
|
35
|
-
|
36
|
-
def complete
|
37
|
-
self.class.request :put, "cards/#{card_id}/checklist/#{checklist_id}/checkItem/#{id}/state", value: "complete"
|
38
|
-
end
|
39
|
-
|
40
|
-
def to_param
|
41
|
-
name_without_mentions.parameterize[0..50]
|
42
|
-
end
|
43
|
-
|
44
|
-
def name_without_mentions
|
45
|
-
(name.split - mentions).join(" ").strip
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def checklist
|
51
|
-
@_checklist ||= Checklist.find checklist_id
|
52
|
-
end
|
53
|
-
|
54
|
-
def checklist_id
|
55
|
-
attributes[:idChecklist]
|
56
|
-
end
|
57
|
-
|
58
|
-
def mentions
|
59
|
-
name.scan(/(@\S+)/).flatten
|
60
|
-
end
|
61
|
-
|
62
|
-
def checkmark
|
63
|
-
"\u2713 "
|
64
|
-
end
|
65
|
-
|
66
|
-
def complete?
|
67
|
-
state == "complete"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|