troo 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -2,15 +2,22 @@ module Troo
|
|
2
2
|
module Commands
|
3
3
|
class Default
|
4
4
|
class << self
|
5
|
+
# @param []
|
6
|
+
# @param []
|
7
|
+
# @return []
|
5
8
|
def dispatch(klass, id)
|
6
9
|
new(klass, id).set_default
|
7
10
|
end
|
8
11
|
end
|
9
12
|
|
13
|
+
# @param []
|
14
|
+
# @param []
|
15
|
+
# @return []
|
10
16
|
def initialize(klass, id)
|
11
17
|
@klass, @id = klass, id
|
12
18
|
end
|
13
19
|
|
20
|
+
# @return []
|
14
21
|
def set_default
|
15
22
|
return success if resource && resource.set_default!
|
16
23
|
error
|
@@ -3,15 +3,24 @@ module Troo
|
|
3
3
|
module Move
|
4
4
|
class Card
|
5
5
|
class << self
|
6
|
+
# @param []
|
7
|
+
# @param []
|
8
|
+
# @param []
|
9
|
+
# @return []
|
6
10
|
def dispatch(card_id, list_id, board_id = nil)
|
7
11
|
new(card_id, list_id, board_id).move
|
8
12
|
end
|
9
13
|
end
|
10
14
|
|
15
|
+
# @param []
|
16
|
+
# @param []
|
17
|
+
# @param []
|
18
|
+
# @return []
|
11
19
|
def initialize(card_id, list_id, board_id = nil)
|
12
20
|
@card_id, @list_id, @board_id = card_id, list_id, board_id
|
13
21
|
end
|
14
22
|
|
23
|
+
# @return []
|
15
24
|
def move
|
16
25
|
return 'Card cannot be found.' if card_not_found?
|
17
26
|
return 'List cannot be found.' if list_not_found?
|
@@ -4,15 +4,22 @@ module Troo
|
|
4
4
|
attr_reader :id
|
5
5
|
|
6
6
|
class << self
|
7
|
+
# @param []
|
8
|
+
# @param []
|
9
|
+
# @return []
|
7
10
|
def dispatch(klass, id = nil)
|
8
11
|
new(klass, id).refresh
|
9
12
|
end
|
10
13
|
end
|
11
14
|
|
15
|
+
# @param []
|
16
|
+
# @param []
|
17
|
+
# @return []
|
12
18
|
def initialize(klass, id = nil)
|
13
19
|
@klass, @id = klass, id
|
14
20
|
end
|
15
21
|
|
22
|
+
# @return []
|
16
23
|
def refresh
|
17
24
|
return not_found if not_found?
|
18
25
|
return many_success if multiple_refreshed?
|
@@ -4,15 +4,22 @@ module Troo
|
|
4
4
|
attr_reader :id, :type
|
5
5
|
|
6
6
|
class << self
|
7
|
+
# @param []
|
8
|
+
# @param []
|
9
|
+
# @return [String]
|
7
10
|
def dispatch(klass, id = nil)
|
8
11
|
new(klass, id).render
|
9
12
|
end
|
10
13
|
end
|
11
14
|
|
15
|
+
# @param []
|
16
|
+
# @param []
|
17
|
+
# @return [Troo::Commands::Show]
|
12
18
|
def initialize(klass, id = nil)
|
13
19
|
@klass, @id = klass, id
|
14
20
|
end
|
15
21
|
|
22
|
+
# @return [String]
|
16
23
|
def render
|
17
24
|
if resource
|
18
25
|
presenter
|
@@ -4,15 +4,20 @@ module Troo
|
|
4
4
|
attr_reader :id
|
5
5
|
|
6
6
|
class << self
|
7
|
+
# @param []
|
8
|
+
# @return []
|
7
9
|
def dispatch(id = nil)
|
8
10
|
new(id).render
|
9
11
|
end
|
10
12
|
end
|
11
13
|
|
14
|
+
# @param []
|
15
|
+
# @return []
|
12
16
|
def initialize(id = nil)
|
13
17
|
@id = id
|
14
18
|
end
|
15
19
|
|
20
|
+
# @return []
|
16
21
|
def render
|
17
22
|
if resource
|
18
23
|
presenter
|
@@ -2,15 +2,20 @@ module Troo
|
|
2
2
|
module Commands
|
3
3
|
class Status
|
4
4
|
class << self
|
5
|
+
# @param []
|
6
|
+
# @return []
|
5
7
|
def dispatch(klass)
|
6
8
|
new(klass).report_status
|
7
9
|
end
|
8
10
|
end
|
9
11
|
|
12
|
+
# @param []
|
13
|
+
# @return []
|
10
14
|
def initialize(klass)
|
11
15
|
@klass = klass
|
12
16
|
end
|
13
17
|
|
18
|
+
# @return []
|
14
19
|
def report_status
|
15
20
|
return success if resource
|
16
21
|
error
|
data/lib/troo/cli/default.rb
CHANGED
@@ -3,18 +3,24 @@ module Troo
|
|
3
3
|
class Default < ThorFixes
|
4
4
|
package_name 'default'
|
5
5
|
|
6
|
+
# @param [String]
|
7
|
+
# @return [String]
|
6
8
|
desc 'board <id>',
|
7
9
|
'Set the board <id> to default.'
|
8
10
|
def board(id)
|
9
11
|
say Commands::Default.dispatch(Board, id)
|
10
12
|
end
|
11
13
|
|
14
|
+
# @param [String]
|
15
|
+
# @return [String]
|
12
16
|
desc 'card <id>',
|
13
17
|
'Set the card <id> to default.'
|
14
18
|
def card(id)
|
15
19
|
say Commands::Default.dispatch(Card, id)
|
16
20
|
end
|
17
21
|
|
22
|
+
# @param [String]
|
23
|
+
# @return [String]
|
18
24
|
desc 'list <id>',
|
19
25
|
'Set the list <id> to default.'
|
20
26
|
def list(id)
|
data/lib/troo/cli/main.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Troo
|
2
2
|
module CLI
|
3
3
|
class Main < ThorFixes
|
4
|
+
# @return [String]
|
4
5
|
desc 'status',
|
5
6
|
'Get troo status.'
|
6
7
|
def status
|
@@ -18,6 +19,7 @@ module Troo
|
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
22
|
+
# @return [String]
|
21
23
|
desc 'config',
|
22
24
|
'Show the current configuration.'
|
23
25
|
def config
|
@@ -25,6 +27,7 @@ module Troo
|
|
25
27
|
say Troo.configuration.view
|
26
28
|
end
|
27
29
|
|
30
|
+
# @return [String]
|
28
31
|
desc 'cleanup',
|
29
32
|
'Removes all local data.'
|
30
33
|
def cleanup
|
@@ -36,6 +39,7 @@ module Troo
|
|
36
39
|
end
|
37
40
|
end
|
38
41
|
|
42
|
+
# @return [String]
|
39
43
|
desc 'version',
|
40
44
|
'Print the version.'
|
41
45
|
def version
|
@@ -59,6 +63,10 @@ module Troo
|
|
59
63
|
'Refresh all local data or board, list or card with <id>.'
|
60
64
|
subcommand :refresh, CLI::Refresh
|
61
65
|
|
66
|
+
# @param [String]
|
67
|
+
# @param [String]
|
68
|
+
# @param [String]
|
69
|
+
# @return [String]
|
62
70
|
desc 'move <card_id> <list_id> (<board_id>)',
|
63
71
|
'Move card with <card_id> to list with <list_id> ' \
|
64
72
|
'optionally to another board with <board_id>.'
|
data/lib/troo/cli/refresh.rb
CHANGED
@@ -3,24 +3,31 @@ module Troo
|
|
3
3
|
class Refresh < ThorFixes
|
4
4
|
package_name 'refresh'
|
5
5
|
|
6
|
+
# @return [String]
|
6
7
|
desc 'all',
|
7
8
|
'Refresh all the local data.'
|
8
9
|
def all
|
9
10
|
say Commands::RefreshAll.dispatch
|
10
11
|
end
|
11
12
|
|
13
|
+
# @param [String]
|
14
|
+
# @return [String]
|
12
15
|
desc 'board (<id>)',
|
13
16
|
'Refresh the default board or board with <id>.'
|
14
17
|
def board(id = nil)
|
15
18
|
say Commands::Refresh.dispatch(Troo::Board, id)
|
16
19
|
end
|
17
20
|
|
21
|
+
# @param [String]
|
22
|
+
# @return [String]
|
18
23
|
desc 'card (<id>)',
|
19
24
|
'Refresh the default card or card with <id>.'
|
20
25
|
def card(id = nil)
|
21
26
|
say Commands::Refresh.dispatch(Troo::Card, id)
|
22
27
|
end
|
23
28
|
|
29
|
+
# @param [String]
|
30
|
+
# @return [String]
|
24
31
|
desc 'list (<id>)',
|
25
32
|
'Refresh the default list or list with <id>.'
|
26
33
|
def list(id = nil)
|
data/lib/troo/cli/show.rb
CHANGED
@@ -3,12 +3,15 @@ module Troo
|
|
3
3
|
class Show < ThorFixes
|
4
4
|
package_name 'show'
|
5
5
|
|
6
|
+
# @return [String]
|
6
7
|
desc 'boards',
|
7
8
|
'Show all the boards with lists.'
|
8
9
|
def boards
|
9
10
|
say Troo::Commands::ShowBoards.dispatch
|
10
11
|
end
|
11
12
|
|
13
|
+
# @param [String]
|
14
|
+
# @return [String]
|
12
15
|
desc 'board (<id>)',
|
13
16
|
'Show lists and cards for board <id>' \
|
14
17
|
' (uses default board if <id> not provided).'
|
@@ -16,6 +19,8 @@ module Troo
|
|
16
19
|
say Troo::Commands::Show.dispatch(Troo::Board, id)
|
17
20
|
end
|
18
21
|
|
22
|
+
# @param [String]
|
23
|
+
# @return [String]
|
19
24
|
desc 'list (<id>)',
|
20
25
|
'Show all cards for list <id>' \
|
21
26
|
' (uses default list if <id> not provided).'
|
@@ -23,6 +28,8 @@ module Troo
|
|
23
28
|
say Troo::Commands::Show.dispatch(Troo::List, id)
|
24
29
|
end
|
25
30
|
|
31
|
+
# @param [String]
|
32
|
+
# @return [String]
|
26
33
|
desc 'card (<id>)',
|
27
34
|
'Show a card <id> including last 3 comments' \
|
28
35
|
' (uses default card if <id> not provided).'
|
@@ -30,6 +37,8 @@ module Troo
|
|
30
37
|
say Troo::Commands::Show.dispatch(Troo::Card, id)
|
31
38
|
end
|
32
39
|
|
40
|
+
# @param [String]
|
41
|
+
# @return [String]
|
33
42
|
desc 'comments (<id>)',
|
34
43
|
'Show all comments for card <id>' \
|
35
44
|
' (uses default card if <id> not provided).'
|
data/lib/troo/cli/thor_fixes.rb
CHANGED
data/lib/troo/configuration.rb
CHANGED
@@ -1,29 +1,4 @@
|
|
1
1
|
module Troo
|
2
|
-
class Preference
|
3
|
-
include Virtus.value_object
|
4
|
-
|
5
|
-
values do
|
6
|
-
attribute :label, String
|
7
|
-
attribute :value, String
|
8
|
-
end
|
9
|
-
|
10
|
-
class << self
|
11
|
-
def view(parameters)
|
12
|
-
new(parameters).view
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def view
|
17
|
-
[formatted_label, value].join(' ')
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def formatted_label
|
23
|
-
(label + ':').rjust(25, ' ')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
2
|
class Configuration
|
28
3
|
include Virtus.value_object
|
29
4
|
|
@@ -40,15 +15,15 @@ module Troo
|
|
40
15
|
end
|
41
16
|
|
42
17
|
class << self
|
18
|
+
# @param []
|
19
|
+
# @param [String]
|
20
|
+
# @return []
|
43
21
|
def load(file, env)
|
44
|
-
new(YAML.load_file(file)[env
|
45
|
-
rescue Errno::ENOENT
|
46
|
-
puts "\nConfiguration cannot be found, please run 'troo init'" \
|
47
|
-
" first.\n\n"
|
48
|
-
exit(1)
|
22
|
+
new(YAML.load_file(file)[env])
|
49
23
|
end
|
50
24
|
end
|
51
25
|
|
26
|
+
# @return []
|
52
27
|
def view
|
53
28
|
attributes.map do |label, value|
|
54
29
|
Preference.view(label: label, value: value)
|
data/lib/troo/database.rb
CHANGED
@@ -1,15 +1,22 @@
|
|
1
1
|
module Troo
|
2
2
|
class Database
|
3
3
|
class << self
|
4
|
+
# @param []
|
5
|
+
# @param [Hash]
|
6
|
+
# @return []
|
4
7
|
def connect(configuration, options = {})
|
5
8
|
new(configuration, options).connect
|
6
9
|
end
|
7
10
|
end
|
8
11
|
|
12
|
+
# @param []
|
13
|
+
# @param [Hash]
|
14
|
+
# @return []
|
9
15
|
def initialize(configuration, options = {})
|
10
16
|
@configuration, @options = configuration, options
|
11
17
|
end
|
12
18
|
|
19
|
+
# @return []
|
13
20
|
def connect
|
14
21
|
Ohm.connect(db: configuration.database)
|
15
22
|
end
|
data/lib/troo/debug.rb
CHANGED
@@ -3,10 +3,14 @@ module Troo
|
|
3
3
|
class Resource
|
4
4
|
include DecoratorHelpers
|
5
5
|
|
6
|
+
# @param []
|
7
|
+
# @param [Hash]
|
8
|
+
# @return [Troo::Decorators::Resource]
|
6
9
|
def initialize(klass, options = {})
|
7
10
|
@klass, @options = klass, options
|
8
11
|
end
|
9
12
|
|
13
|
+
# @return [String]
|
10
14
|
def title
|
11
15
|
[
|
12
16
|
resource_id,
|
@@ -15,6 +19,7 @@ module Troo
|
|
15
19
|
].compact.join(' ') + "\n"
|
16
20
|
end
|
17
21
|
|
22
|
+
# @return [String]
|
18
23
|
def resource_title
|
19
24
|
if klass.type == :card
|
20
25
|
Troo::Wordwrap.this(name, prune: true)
|
@@ -24,6 +29,7 @@ module Troo
|
|
24
29
|
end
|
25
30
|
end
|
26
31
|
|
32
|
+
# @return [String]
|
27
33
|
def resource_id
|
28
34
|
if klass.type == :card
|
29
35
|
brackets(Troo::Formatter.highlight(
|
@@ -33,32 +39,39 @@ module Troo
|
|
33
39
|
end
|
34
40
|
end
|
35
41
|
|
42
|
+
# @return []
|
36
43
|
def id
|
37
44
|
(klass.type == :card) ? klass.short_id : klass.id
|
38
45
|
end
|
39
46
|
|
47
|
+
# @return [String]
|
40
48
|
def description
|
41
49
|
return 'N/A' if klass.description.nil? ||
|
42
50
|
klass.description.empty?
|
43
51
|
Troo::Formatter.wordwrap(klass.description)
|
44
52
|
end
|
45
53
|
|
54
|
+
# @return [String, NilClass]
|
46
55
|
def default
|
47
56
|
klass.default? ? '*' : nil
|
48
57
|
end
|
49
58
|
|
59
|
+
# @return [String]
|
50
60
|
def name
|
51
61
|
(klass.name && klass.name.chomp) || 'N/A'
|
52
62
|
end
|
53
63
|
|
64
|
+
# @return []
|
54
65
|
def board
|
55
66
|
klass.board.decorator
|
56
67
|
end
|
57
68
|
|
69
|
+
# @return []
|
58
70
|
def list
|
59
71
|
klass.list.decorator
|
60
72
|
end
|
61
73
|
|
74
|
+
# @return [String]
|
62
75
|
def comments
|
63
76
|
if klass.comments.any? && klass.comments.size > 3
|
64
77
|
msg = '(There are more comments, use: ' \
|
@@ -72,28 +85,34 @@ module Troo
|
|
72
85
|
end
|
73
86
|
end
|
74
87
|
|
88
|
+
# @return [String]
|
75
89
|
def members
|
76
90
|
Presenters::Member.new(klass).show
|
77
91
|
end
|
78
92
|
|
93
|
+
# @return [String]
|
79
94
|
def last_activity_date
|
80
95
|
return 'N/A' unless klass.last_activity_date
|
81
96
|
Time.parse(klass.last_activity_date)
|
82
97
|
.strftime('%a, %b %d at %H:%M')
|
83
98
|
end
|
84
99
|
|
100
|
+
# @return [String]
|
85
101
|
def as_view
|
86
102
|
Template.parse(self, '/../views/' + type + '.erb')
|
87
103
|
end
|
88
104
|
|
105
|
+
# @return [String]
|
89
106
|
def username
|
90
107
|
['@', klass.member.username].join
|
91
108
|
end
|
92
109
|
|
110
|
+
# @return [String]
|
93
111
|
def text
|
94
112
|
Troo::Formatter.wordwrap(klass.text)
|
95
113
|
end
|
96
114
|
|
115
|
+
# @return [String]
|
97
116
|
def date
|
98
117
|
Time.parse(klass.date).strftime('%a, %b %d at %H:%M')
|
99
118
|
end
|