troo 0.0.4 → 0.0.5
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.
- checksums.yaml +4 -4
- data/lib/troo/actions/create_board.rb +1 -1
- data/lib/troo/actions/create_card.rb +1 -1
- data/lib/troo/actions/create_comment.rb +1 -1
- data/lib/troo/actions/create_list.rb +1 -1
- data/lib/troo/cli/add_cli.rb +10 -10
- data/lib/troo/cli/cli_helpers.rb +34 -0
- data/lib/troo/cli/default_cli.rb +8 -22
- data/lib/troo/cli/main_cli.rb +52 -50
- data/lib/troo/cli/show_cli.rb +32 -51
- data/lib/troo/display/board_decorator.rb +4 -0
- data/lib/troo/display/board_presenter.rb +44 -38
- data/lib/troo/display/card_decorator.rb +8 -13
- data/lib/troo/display/card_presenter.rb +4 -4
- data/lib/troo/display/comment_decorator.rb +2 -1
- data/lib/troo/display/comment_presenter.rb +8 -12
- data/lib/troo/display/decorator_helpers.rb +8 -0
- data/lib/troo/display/list_decorator.rb +4 -0
- data/lib/troo/display/list_presenter.rb +18 -20
- data/lib/troo/display/member_decorator.rb +3 -2
- data/lib/troo/display/member_presenter.rb +4 -4
- data/lib/troo/external/board.rb +2 -2
- data/lib/troo/external/card.rb +1 -1
- data/lib/troo/external/comment.rb +1 -1
- data/lib/troo/external/list.rb +1 -1
- data/lib/troo/external/member.rb +1 -1
- data/lib/troo/models/board.rb +12 -0
- data/lib/troo/models/card.rb +14 -2
- data/lib/troo/models/comment.rb +7 -3
- data/lib/troo/models/list.rb +13 -1
- data/lib/troo/models/member.rb +8 -0
- data/lib/troo/troo.rb +1 -1
- data/lib/troo/version.rb +1 -1
- data/test/lib/troo/actions/create_board_test.rb +1 -1
- data/test/lib/troo/actions/create_card_test.rb +1 -1
- data/test/lib/troo/actions/create_comment_test.rb +1 -1
- data/test/lib/troo/actions/create_list_test.rb +1 -1
- data/test/lib/troo/cli/add_cli_test.rb +18 -18
- data/test/lib/troo/cli/{thor_fixes_test.rb → cli_helpers_test.rb} +3 -0
- data/test/lib/troo/cli/default_cli_test.rb +6 -6
- data/test/lib/troo/cli/main_cli_test.rb +22 -20
- data/test/lib/troo/cli/show_cli_test.rb +57 -27
- data/test/lib/troo/display/board_decorator_test.rb +2 -2
- data/test/lib/troo/display/board_presenter_test.rb +2 -2
- data/test/lib/troo/display/card_decorator_test.rb +6 -14
- data/test/lib/troo/display/card_presenter_test.rb +2 -2
- data/test/lib/troo/display/comment_decorator_test.rb +6 -1
- data/test/lib/troo/display/comment_presenter_test.rb +2 -2
- data/test/lib/troo/display/decorator_helpers_test.rb +21 -1
- data/test/lib/troo/display/list_presenter_test.rb +2 -2
- data/test/lib/troo/display/member_decorator_test.rb +6 -1
- data/test/lib/troo/display/member_presenter_test.rb +2 -2
- metadata +6 -6
- data/lib/troo/cli/thor_fixes.rb +0 -9
@@ -1,8 +1,8 @@
|
|
1
1
|
module Troo
|
2
2
|
class CommentPresenter
|
3
3
|
class << self
|
4
|
-
def
|
5
|
-
new(card, options).
|
4
|
+
def show(card, options = {})
|
5
|
+
new(card, options).show
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
@@ -13,18 +13,14 @@ module Troo
|
|
13
13
|
@options = options
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def show
|
17
17
|
spacing do
|
18
|
-
print
|
18
|
+
print card.decorator.short
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
26
|
-
else
|
27
|
-
print_error "No comments were found."
|
20
|
+
print_error "No comments were found." unless card.comments.any?
|
21
|
+
|
22
|
+
card.comments.each do |comment|
|
23
|
+
indent { print comment.decorator.as_view }
|
28
24
|
end
|
29
25
|
end
|
30
26
|
end
|
@@ -7,8 +7,16 @@ module Troo
|
|
7
7
|
base.extend(ClassMethods)
|
8
8
|
end
|
9
9
|
|
10
|
+
def title
|
11
|
+
highlight([default, brackets(id), name].join(" "), options)
|
12
|
+
end
|
13
|
+
|
10
14
|
private
|
11
15
|
|
16
|
+
def title_for(resource)
|
17
|
+
indent { print resource.title + "\n" }
|
18
|
+
end
|
19
|
+
|
12
20
|
def word_wrap(text, line_width = 70)
|
13
21
|
return text if line_width <= 0
|
14
22
|
text.gsub(/\n/, ' ').gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip
|
@@ -1,36 +1,30 @@
|
|
1
1
|
module Troo
|
2
2
|
class ListPresenter
|
3
3
|
class << self
|
4
|
-
def
|
5
|
-
new(list, options).
|
4
|
+
def show(list, options = {})
|
5
|
+
new(list, options).show
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
9
|
include DecoratorHelpers
|
10
10
|
|
11
11
|
def initialize(list, options = {})
|
12
|
-
@list
|
12
|
+
@list = list
|
13
13
|
@options = options
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
indent do
|
26
|
-
print CardDecorator.new(card).short
|
27
|
-
end
|
28
|
-
end
|
29
|
-
else
|
30
|
-
print_error "No cards were found."
|
31
|
-
end
|
32
|
-
end
|
16
|
+
def show
|
17
|
+
puts board.decorator.title
|
18
|
+
|
19
|
+
title_for(list.decorator)
|
20
|
+
|
21
|
+
print_error "No cards were found." if cards.empty?
|
22
|
+
|
23
|
+
cards.each do |card|
|
24
|
+
title_for(card)
|
33
25
|
end
|
26
|
+
|
27
|
+
puts
|
34
28
|
end
|
35
29
|
|
36
30
|
private
|
@@ -39,5 +33,9 @@ module Troo
|
|
39
33
|
def board
|
40
34
|
list.board
|
41
35
|
end
|
36
|
+
|
37
|
+
def cards
|
38
|
+
list.decorator.cards
|
39
|
+
end
|
42
40
|
end
|
43
41
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Troo
|
2
2
|
class MemberPresenter
|
3
3
|
class << self
|
4
|
-
def
|
5
|
-
new(card, options).
|
4
|
+
def show(card, options = {})
|
5
|
+
new(card, options).show
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
@@ -13,7 +13,7 @@ module Troo
|
|
13
13
|
@options = options
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def show
|
17
17
|
decorated_members
|
18
18
|
end
|
19
19
|
|
@@ -33,7 +33,7 @@ module Troo
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def members
|
36
|
-
@members ||= card.members.map { |member|
|
36
|
+
@members ||= card.members.map { |member| member.decorator.username }
|
37
37
|
end
|
38
38
|
|
39
39
|
def one_member?
|
data/lib/troo/external/board.rb
CHANGED
@@ -4,13 +4,13 @@ module Troo
|
|
4
4
|
class << self
|
5
5
|
def fetch(external_id, options = {})
|
6
6
|
new(external_id, options).fetch_by_external_id.map do |resource|
|
7
|
-
|
7
|
+
BoardPersistence.for(resource) unless closed?(resource)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
def fetch_all
|
12
12
|
new.fetch_all.map do |resource|
|
13
|
-
|
13
|
+
BoardPersistence.for(resource) unless closed?(resource)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
data/lib/troo/external/card.rb
CHANGED
@@ -6,7 +6,7 @@ module Troo
|
|
6
6
|
new(external_id, options).fetch_by_external_id.map do |resource|
|
7
7
|
unless closed?(resource)
|
8
8
|
Troo::External::Comment.fetch(resource.id, { mode: :card }) if options.fetch(:comments, true)
|
9
|
-
|
9
|
+
CardPersistence.for(resource)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
data/lib/troo/external/list.rb
CHANGED
@@ -4,7 +4,7 @@ module Troo
|
|
4
4
|
class << self
|
5
5
|
def fetch(external_id, options = {})
|
6
6
|
new(external_id, options).fetch_by_external_id.map do |resource|
|
7
|
-
|
7
|
+
ListPersistence.for(resource) unless closed?(resource)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
data/lib/troo/external/member.rb
CHANGED
data/lib/troo/models/board.rb
CHANGED
@@ -21,6 +21,18 @@ module Troo
|
|
21
21
|
def cards
|
22
22
|
Troo::Card.find(external_board_id: self.external_board_id)
|
23
23
|
end
|
24
|
+
|
25
|
+
def decorator(options = {})
|
26
|
+
BoardDecorator.new(self, options)
|
27
|
+
end
|
28
|
+
|
29
|
+
def presenter
|
30
|
+
BoardPresenter.new(self)
|
31
|
+
end
|
32
|
+
|
33
|
+
def set_default!
|
34
|
+
SetDefault.for(self)
|
35
|
+
end
|
24
36
|
end
|
25
37
|
end
|
26
38
|
|
data/lib/troo/models/card.rb
CHANGED
@@ -25,11 +25,11 @@ module Troo
|
|
25
25
|
alias_method :default?, :default
|
26
26
|
|
27
27
|
def board
|
28
|
-
|
28
|
+
BoardRetrieval.retrieve(self.external_board_id)
|
29
29
|
end
|
30
30
|
|
31
31
|
def list
|
32
|
-
|
32
|
+
ListRetrieval.retrieve(self.external_list_id)
|
33
33
|
end
|
34
34
|
|
35
35
|
def comments
|
@@ -49,6 +49,18 @@ module Troo
|
|
49
49
|
[]
|
50
50
|
end
|
51
51
|
end
|
52
|
+
|
53
|
+
def decorator(options = {})
|
54
|
+
CardDecorator.new(self, options)
|
55
|
+
end
|
56
|
+
|
57
|
+
def presenter
|
58
|
+
CardPresenter.new(self)
|
59
|
+
end
|
60
|
+
|
61
|
+
def set_default!
|
62
|
+
SetDefault.for(self)
|
63
|
+
end
|
52
64
|
end
|
53
65
|
end
|
54
66
|
|
data/lib/troo/models/comment.rb
CHANGED
@@ -17,15 +17,19 @@ module Troo
|
|
17
17
|
index :external_member_id
|
18
18
|
|
19
19
|
def board
|
20
|
-
|
20
|
+
BoardRetrieval.retrieve(self.external_board_id)
|
21
21
|
end
|
22
22
|
|
23
23
|
def card
|
24
|
-
|
24
|
+
CardRetrieval.retrieve(self.external_card_id)
|
25
25
|
end
|
26
26
|
|
27
27
|
def member
|
28
|
-
|
28
|
+
MemberRetrieval.retrieve(self.external_member_id)
|
29
|
+
end
|
30
|
+
|
31
|
+
def decorator(options = {})
|
32
|
+
CommentDecorator.new(self, options)
|
29
33
|
end
|
30
34
|
end
|
31
35
|
end
|
data/lib/troo/models/list.rb
CHANGED
@@ -17,11 +17,23 @@ module Troo
|
|
17
17
|
alias_method :default?, :default
|
18
18
|
|
19
19
|
def board
|
20
|
-
|
20
|
+
BoardRetrieval.retrieve(self.external_board_id)
|
21
21
|
end
|
22
22
|
|
23
23
|
def cards
|
24
24
|
Troo::Card.find(external_list_id: self.external_list_id)
|
25
25
|
end
|
26
|
+
|
27
|
+
def decorator(options = {})
|
28
|
+
ListDecorator.new(self, options)
|
29
|
+
end
|
30
|
+
|
31
|
+
def presenter
|
32
|
+
ListPresenter.new(self)
|
33
|
+
end
|
34
|
+
|
35
|
+
def set_default!
|
36
|
+
SetDefault.for(self)
|
37
|
+
end
|
26
38
|
end
|
27
39
|
end
|
data/lib/troo/models/member.rb
CHANGED
data/lib/troo/troo.rb
CHANGED
@@ -65,7 +65,7 @@ require_relative "models/member_retrieval"
|
|
65
65
|
require_relative "models/member_persistence"
|
66
66
|
require_relative "models/refresh"
|
67
67
|
|
68
|
-
require_relative "cli/
|
68
|
+
require_relative "cli/cli_helpers"
|
69
69
|
require_relative "cli/add_cli"
|
70
70
|
require_relative "cli/default_cli"
|
71
71
|
require_relative "cli/show_cli"
|
data/lib/troo/version.rb
CHANGED
@@ -12,10 +12,10 @@ module Troo
|
|
12
12
|
@comment = Fabricate.build(:comment)
|
13
13
|
@list = Fabricate.build(:list, name: "My New Test List")
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
CreateBoard.stubs(:with).returns(@board)
|
16
|
+
CreateCard.stubs(:for).returns(@card)
|
17
|
+
CreateComment.stubs(:for).returns(@comment)
|
18
|
+
CreateList.stubs(:for).returns(@list)
|
19
19
|
end
|
20
20
|
|
21
21
|
after { database_cleanup }
|
@@ -42,7 +42,7 @@ module Troo
|
|
42
42
|
end
|
43
43
|
|
44
44
|
context "when the board was not created" do
|
45
|
-
before {
|
45
|
+
before { CreateBoard.stubs(:with).returns(false) }
|
46
46
|
|
47
47
|
it "returns a polite message" do
|
48
48
|
subject.must_match /Board could not be created/
|
@@ -50,7 +50,7 @@ module Troo
|
|
50
50
|
end
|
51
51
|
|
52
52
|
context "when the Trello access token credentials are invalid" do
|
53
|
-
before {
|
53
|
+
before { CreateBoard.stubs(:with).raises(Troo::InvalidAccessToken) }
|
54
54
|
|
55
55
|
it "returns a polite message" do
|
56
56
|
subject.must_match /access credentials have expired, please renew/
|
@@ -63,7 +63,7 @@ module Troo
|
|
63
63
|
let(:card_name) { "My New Test Card" }
|
64
64
|
let(:description) { "A very brief description..." }
|
65
65
|
|
66
|
-
before {
|
66
|
+
before { ListRetrieval.stubs(:retrieve).returns(@list) }
|
67
67
|
|
68
68
|
subject { capture_io { described_class.new.card(list_id, card_name, description) }.join }
|
69
69
|
|
@@ -85,7 +85,7 @@ module Troo
|
|
85
85
|
end
|
86
86
|
|
87
87
|
context "when the card was not created" do
|
88
|
-
before {
|
88
|
+
before { CreateCard.stubs(:for).returns(false) }
|
89
89
|
|
90
90
|
it "returns a polite message" do
|
91
91
|
subject.must_match /Card could not be created/
|
@@ -93,7 +93,7 @@ module Troo
|
|
93
93
|
end
|
94
94
|
|
95
95
|
context "when the Trello access token credentials are invalid" do
|
96
|
-
before {
|
96
|
+
before { CreateCard.stubs(:for).raises(Troo::InvalidAccessToken) }
|
97
97
|
|
98
98
|
it "returns a polite message" do
|
99
99
|
subject.must_match /access credentials have expired, please renew/
|
@@ -102,7 +102,7 @@ module Troo
|
|
102
102
|
end
|
103
103
|
|
104
104
|
context "when the list was not found" do
|
105
|
-
before {
|
105
|
+
before { ListRetrieval.stubs(:retrieve) }
|
106
106
|
|
107
107
|
it "returns a polite message" do
|
108
108
|
subject.must_match /list was not found/
|
@@ -114,7 +114,7 @@ module Troo
|
|
114
114
|
let(:card_id) { "526d8f19ddb279532e005259" }
|
115
115
|
let(:comment) { "A very brief description..." }
|
116
116
|
|
117
|
-
before {
|
117
|
+
before { CardRetrieval.stubs(:retrieve).returns(@card) }
|
118
118
|
|
119
119
|
subject { capture_io { described_class.new.comment(card_id, comment) }.join }
|
120
120
|
|
@@ -136,7 +136,7 @@ module Troo
|
|
136
136
|
end
|
137
137
|
|
138
138
|
context "when the comment was not created" do
|
139
|
-
before {
|
139
|
+
before { CreateComment.stubs(:for).returns(false) }
|
140
140
|
|
141
141
|
it "returns a polite message" do
|
142
142
|
subject.must_match /Comment could not be created/
|
@@ -144,7 +144,7 @@ module Troo
|
|
144
144
|
end
|
145
145
|
|
146
146
|
context "when the Trello access token credentials are invalid" do
|
147
|
-
before {
|
147
|
+
before { CreateComment.stubs(:for).raises(Troo::InvalidAccessToken) }
|
148
148
|
|
149
149
|
it "returns a polite message" do
|
150
150
|
subject.must_match /access credentials have expired, please renew/
|
@@ -153,7 +153,7 @@ module Troo
|
|
153
153
|
end
|
154
154
|
|
155
155
|
context "when the card was not found" do
|
156
|
-
before {
|
156
|
+
before { CardRetrieval.stubs(:retrieve) }
|
157
157
|
|
158
158
|
it "returns a polite message" do
|
159
159
|
subject.must_match /card was not found/
|
@@ -165,7 +165,7 @@ module Troo
|
|
165
165
|
let(:board_id) { "526d8e130a14a9d846001d96" }
|
166
166
|
let(:list_name) { "My New List" }
|
167
167
|
|
168
|
-
before {
|
168
|
+
before { BoardRetrieval.stubs(:retrieve).returns(@board) }
|
169
169
|
|
170
170
|
subject { capture_io { described_class.new.list(board_id, list_name) }.join }
|
171
171
|
|
@@ -187,7 +187,7 @@ module Troo
|
|
187
187
|
end
|
188
188
|
|
189
189
|
context "when the list was not created" do
|
190
|
-
before {
|
190
|
+
before { CreateList.stubs(:for).returns(false) }
|
191
191
|
|
192
192
|
it "returns a polite message" do
|
193
193
|
subject.must_match /List could not be created/
|
@@ -195,7 +195,7 @@ module Troo
|
|
195
195
|
end
|
196
196
|
|
197
197
|
context "when the Trello access token credentials are invalid" do
|
198
|
-
before {
|
198
|
+
before { CreateList.stubs(:for).raises(Troo::InvalidAccessToken) }
|
199
199
|
|
200
200
|
it "returns a polite message" do
|
201
201
|
subject.must_match /access credentials have expired, please renew/
|
@@ -204,7 +204,7 @@ module Troo
|
|
204
204
|
end
|
205
205
|
|
206
206
|
context "when the board was not found" do
|
207
|
-
before {
|
207
|
+
before { BoardRetrieval.stubs(:retrieve) }
|
208
208
|
|
209
209
|
it "returns a polite message" do
|
210
210
|
subject.must_match /board was not found/
|
@@ -12,7 +12,7 @@ module Troo
|
|
12
12
|
subject { capture_io { described_class.new.board(id) }.join }
|
13
13
|
|
14
14
|
context "when the id cannot be found" do
|
15
|
-
before {
|
15
|
+
before { BoardRetrieval.stubs(:retrieve) }
|
16
16
|
|
17
17
|
it "returns a polite message" do
|
18
18
|
subject.must_match /Board cannot be found/
|
@@ -22,7 +22,7 @@ module Troo
|
|
22
22
|
context "when the id was found" do
|
23
23
|
before do
|
24
24
|
@board = Fabricate.build(:board)
|
25
|
-
|
25
|
+
BoardRetrieval.stubs(:retrieve).returns(@board)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "returns a polite message" do
|
@@ -36,13 +36,13 @@ module Troo
|
|
36
36
|
|
37
37
|
before do
|
38
38
|
@card = Fabricate.build(:card)
|
39
|
-
|
39
|
+
CardRetrieval.stubs(:retrieve).returns(@card)
|
40
40
|
end
|
41
41
|
|
42
42
|
subject { capture_io { described_class.new.card(id) }.join }
|
43
43
|
|
44
44
|
context "when the id cannot be found" do
|
45
|
-
before {
|
45
|
+
before { CardRetrieval.stubs(:retrieve) }
|
46
46
|
|
47
47
|
it "returns a polite message" do
|
48
48
|
subject.must_match /Card cannot be found/
|
@@ -62,7 +62,7 @@ module Troo
|
|
62
62
|
subject { capture_io { described_class.new.list(id) }.join }
|
63
63
|
|
64
64
|
context "when the id cannot be found" do
|
65
|
-
before {
|
65
|
+
before { ListRetrieval.stubs(:retrieve) }
|
66
66
|
|
67
67
|
it "returns a polite message" do
|
68
68
|
subject.must_match /List cannot be found/
|
@@ -72,7 +72,7 @@ module Troo
|
|
72
72
|
context "when the id was found" do
|
73
73
|
before do
|
74
74
|
@list = Fabricate.build(:list)
|
75
|
-
|
75
|
+
ListRetrieval.stubs(:retrieve).returns(@list)
|
76
76
|
end
|
77
77
|
|
78
78
|
it "returns a polite message" do
|