troo 0.0.10 → 0.0.11
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/.gitignore +2 -0
- data/Gemfile.lock +7 -7
- data/README.md +39 -40
- data/Rakefile +17 -11
- data/features/step_definitions/troo_steps.rb +1 -1
- data/lib/troo.rb +24 -35
- data/lib/troo/api/client.rb +3 -0
- data/lib/troo/api/endpoints.rb +7 -1
- data/lib/troo/api/headers.rb +7 -0
- data/lib/troo/api/request.rb +9 -0
- data/lib/troo/api/response.rb +3 -0
- data/lib/troo/cli/add.rb +11 -0
- data/lib/troo/cli/commands/add.rb +9 -0
- data/lib/troo/cli/commands/default.rb +7 -0
- data/lib/troo/cli/commands/move/card.rb +9 -0
- data/lib/troo/cli/commands/refresh.rb +7 -0
- data/lib/troo/cli/commands/refresh/all.rb +2 -0
- data/lib/troo/cli/commands/show.rb +7 -0
- data/lib/troo/cli/commands/show/show_boards.rb +2 -0
- data/lib/troo/cli/commands/show/show_comments.rb +5 -0
- data/lib/troo/cli/commands/status.rb +5 -0
- data/lib/troo/cli/default.rb +6 -0
- data/lib/troo/cli/main.rb +8 -0
- data/lib/troo/cli/refresh.rb +7 -0
- data/lib/troo/cli/show.rb +9 -0
- data/lib/troo/cli/thor_fixes.rb +4 -0
- data/lib/troo/configuration.rb +5 -30
- data/lib/troo/database.rb +7 -0
- data/lib/troo/debug.rb +3 -0
- data/lib/troo/decorators/member.rb +1 -0
- data/lib/troo/decorators/resource.rb +19 -0
- data/lib/troo/helpers/model_helpers.rb +13 -0
- data/lib/troo/helpers/remote_model_helpers.rb +9 -0
- data/lib/troo/launcher.rb +44 -0
- data/lib/troo/models/behaviours/set_default.rb +6 -0
- data/lib/troo/models/board.rb +9 -0
- data/lib/troo/models/card.rb +15 -0
- data/lib/troo/models/comment.rb +9 -0
- data/lib/troo/models/list.rb +9 -0
- data/lib/troo/models/member.rb +8 -0
- data/lib/troo/models/refresh.rb +2 -0
- data/lib/troo/options.rb +9 -0
- data/lib/troo/persistence/local.rb +8 -0
- data/lib/troo/preference.rb +29 -0
- data/lib/troo/presentation/formatter.rb +12 -0
- data/lib/troo/presentation/sentence.rb +7 -0
- data/lib/troo/presentation/template.rb +7 -0
- data/lib/troo/presenters/board.rb +8 -0
- data/lib/troo/presenters/card.rb +4 -0
- data/lib/troo/presenters/comment.rb +4 -0
- data/lib/troo/presenters/list.rb +5 -0
- data/lib/troo/presenters/member.rb +4 -0
- data/lib/troo/presenters/resource.rb +7 -0
- data/lib/troo/remote/board.rb +6 -0
- data/lib/troo/remote/card.rb +7 -0
- data/lib/troo/remote/comment.rb +10 -0
- data/lib/troo/remote/list.rb +6 -0
- data/lib/troo/remote/member.rb +6 -0
- data/lib/troo/remote/persistence/board.rb +7 -0
- data/lib/troo/remote/persistence/card.rb +9 -0
- data/lib/troo/remote/persistence/comment.rb +7 -0
- data/lib/troo/remote/persistence/list.rb +7 -0
- data/lib/troo/remote/persistence/move_card.rb +9 -0
- data/lib/troo/retrieval/local.rb +16 -0
- data/lib/troo/retrieval/remote.rb +9 -0
- data/lib/troo/troo.rb +4 -0
- data/lib/troo/version.rb +1 -1
- data/test/lib/troo/api/client_test.rb +4 -4
- data/test/lib/troo/api/response_test.rb +27 -0
- data/test/lib/troo/cli/commands/refresh/all_test.rb +2 -2
- data/test/lib/troo/cli/commands/refresh_test.rb +2 -2
- data/test/lib/troo/configuration_test.rb +1 -1
- data/test/lib/troo/database_test.rb +7 -0
- data/test/lib/troo/decorators/resource_test.rb +5 -3
- data/test/lib/troo/launcher_test.rb +7 -0
- data/test/lib/troo/models/card_test.rb +5 -5
- data/test/lib/troo/options_test.rb +7 -0
- data/test/lib/troo/preference_test.rb +21 -0
- data/test/lib/troo/presentation/formatter_test.rb +8 -8
- data/test/lib/troo/presenters/member_test.rb +33 -3
- data/test/lib/troo/presenters/resource_test.rb +2 -2
- data/test/lib/troo/remote/board_test.rb +2 -2
- data/test/lib/troo/remote/card_test.rb +2 -2
- data/test/lib/troo/remote/comment_test.rb +2 -2
- data/test/lib/troo/remote/list_test.rb +2 -2
- data/test/lib/troo/remote/member_test.rb +2 -2
- data/test/lib/troo/remote/persistence/card_test.rb +2 -2
- data/test/lib/troo/remote/persistence/comment_test.rb +2 -2
- data/test/lib/troo/remote/persistence/list_test.rb +2 -2
- data/test/lib/troo_test.rb +5 -0
- data/test/support/remotes/board.json +140 -0
- data/test/test_helper.rb +1 -1
- data/troo.gemspec +2 -1
- metadata +34 -4
@@ -3,16 +3,23 @@ module Troo
|
|
3
3
|
module Persistence
|
4
4
|
class Board
|
5
5
|
class << self
|
6
|
+
# @param [String]
|
7
|
+
# @param [String, NilClass]
|
8
|
+
# @return []
|
6
9
|
def with(name, description = nil)
|
7
10
|
new(name, description).perform
|
8
11
|
end
|
9
12
|
end
|
10
13
|
|
14
|
+
# @param [String]
|
15
|
+
# @param [String, NilClass]
|
16
|
+
# @return []
|
11
17
|
def initialize(name, description = nil)
|
12
18
|
@name = name
|
13
19
|
@description = description
|
14
20
|
end
|
15
21
|
|
22
|
+
# @return []
|
16
23
|
def perform
|
17
24
|
create_local
|
18
25
|
end
|
@@ -3,17 +3,26 @@ module Troo
|
|
3
3
|
module Persistence
|
4
4
|
class Card
|
5
5
|
class << self
|
6
|
+
# @param [String]
|
7
|
+
# @param [String, NilClass]
|
8
|
+
# @param [String, NilClass]
|
9
|
+
# @return []
|
6
10
|
def with(external_list_id, name = nil, description = nil)
|
7
11
|
new(external_list_id, name, description).perform
|
8
12
|
end
|
9
13
|
end
|
10
14
|
|
15
|
+
# @param [String]
|
16
|
+
# @param [String, NilClass]
|
17
|
+
# @param [String, NilClass]
|
18
|
+
# @return []
|
11
19
|
def initialize(external_list_id, name = nil, description = nil)
|
12
20
|
@external_list_id = external_list_id
|
13
21
|
@name = name
|
14
22
|
@description = description
|
15
23
|
end
|
16
24
|
|
25
|
+
# @return []
|
17
26
|
def perform
|
18
27
|
create_local
|
19
28
|
end
|
@@ -3,16 +3,23 @@ module Troo
|
|
3
3
|
module Persistence
|
4
4
|
class Comment
|
5
5
|
class << self
|
6
|
+
# @param [String]
|
7
|
+
# @param []
|
8
|
+
# @return []
|
6
9
|
def with(external_card_id, comment)
|
7
10
|
new(external_card_id, comment).perform
|
8
11
|
end
|
9
12
|
end
|
10
13
|
|
14
|
+
# @param [String]
|
15
|
+
# @param []
|
16
|
+
# @return []
|
11
17
|
def initialize(external_card_id, comment)
|
12
18
|
@external_card_id = external_card_id
|
13
19
|
@comment = comment
|
14
20
|
end
|
15
21
|
|
22
|
+
# @return []
|
16
23
|
def perform
|
17
24
|
create_local
|
18
25
|
end
|
@@ -3,16 +3,23 @@ module Troo
|
|
3
3
|
module Persistence
|
4
4
|
class List
|
5
5
|
class << self
|
6
|
+
# @param [String]
|
7
|
+
# @param [String]
|
8
|
+
# @return []
|
6
9
|
def with(external_board_id, name)
|
7
10
|
new(external_board_id, name).perform
|
8
11
|
end
|
9
12
|
end
|
10
13
|
|
14
|
+
# @param [String]
|
15
|
+
# @param [String]
|
16
|
+
# @return []
|
11
17
|
def initialize(external_board_id, name)
|
12
18
|
@external_board_id = external_board_id
|
13
19
|
@name = name
|
14
20
|
end
|
15
21
|
|
22
|
+
# @return []
|
16
23
|
def perform
|
17
24
|
create_local
|
18
25
|
end
|
@@ -3,6 +3,10 @@ module Troo
|
|
3
3
|
module Persistence
|
4
4
|
class MoveCard
|
5
5
|
class << self
|
6
|
+
# @param [String]
|
7
|
+
# @param [String]
|
8
|
+
# @param [String, NilClass]
|
9
|
+
# @return []
|
6
10
|
def with(external_card_id,
|
7
11
|
external_list_id,
|
8
12
|
external_board_id = nil)
|
@@ -11,6 +15,10 @@ module Troo
|
|
11
15
|
end
|
12
16
|
end
|
13
17
|
|
18
|
+
# @param [String]
|
19
|
+
# @param [String]
|
20
|
+
# @param [String, NilClass]
|
21
|
+
# @return []
|
14
22
|
def initialize(external_card_id,
|
15
23
|
external_list_id,
|
16
24
|
external_board_id = nil)
|
@@ -19,6 +27,7 @@ module Troo
|
|
19
27
|
@external_board_id = external_board_id
|
20
28
|
end
|
21
29
|
|
30
|
+
# @return []
|
22
31
|
def perform
|
23
32
|
update_cards
|
24
33
|
end
|
data/lib/troo/retrieval/local.rb
CHANGED
@@ -4,31 +4,47 @@ module Troo
|
|
4
4
|
attr_reader :id
|
5
5
|
|
6
6
|
class << self
|
7
|
+
# @param []
|
8
|
+
# @return []
|
7
9
|
def all(klass)
|
8
10
|
new(klass).all
|
9
11
|
end
|
10
12
|
|
13
|
+
# @param []
|
14
|
+
# @param [Hash]
|
15
|
+
# @return []
|
11
16
|
def default(klass, options = {})
|
12
17
|
new(klass, nil, options).default
|
13
18
|
end
|
14
19
|
|
20
|
+
# @param []
|
21
|
+
# @param []
|
22
|
+
# @param [Hash]
|
23
|
+
# @return []
|
15
24
|
def retrieve(klass, id = nil, options = {})
|
16
25
|
new(klass, id, options).retrieve
|
17
26
|
end
|
18
27
|
end
|
19
28
|
|
29
|
+
# @param []
|
30
|
+
# @param []
|
31
|
+
# @param [Hash]
|
32
|
+
# @return []
|
20
33
|
def initialize(klass, id = nil, options = {})
|
21
34
|
@klass, @id, @options = klass, id, options
|
22
35
|
end
|
23
36
|
|
37
|
+
# @return []
|
24
38
|
def all
|
25
39
|
klass.all
|
26
40
|
end
|
27
41
|
|
42
|
+
# @return []
|
28
43
|
def default
|
29
44
|
klass.default
|
30
45
|
end
|
31
46
|
|
47
|
+
# @return []
|
32
48
|
def retrieve
|
33
49
|
return default unless id
|
34
50
|
by_short_id || by_id || by_external_id || optional_remote
|
@@ -4,17 +4,26 @@ module Troo
|
|
4
4
|
attr_reader :external_id
|
5
5
|
|
6
6
|
class << self
|
7
|
+
# @param []
|
8
|
+
# @param []
|
9
|
+
# @param [Hash]
|
10
|
+
# @return []
|
7
11
|
def fetch(klass, external_id, options = {})
|
8
12
|
new(klass, external_id, options).fetch
|
9
13
|
end
|
10
14
|
end
|
11
15
|
|
16
|
+
# @param []
|
17
|
+
# @param []
|
18
|
+
# @param [Hash]
|
19
|
+
# @return []
|
12
20
|
def initialize(klass, external_id, options = {})
|
13
21
|
@klass = klass
|
14
22
|
@external_id = external_id
|
15
23
|
@options = options
|
16
24
|
end
|
17
25
|
|
26
|
+
# @return []
|
18
27
|
def fetch
|
19
28
|
return [] if none?
|
20
29
|
return persist if persist?
|
data/lib/troo/troo.rb
CHANGED
@@ -20,9 +20,11 @@ require 'virtus'
|
|
20
20
|
require 'yajl'
|
21
21
|
require 'yaml'
|
22
22
|
|
23
|
+
require_relative 'preference'
|
23
24
|
require_relative 'configuration'
|
24
25
|
require_relative 'database'
|
25
26
|
require_relative 'debug'
|
27
|
+
require_relative 'options'
|
26
28
|
|
27
29
|
require_relative 'api/endpoints'
|
28
30
|
require_relative 'api/oauth_settings'
|
@@ -86,3 +88,5 @@ require_relative 'cli/default'
|
|
86
88
|
require_relative 'cli/refresh'
|
87
89
|
require_relative 'cli/show'
|
88
90
|
require_relative 'cli/main'
|
91
|
+
|
92
|
+
require_relative 'launcher'
|
data/lib/troo/version.rb
CHANGED
@@ -4,7 +4,7 @@ module Troo
|
|
4
4
|
module API
|
5
5
|
describe Client do
|
6
6
|
let(:described_class) { Client }
|
7
|
-
let(:parameters)
|
7
|
+
let(:parameters) {
|
8
8
|
{
|
9
9
|
verb: :get,
|
10
10
|
endpoint: endpoint,
|
@@ -12,7 +12,7 @@ module Troo
|
|
12
12
|
model: Remote::Board,
|
13
13
|
query: {}
|
14
14
|
}
|
15
|
-
|
15
|
+
}
|
16
16
|
let(:endpoint) { :board_by_id }
|
17
17
|
let(:response) { Response.new }
|
18
18
|
let(:parsed_response) { '' }
|
@@ -28,9 +28,9 @@ module Troo
|
|
28
28
|
|
29
29
|
context 'when all required parameters are provided' do
|
30
30
|
context 'and the API request returns a collection' do
|
31
|
-
let(:parsed_response)
|
31
|
+
let(:parsed_response) {
|
32
32
|
[{ name: 'Board 1' }, { name: 'Board 2' }]
|
33
|
-
|
33
|
+
}
|
34
34
|
|
35
35
|
it 'builds the remote model' do
|
36
36
|
subject.size.must_equal(2)
|
@@ -2,14 +2,41 @@ require_relative '../../../test_helper'
|
|
2
2
|
|
3
3
|
module Troo
|
4
4
|
module API
|
5
|
+
describe Responder do
|
6
|
+
let(:described_class) { Responder }
|
7
|
+
let(:parameters) { { code: code } }
|
8
|
+
|
9
|
+
subject { described_class.build(parameters) }
|
10
|
+
|
11
|
+
context 'when the status code is 200' do
|
12
|
+
let(:code) { '200' }
|
13
|
+
|
14
|
+
it { subject.must_be_instance_of(Troo::API::Response) }
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'when the status code is any other value' do
|
18
|
+
let(:code) { '410' }
|
19
|
+
|
20
|
+
it { subject.must_be_instance_of(Troo::API::ErrorResponse) }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
5
24
|
describe Response do
|
6
25
|
let(:described_class) { Response }
|
7
26
|
let(:parameters) { {} }
|
27
|
+
|
28
|
+
subject { described_class.new(parameters) }
|
29
|
+
|
30
|
+
it { subject.must_be_instance_of(Troo::API::Response) }
|
8
31
|
end
|
9
32
|
|
10
33
|
describe ErrorResponse do
|
11
34
|
let(:described_class) { ErrorResponse }
|
12
35
|
let(:parameters) { {} }
|
36
|
+
|
37
|
+
subject { described_class.new(parameters) }
|
38
|
+
|
39
|
+
it { subject.must_be_instance_of(Troo::API::ErrorResponse) }
|
13
40
|
end
|
14
41
|
end
|
15
42
|
end
|
@@ -4,9 +4,9 @@ module Troo
|
|
4
4
|
module Commands
|
5
5
|
describe RefreshAll do
|
6
6
|
let(:described_class) { RefreshAll }
|
7
|
-
let(:resource)
|
7
|
+
let(:resource) {
|
8
8
|
[mock_trello_response('board_200.json', Troo::Remote::Board)]
|
9
|
-
|
9
|
+
}
|
10
10
|
|
11
11
|
before { Retrieval::Remote.stubs(:fetch).returns(resource) }
|
12
12
|
|
@@ -4,7 +4,7 @@ module Troo
|
|
4
4
|
describe Configuration do
|
5
5
|
let(:described_class) { Configuration }
|
6
6
|
|
7
|
-
subject { described_class.load('config/trooconf.yml',
|
7
|
+
subject { described_class.load('config/trooconf.yml', 'test') }
|
8
8
|
|
9
9
|
context 'configures' do
|
10
10
|
it 'the name of the configuration' do
|
@@ -4,7 +4,7 @@ module Troo
|
|
4
4
|
module Decorators
|
5
5
|
describe Resource do
|
6
6
|
let(:described_class) { Resource }
|
7
|
-
let(:klass)
|
7
|
+
let(:klass) {
|
8
8
|
stub(id: 67,
|
9
9
|
name: resource_name,
|
10
10
|
description: description,
|
@@ -12,7 +12,7 @@ module Troo
|
|
12
12
|
text: 'Some text...',
|
13
13
|
date: 'Wed, Dec 17 at 22:01',
|
14
14
|
type: :resource_type)
|
15
|
-
|
15
|
+
}
|
16
16
|
let(:options) { {} }
|
17
17
|
let(:described_instance) { described_class.new(klass, options) }
|
18
18
|
let(:resource_name) { 'My Resource' }
|
@@ -61,7 +61,9 @@ module Troo
|
|
61
61
|
context 'when the resource is not the default' do
|
62
62
|
let(:default) { false }
|
63
63
|
|
64
|
-
it
|
64
|
+
it 'returns nil so that join compacts the value away' do
|
65
|
+
subject.must_equal nil
|
66
|
+
end
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
@@ -34,11 +34,11 @@ module Troo
|
|
34
34
|
end
|
35
35
|
|
36
36
|
context 'and the attribute is a string' do
|
37
|
-
let(:member_ids)
|
38
|
-
let(:described_instance)
|
37
|
+
let(:member_ids) { "[\"20050\"]" }
|
38
|
+
let(:described_instance) {
|
39
39
|
Fabricate.build(:card,
|
40
40
|
external_member_ids: member_ids)
|
41
|
-
|
41
|
+
}
|
42
42
|
|
43
43
|
it 'converts to an array and returns the attribute' do
|
44
44
|
subject.external_member_ids
|
@@ -48,9 +48,9 @@ module Troo
|
|
48
48
|
end
|
49
49
|
|
50
50
|
context 'when the attribute is not set' do
|
51
|
-
let(:described_instance)
|
51
|
+
let(:described_instance) {
|
52
52
|
Fabricate.build(:card, external_member_ids: nil)
|
53
|
-
|
53
|
+
}
|
54
54
|
|
55
55
|
it 'returns an empty collection' do
|
56
56
|
subject.external_member_ids.must_equal([])
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
|
3
|
+
module Troo
|
4
|
+
describe Preference do
|
5
|
+
let(:described_class) { Preference }
|
6
|
+
let(:parameters) {
|
7
|
+
{
|
8
|
+
label: 'my_preference',
|
9
|
+
value: 'Some value...'
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
describe '#view' do
|
14
|
+
subject { described_class.view(parameters) }
|
15
|
+
|
16
|
+
it 'presents the preference' do
|
17
|
+
subject.must_equal(' my_preference: Some value...')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -21,7 +21,7 @@ end
|
|
21
21
|
module Troo
|
22
22
|
describe Wordwrap do
|
23
23
|
let(:described_class) { Wordwrap }
|
24
|
-
let(:value)
|
24
|
+
let(:value) {
|
25
25
|
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' \
|
26
26
|
"Curabitur aliquet turpis id dui condimentum elementum.\n" \
|
27
27
|
'Pellentesque blandit vulputate imperdiet. Quisque ut arcu ' \
|
@@ -35,11 +35,11 @@ module Troo
|
|
35
35
|
"quis diam.\n\nDonec mollis, nisi sit amet congue sagittis, " \
|
36
36
|
'sapien magna rhoncus justo, vel molestie metus sapien eget ' \
|
37
37
|
"libero.\n\n\n"
|
38
|
-
|
39
|
-
let(:options)
|
38
|
+
}
|
39
|
+
let(:options) { {} }
|
40
40
|
|
41
41
|
describe '#wordwrap' do
|
42
|
-
let(:formatted_value)
|
42
|
+
let(:formatted_value) {
|
43
43
|
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. " \
|
44
44
|
"Curabitur\naliquet turpis id dui condimentum elementum.\n" \
|
45
45
|
"Pellentesque blandit vulputate imperdiet. Quisque ut arcu " \
|
@@ -53,7 +53,7 @@ module Troo
|
|
53
53
|
"lectus placerat\ngravida sit amet quis diam.\n\nDonec " \
|
54
54
|
"mollis, nisi sit amet congue sagittis, sapien magna " \
|
55
55
|
"rhoncus\njusto, vel molestie metus sapien eget libero."
|
56
|
-
|
56
|
+
}
|
57
57
|
|
58
58
|
subject { described_class.this(value, options) }
|
59
59
|
|
@@ -62,11 +62,11 @@ module Troo
|
|
62
62
|
end
|
63
63
|
|
64
64
|
context 'when the content should be pruned' do
|
65
|
-
let(:options)
|
66
|
-
let(:formatted_value)
|
65
|
+
let(:options) { { width: 70, prune: true } }
|
66
|
+
let(:formatted_value) {
|
67
67
|
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.' \
|
68
68
|
" Curabitur a...\e[0m"
|
69
|
-
|
69
|
+
}
|
70
70
|
|
71
71
|
it 'returns formatted text' do
|
72
72
|
subject.must_equal(formatted_value)
|