troo 0.0.7 → 0.0.8

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.
Files changed (271) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +2 -0
  4. data/Guardfile +3 -1
  5. data/Rakefile +7 -0
  6. data/bin/troo +3 -8
  7. data/config/.gitkeep +0 -0
  8. data/config/cucumber.yml +8 -0
  9. data/features/add/board.feature +26 -0
  10. data/features/add/card.feature +34 -0
  11. data/features/add/comment.feature +21 -0
  12. data/features/add/list.feature +24 -0
  13. data/features/cleanup.feature +13 -0
  14. data/features/default/board.feature +21 -0
  15. data/features/default/card.feature +21 -0
  16. data/features/default/list.feature +21 -0
  17. data/features/refresh/all.feature +7 -0
  18. data/features/refresh/board.feature +26 -0
  19. data/features/refresh/card.feature +27 -0
  20. data/features/refresh/list.feature +27 -0
  21. data/features/show/board.feature +32 -0
  22. data/features/show/card.feature +62 -0
  23. data/features/show/comment.feature +39 -0
  24. data/features/show/list.feature +37 -0
  25. data/features/status.feature +46 -1
  26. data/features/step_definitions/fabrication_steps.rb +34 -0
  27. data/features/step_definitions/troo_steps.rb +16 -0
  28. data/features/support/env.rb +22 -24
  29. data/features/troo.feature +31 -1
  30. data/lib/troo/actions/create_board.rb +10 -7
  31. data/lib/troo/actions/create_card.rb +5 -4
  32. data/lib/troo/actions/create_comment.rb +15 -13
  33. data/lib/troo/actions/create_list.rb +5 -4
  34. data/lib/troo/actions/move_card.rb +4 -3
  35. data/lib/troo/{external/board_adaptor.rb → adaptors/board.rb} +3 -14
  36. data/lib/troo/{external/card_adaptor.rb → adaptors/card.rb} +4 -15
  37. data/lib/troo/{external/comment_adaptor.rb → adaptors/comment.rb} +6 -17
  38. data/lib/troo/{external/list_adaptor.rb → adaptors/list.rb} +3 -14
  39. data/lib/troo/{external/member_adaptor.rb → adaptors/member.rb} +3 -14
  40. data/lib/troo/adaptors/resource.rb +17 -0
  41. data/lib/troo/cli/add.rb +53 -0
  42. data/lib/troo/cli/default.rb +25 -0
  43. data/lib/troo/cli/main.rb +46 -0
  44. data/lib/troo/cli/refresh.rb +31 -0
  45. data/lib/troo/cli/show.rb +41 -0
  46. data/lib/troo/cli/thor_fixes.rb +13 -0
  47. data/lib/troo/commands/add/board.rb +26 -0
  48. data/lib/troo/commands/add/card.rb +33 -0
  49. data/lib/troo/commands/add/comment.rb +33 -0
  50. data/lib/troo/commands/add/list.rb +33 -0
  51. data/lib/troo/commands/add/resource.rb +21 -0
  52. data/lib/troo/commands/commands.rb +28 -0
  53. data/lib/troo/commands/default/board.rb +25 -0
  54. data/lib/troo/commands/default/card.rb +25 -0
  55. data/lib/troo/commands/default/list.rb +25 -0
  56. data/lib/troo/commands/default/resource.rb +26 -0
  57. data/lib/troo/commands/refresh/all.rb +41 -0
  58. data/lib/troo/commands/refresh/board.rb +28 -0
  59. data/lib/troo/commands/refresh/card.rb +29 -0
  60. data/lib/troo/commands/refresh/list.rb +29 -0
  61. data/lib/troo/commands/refresh/resource.rb +42 -0
  62. data/lib/troo/commands/show/board.rb +13 -0
  63. data/lib/troo/commands/show/boards.rb +35 -0
  64. data/lib/troo/commands/show/card.rb +13 -0
  65. data/lib/troo/commands/show/comments.rb +21 -0
  66. data/lib/troo/commands/show/list.rb +13 -0
  67. data/lib/troo/commands/show/resource.rb +41 -0
  68. data/lib/troo/commands/status/board.rb +30 -0
  69. data/lib/troo/commands/status/card.rb +30 -0
  70. data/lib/troo/commands/status/list.rb +30 -0
  71. data/lib/troo/commands/status/resource.rb +34 -0
  72. data/lib/troo/decorators/board.rb +66 -0
  73. data/lib/troo/decorators/card.rb +105 -0
  74. data/lib/troo/decorators/comment.rb +36 -0
  75. data/lib/troo/decorators/list.rb +60 -0
  76. data/lib/troo/decorators/member.rb +28 -0
  77. data/lib/troo/external/board.rb +14 -26
  78. data/lib/troo/external/card.rb +2 -19
  79. data/lib/troo/external/comment.rb +5 -23
  80. data/lib/troo/external/list.rb +2 -20
  81. data/lib/troo/external/member.rb +2 -20
  82. data/lib/troo/external/resource.rb +21 -6
  83. data/lib/troo/helpers/command_helpers.rb +37 -0
  84. data/lib/troo/{display → helpers}/decorator_helpers.rb +23 -17
  85. data/lib/troo/{models → helpers}/model_helpers.rb +1 -1
  86. data/lib/troo/models/behaviours/set_default.rb +49 -0
  87. data/lib/troo/models/board.rb +10 -7
  88. data/lib/troo/models/card.rb +33 -15
  89. data/lib/troo/models/comment.rb +8 -5
  90. data/lib/troo/models/list.rb +10 -6
  91. data/lib/troo/models/member.rb +7 -4
  92. data/lib/troo/models/persistence/board.rb +19 -0
  93. data/lib/troo/models/persistence/card.rb +19 -0
  94. data/lib/troo/models/persistence/comment.rb +19 -0
  95. data/lib/troo/models/persistence/list.rb +19 -0
  96. data/lib/troo/models/persistence/member.rb +19 -0
  97. data/lib/troo/models/persistence/resource.rb +50 -0
  98. data/lib/troo/models/refresh.rb +1 -1
  99. data/lib/troo/models/remote/comment.rb +21 -0
  100. data/lib/troo/models/remote/resource.rb +25 -0
  101. data/lib/troo/models/retrieval/board.rb +29 -0
  102. data/lib/troo/models/retrieval/card.rb +33 -0
  103. data/lib/troo/models/retrieval/comment.rb +25 -0
  104. data/lib/troo/models/retrieval/list.rb +29 -0
  105. data/lib/troo/models/retrieval/member.rb +25 -0
  106. data/lib/troo/models/retrieval/resource.rb +36 -0
  107. data/lib/troo/presentation/sentence.rb +57 -0
  108. data/lib/troo/presentation/template.rb +4 -3
  109. data/lib/troo/presenters/board.rb +81 -0
  110. data/lib/troo/presenters/card.rb +30 -0
  111. data/lib/troo/presenters/comment.rb +38 -0
  112. data/lib/troo/presenters/list.rb +44 -0
  113. data/lib/troo/presenters/member.rb +32 -0
  114. data/lib/troo/troo.rb +79 -65
  115. data/lib/troo/version.rb +1 -2
  116. data/lib/troo.rb +36 -8
  117. data/test/lib/troo/actions/create_board_test.rb +34 -15
  118. data/test/lib/troo/actions/create_card_test.rb +35 -18
  119. data/test/lib/troo/actions/create_comment_test.rb +38 -16
  120. data/test/lib/troo/actions/create_list_test.rb +31 -15
  121. data/test/lib/troo/actions/move_card_test.rb +23 -15
  122. data/test/lib/troo/adaptors/board_test.rb +38 -0
  123. data/test/lib/troo/adaptors/card_test.rb +49 -0
  124. data/test/lib/troo/adaptors/comment_test.rb +41 -0
  125. data/test/lib/troo/adaptors/list_test.rb +38 -0
  126. data/test/lib/troo/adaptors/member_test.rb +44 -0
  127. data/test/lib/troo/commands/add/board_test.rb +43 -0
  128. data/test/lib/troo/commands/add/card_test.rb +44 -0
  129. data/test/lib/troo/commands/add/comment_test.rb +44 -0
  130. data/test/lib/troo/commands/add/list_test.rb +44 -0
  131. data/test/lib/troo/commands/add/resource_test.rb +25 -0
  132. data/test/lib/troo/commands/default/board_test.rb +37 -0
  133. data/test/lib/troo/commands/default/card_test.rb +37 -0
  134. data/test/lib/troo/commands/default/list_test.rb +37 -0
  135. data/test/lib/troo/commands/default/resource_test.rb +20 -0
  136. data/test/lib/troo/commands/refresh/all_test.rb +39 -0
  137. data/test/lib/troo/commands/refresh/board_test.rb +62 -0
  138. data/test/lib/troo/commands/refresh/card_test.rb +62 -0
  139. data/test/lib/troo/commands/refresh/list_test.rb +62 -0
  140. data/test/lib/troo/commands/refresh/resource_test.rb +20 -0
  141. data/test/lib/troo/commands/show/board_test.rb +65 -0
  142. data/test/lib/troo/commands/show/boards_test.rb +36 -0
  143. data/test/lib/troo/commands/show/card_test.rb +64 -0
  144. data/test/lib/troo/commands/show/comments_test.rb +64 -0
  145. data/test/lib/troo/commands/show/list_test.rb +64 -0
  146. data/test/lib/troo/commands/show/resource_test.rb +25 -0
  147. data/test/lib/troo/commands/status/board_test.rb +43 -0
  148. data/test/lib/troo/commands/status/card_test.rb +43 -0
  149. data/test/lib/troo/commands/status/list_test.rb +43 -0
  150. data/test/lib/troo/commands/status/resource_test.rb +19 -0
  151. data/test/lib/troo/decorators/board_test.rb +129 -0
  152. data/test/lib/troo/decorators/card_test.rb +237 -0
  153. data/test/lib/troo/decorators/comment_test.rb +74 -0
  154. data/test/lib/troo/decorators/list_test.rb +102 -0
  155. data/test/lib/troo/decorators/member_test.rb +50 -0
  156. data/test/lib/troo/external/board_test.rb +74 -41
  157. data/test/lib/troo/external/card_test.rb +49 -37
  158. data/test/lib/troo/external/comment_test.rb +43 -33
  159. data/test/lib/troo/external/list_test.rb +37 -30
  160. data/test/lib/troo/external/member_test.rb +37 -30
  161. data/test/lib/troo/external/resource_test.rb +18 -1
  162. data/test/lib/troo/helpers/command_helpers_test.rb +82 -0
  163. data/test/lib/troo/{display → helpers}/decorator_helpers_test.rb +6 -6
  164. data/test/lib/troo/helpers/model_helpers_test.rb +103 -0
  165. data/test/lib/troo/models/behaviours/set_default_test.rb +54 -0
  166. data/test/lib/troo/models/board_test.rb +13 -14
  167. data/test/lib/troo/models/card_test.rb +64 -33
  168. data/test/lib/troo/models/comment_test.rb +18 -19
  169. data/test/lib/troo/models/list_test.rb +15 -15
  170. data/test/lib/troo/models/member_test.rb +18 -18
  171. data/test/lib/troo/models/persistence/board_test.rb +62 -0
  172. data/test/lib/troo/models/persistence/card_test.rb +61 -0
  173. data/test/lib/troo/models/persistence/comment_test.rb +69 -0
  174. data/test/lib/troo/models/persistence/list_test.rb +60 -0
  175. data/test/lib/troo/models/persistence/member_test.rb +60 -0
  176. data/test/lib/troo/models/refresh_test.rb +12 -11
  177. data/test/lib/troo/models/remote/comment_test.rb +56 -0
  178. data/test/lib/troo/models/remote/resource_test.rb +26 -0
  179. data/test/lib/troo/models/retrieval/board_test.rb +93 -0
  180. data/test/lib/troo/models/retrieval/card_test.rb +101 -0
  181. data/test/lib/troo/models/retrieval/comment_test.rb +46 -0
  182. data/test/lib/troo/models/retrieval/list_test.rb +93 -0
  183. data/test/lib/troo/models/retrieval/member_test.rb +58 -0
  184. data/test/lib/troo/presentation/sentence_test.rb +57 -0
  185. data/test/lib/troo/presentation/template_test.rb +17 -16
  186. data/test/lib/troo/presenters/board_test.rb +79 -0
  187. data/test/lib/troo/presenters/card_test.rb +41 -0
  188. data/test/lib/troo/presenters/comment_test.rb +49 -0
  189. data/test/lib/troo/presenters/list_test.rb +50 -0
  190. data/test/lib/troo/presenters/member_test.rb +40 -0
  191. data/test/support/fabrication.rb +31 -32
  192. data/test/support/vcr_setup.rb +7 -9
  193. data/test/system_test.sh +55 -0
  194. data/test/test_helper.rb +10 -10
  195. data/troo.gemspec +1 -0
  196. metadata +232 -134
  197. data/features/add_board.feature +0 -1
  198. data/features/add_card.feature +0 -1
  199. data/features/add_comment.feature +0 -1
  200. data/features/add_list.feature +0 -1
  201. data/features/move_card_to_list.feature +0 -1
  202. data/features/refresh.feature +0 -1
  203. data/features/set_default.feature +0 -7
  204. data/features/show_board.feature +0 -1
  205. data/features/show_boards.feature +0 -1
  206. data/features/show_card.feature +0 -1
  207. data/features/show_comments.feature +0 -1
  208. data/features/show_list.feature +0 -1
  209. data/features/version.feature +0 -8
  210. data/lib/troo/actions/refresh_all.rb +0 -79
  211. data/lib/troo/actions/set_default.rb +0 -46
  212. data/lib/troo/cli/add_cli.rb +0 -83
  213. data/lib/troo/cli/cli_helpers.rb +0 -34
  214. data/lib/troo/cli/default_cli.rb +0 -32
  215. data/lib/troo/cli/main_cli.rb +0 -132
  216. data/lib/troo/cli/show_cli.rb +0 -64
  217. data/lib/troo/display/board_decorator.rb +0 -62
  218. data/lib/troo/display/board_presenter.rb +0 -71
  219. data/lib/troo/display/card_decorator.rb +0 -100
  220. data/lib/troo/display/card_presenter.rb +0 -27
  221. data/lib/troo/display/comment_decorator.rb +0 -33
  222. data/lib/troo/display/comment_presenter.rb +0 -31
  223. data/lib/troo/display/list_decorator.rb +0 -57
  224. data/lib/troo/display/list_presenter.rb +0 -41
  225. data/lib/troo/display/member_decorator.rb +0 -25
  226. data/lib/troo/display/member_presenter.rb +0 -59
  227. data/lib/troo/models/board_persistence.rb +0 -25
  228. data/lib/troo/models/board_retrieval.rb +0 -45
  229. data/lib/troo/models/card_persistence.rb +0 -25
  230. data/lib/troo/models/card_retrieval.rb +0 -49
  231. data/lib/troo/models/comment_persistence.rb +0 -25
  232. data/lib/troo/models/comment_retrieval.rb +0 -32
  233. data/lib/troo/models/list_persistence.rb +0 -25
  234. data/lib/troo/models/list_retrieval.rb +0 -45
  235. data/lib/troo/models/member_persistence.rb +0 -25
  236. data/lib/troo/models/member_retrieval.rb +0 -36
  237. data/lib/troo/models/persistence.rb +0 -39
  238. data/test/lib/troo/actions/refresh_all_test.rb +0 -68
  239. data/test/lib/troo/actions/set_default_test.rb +0 -44
  240. data/test/lib/troo/cli/add_cli_test.rb +0 -216
  241. data/test/lib/troo/cli/cli_helpers_test.rb +0 -24
  242. data/test/lib/troo/cli/default_cli_test.rb +0 -85
  243. data/test/lib/troo/cli/main_cli_test.rb +0 -234
  244. data/test/lib/troo/cli/show_cli_test.rb +0 -251
  245. data/test/lib/troo/display/board_decorator_test.rb +0 -126
  246. data/test/lib/troo/display/board_presenter_test.rb +0 -77
  247. data/test/lib/troo/display/card_decorator_test.rb +0 -213
  248. data/test/lib/troo/display/card_presenter_test.rb +0 -38
  249. data/test/lib/troo/display/comment_decorator_test.rb +0 -70
  250. data/test/lib/troo/display/comment_presenter_test.rb +0 -47
  251. data/test/lib/troo/display/list_decorator_test.rb +0 -98
  252. data/test/lib/troo/display/list_presenter_test.rb +0 -48
  253. data/test/lib/troo/display/member_decorator_test.rb +0 -47
  254. data/test/lib/troo/display/member_presenter_test.rb +0 -70
  255. data/test/lib/troo/external/board_adaptor_test.rb +0 -36
  256. data/test/lib/troo/external/card_adaptor_test.rb +0 -50
  257. data/test/lib/troo/external/comment_adaptor_test.rb +0 -41
  258. data/test/lib/troo/external/list_adaptor_test.rb +0 -38
  259. data/test/lib/troo/external/member_adaptor_test.rb +0 -44
  260. data/test/lib/troo/models/board_persistence_test.rb +0 -61
  261. data/test/lib/troo/models/board_retrieval_test.rb +0 -93
  262. data/test/lib/troo/models/card_persistence_test.rb +0 -60
  263. data/test/lib/troo/models/card_retrieval_test.rb +0 -101
  264. data/test/lib/troo/models/comment_persistence_test.rb +0 -65
  265. data/test/lib/troo/models/comment_retrieval_test.rb +0 -46
  266. data/test/lib/troo/models/list_persistence_test.rb +0 -60
  267. data/test/lib/troo/models/list_retrieval_test.rb +0 -93
  268. data/test/lib/troo/models/member_persistence_test.rb +0 -59
  269. data/test/lib/troo/models/member_retrieval_test.rb +0 -58
  270. data/test/lib/troo/models/model_helpers_test.rb +0 -103
  271. data/test/lib/troo/models/persistence_test.rb +0 -6
@@ -1,83 +0,0 @@
1
- module Troo
2
- module CLI
3
- class Add < ThorFixes
4
- package_name "add"
5
-
6
- desc "board <name> (<description>)",
7
- "Add a new board with <name> and optional <description>."
8
- def board(name = nil, description = nil)
9
- if name.nil?
10
- name = ask("Please enter a name for this board:")
11
- end
12
-
13
- if result = CreateBoard.with(name, description)
14
- say "New board '#{result.decorator.name}' created."
15
- else
16
- say "Board could not be created."
17
- end
18
- rescue Troo::InvalidAccessToken
19
- say "Your Trello access credentials have expired, please renew and try again."
20
- end
21
-
22
- desc "card <list_id> <name> (<description>)",
23
- "Add a new card to <list_id> with <name> and optional <description>."
24
- def card(list_id, name = nil, description = nil)
25
- if name.nil?
26
- name = ask("Please enter a name for this card:")
27
- end
28
-
29
- if list = ListRetrieval.retrieve(list_id)
30
- if result = CreateCard.for(list, name, description)
31
- say "New card '#{result.decorator.name}' created."
32
- else
33
- say "Card could not be created."
34
- end
35
- else
36
- say "Card could not be created, as list was not found."
37
- end
38
- rescue Troo::InvalidAccessToken
39
- say "Your Trello access credentials have expired, please renew and try again."
40
- end
41
-
42
- desc "comment <card_id> <comment>",
43
- "Add a new comment to <card_id>."
44
- def comment(card_id, comment = nil)
45
- if comment.nil?
46
- comment = ask("Please enter a comment:")
47
- end
48
-
49
- if card = CardRetrieval.retrieve(card_id)
50
- if CreateComment.for(card, comment)
51
- say "New comment created."
52
- else
53
- say "Comment could not be created."
54
- end
55
- else
56
- say "Comment could not be created, as card was not found."
57
- end
58
- rescue Troo::InvalidAccessToken
59
- say "Your Trello access credentials have expired, please renew and try again."
60
- end
61
-
62
- desc "list <board_id> <name>",
63
- "Add a new list to <board_id> with <name>."
64
- def list(board_id, name = nil)
65
- if name.nil?
66
- name = ask("Please enter a name for this list:")
67
- end
68
-
69
- if board = BoardRetrieval.retrieve(board_id)
70
- if result = CreateList.for(board, name)
71
- say "New list '#{result.decorator.name}' created."
72
- else
73
- say "List could not be created."
74
- end
75
- else
76
- say "List could not be created, as board was not found."
77
- end
78
- rescue Troo::InvalidAccessToken
79
- say "Your Trello access credentials have expired, please renew and try again."
80
- end
81
- end
82
- end
83
- end
@@ -1,34 +0,0 @@
1
- module Troo
2
- module CLI
3
- module Helpers
4
- def set_default
5
- return success if resource && resource.set_default!
6
- not_found
7
- end
8
-
9
- def success
10
- say "'#{resource.decorator.name}' set as default #{type.to_s.downcase}."
11
- true
12
- end
13
-
14
- def not_found
15
- say "#{type.to_s.capitalize} cannot be found. Specify a different <id> or use 'troo default #{type.to_s} <id>' to set a default #{type.to_s} first."
16
- false
17
- end
18
-
19
- def resource
20
- @resource = case type
21
- when :board then @board ||= BoardRetrieval.retrieve(id)
22
- when :list then @list ||= ListRetrieval.retrieve(id)
23
- when :card then @card ||= CardRetrieval.retrieve(id)
24
- end
25
- end
26
- end
27
-
28
- class ThorFixes < Thor
29
- def self.banner(command, namespace = nil, subcommand = false)
30
- "#{basename} #{@package_name} #{command.usage}"
31
- end
32
- end
33
- end
34
- end
@@ -1,32 +0,0 @@
1
- module Troo
2
- module CLI
3
- class Default < ThorFixes
4
- include Helpers
5
-
6
- package_name "default"
7
-
8
- desc "board <id>", "Set the board <id> to default."
9
- def board(id)
10
- initialize_and_dispatch(id, :board)
11
- end
12
-
13
- desc "card <id>", "Set the card <id> to default."
14
- def card(id)
15
- initialize_and_dispatch(id, :card)
16
- end
17
-
18
- desc "list <id>", "Set the list <id> to default."
19
- def list(id)
20
- initialize_and_dispatch(id, :list)
21
- end
22
-
23
- private
24
- attr_reader :id, :type
25
-
26
- def initialize_and_dispatch(id, type)
27
- @id, @type = id, type
28
- set_default
29
- end
30
- end
31
- end
32
- end
@@ -1,132 +0,0 @@
1
- module Troo
2
- module CLI
3
- class Main < ThorFixes
4
- include Helpers
5
-
6
- default_task :status
7
-
8
- class_option :debug, type: :boolean, desc: "Enable debugging."
9
-
10
- desc "status", "Get troo status."
11
- def status
12
- say "Status:"
13
- get_status(:board)
14
- get_status(:list)
15
- get_status(:card)
16
- say ""
17
-
18
- help
19
- end
20
-
21
- desc "refresh", "Refresh all data for default board."
22
- method_option :all, type: :boolean, desc: "Refresh all boards, lists, cards and comments."
23
- method_option :lists, type: :boolean, desc: "Refresh all lists for default board."
24
- method_option :cards, type: :boolean, desc: "Refresh all cards for default board."
25
- def refresh
26
- if options["all"]
27
- RefreshAll.all(nil, options)
28
- say "All local data has been refreshed."
29
- else
30
- if board = BoardRetrieval.default
31
- if options["lists"]
32
- RefreshAll.lists(board, options)
33
- say "All lists for the default board have been refreshed."
34
- elsif options["cards"]
35
- RefreshAll.cards(board, options)
36
- say "All cards for the default board have been refreshed."
37
- else
38
- RefreshAll.default(board, options)
39
- say "All data for the default board has been refreshed."
40
- end
41
- else
42
- say "Use 'troo default board <board_id>' to set a default board first."
43
- end
44
- end
45
- rescue Troo::InvalidAccessToken
46
- say "Your Trello access credentials have expired, please renew and try again."
47
- end
48
-
49
- desc "cleanup", "Removes all local data."
50
- def cleanup
51
- if yes?("This will remove all local data, are you sure?")
52
- Ohm.redis.flushdb
53
- say "All local data has been removed."
54
- end
55
- end
56
-
57
- desc "version", "Print the version."
58
- def version
59
- say "troo #{Troo::VERSION}"
60
- end
61
-
62
- desc "show [board|list|card|comment] <id>", "Show the board, list, card or comment with <id>."
63
- subcommand :show, Troo::CLI::Show
64
-
65
- desc "add [board|list|card|comment] <id>", "Add board, list, card or comment."
66
- subcommand :add, Troo::CLI::Add
67
-
68
- desc "default [board|list|card] <id>", "Set board, list or card to be default."
69
- subcommand :default, Troo::CLI::Default
70
-
71
- desc "move <card_id> <list_id>", "Move a card <card_id> to list <list_id>."
72
- def move(card_id, list_id)
73
- if card = CardRetrieval.retrieve(card_id)
74
- if list = ListRetrieval.retrieve(list_id)
75
- if result = MoveCard.with(card, list)
76
- say "Card moved from '#{card.list.decorator.name}' to '#{list.decorator.name}'."
77
- else
78
- say "Card could not be moved."
79
- end
80
- else
81
- say "Card could not be moved, as list was not found."
82
- end
83
- else
84
- say "Card could not be moved, as card was not found."
85
- end
86
- rescue Troo::InvalidAccessToken
87
- say "Your Trello access credentials have expired, please renew and try again."
88
- end
89
-
90
- private
91
- attr_reader :id, :type
92
-
93
- def get_status(type)
94
- @id, @type = nil, type
95
- return show_resource_title if resource_found && resource
96
- return no_default_found if resource_count > 0
97
- end
98
-
99
- def resource_found
100
- label = " #{type.to_s.capitalize}s:".ljust(10)
101
- say label + plural(resource_count, type.to_s) + " found."
102
- end
103
-
104
- def resource_count
105
- @count = case type
106
- when :board then Troo::Board.count
107
- when :list then Troo::List.count
108
- when :card then Troo::Card.count
109
- end
110
- end
111
-
112
- def show_resource_title
113
- say " #{resource.decorator.title}"
114
- end
115
-
116
- def no_default_found
117
- say " " + Esc.red + "No default #{type} set." + Esc.reset
118
- end
119
-
120
- def plural(size, singular)
121
- pluralized = singular + "s"
122
- if size == 0
123
- "No #{pluralized}"
124
- elsif size == 1
125
- "#{size} #{singular}"
126
- else
127
- "#{size} #{pluralized}"
128
- end
129
- end
130
- end
131
- end
132
- end
@@ -1,64 +0,0 @@
1
- module Troo
2
- module CLI
3
- class Show < ThorFixes
4
- include Helpers
5
-
6
- package_name "show"
7
-
8
- desc "boards", "Show all the boards with lists."
9
- def boards
10
- boards = BoardRetrieval.all
11
- if boards.any?
12
- boards.map do |board|
13
- BoardPresenter.render_all(board)
14
- end
15
- else
16
- say "Boards not found."
17
- end
18
- end
19
-
20
- desc "board (<id>)", "Show lists and cards for board <id> (uses default board if <id> not provided)."
21
- def board(id = nil)
22
- initialize_and_dispatch(id, :board)
23
- end
24
-
25
- desc "list (<id>)", "Show all cards for list <id> (uses default list if <id> not provided)."
26
- def list(id = nil)
27
- initialize_and_dispatch(id, :list)
28
- end
29
-
30
- desc "card (<id>)", "Show a card including latest 3 comments for card <id> (uses default card if <id> not provided)."
31
- def card(id = nil)
32
- initialize_and_dispatch(id, :card)
33
- end
34
-
35
- desc "comments (<id>)", "Show all comments for card <id> (uses default card if <id> not provided)."
36
- def comments(id = nil)
37
- if card = CardRetrieval.retrieve(id)
38
- if SetDefault.for(card)
39
- say "'#{card.decorator.name}' set to default."
40
- end
41
- CommentPresenter.show(card)
42
- else
43
- if id
44
- say "Card cannot be found."
45
- else
46
- say "Specify a <id> or use 'troo default card <id>' to set a default card first."
47
- end
48
- end
49
- end
50
-
51
- private
52
- attr_reader :id, :type
53
-
54
- def initialize_and_dispatch(id, type)
55
- @id, @type = id, type
56
- show_resource
57
- end
58
-
59
- def show_resource
60
- resource.presenter.show if set_default
61
- end
62
- end
63
- end
64
- end
@@ -1,62 +0,0 @@
1
- module Troo
2
- class BoardDecorator
3
- include DecoratorHelpers
4
-
5
- def initialize(board, options = {})
6
- @board = board
7
- @options = options
8
- end
9
-
10
- def short
11
- [default_str, id_str, name_str].join + "\n"
12
- end
13
-
14
- def name_str
15
- highlight(name, options)
16
- end
17
-
18
- def default_str
19
- default.center(3)
20
- end
21
-
22
- def id_str
23
- highlight(brackets(id) + " ", options).rjust(6)
24
- end
25
-
26
- def description
27
- return "N/A" if board.description.nil? || board.description.empty?
28
- word_wrap(board.description)
29
- end
30
-
31
- def name
32
- (board.name && board.name.chomp) || "N/A"
33
- end
34
-
35
- def default
36
- board.default? ? "*" : ""
37
- end
38
-
39
- def id
40
- board.id.to_s
41
- end
42
-
43
- def lists(alt_options = {})
44
- board.lists.map { |list| list.decorator(alt_options) }
45
- end
46
-
47
- private
48
- attr_reader :board
49
-
50
- def options
51
- defaults.merge!(@options)
52
- end
53
-
54
- def defaults
55
- {
56
- ansicolor: true,
57
- colour: Esc.blue,
58
- underline: Esc.underline
59
- }
60
- end
61
- end
62
- end
@@ -1,71 +0,0 @@
1
- module Troo
2
- class BoardPresenter
3
- class << self
4
- def render_all(board, options = {})
5
- new(board, options).render_all
6
- end
7
-
8
- def show(board, options = {})
9
- new(board, options).show
10
- end
11
- end
12
-
13
- include DecoratorHelpers
14
-
15
- def initialize(board, options = {})
16
- @board = board
17
- @options = options
18
- end
19
-
20
- def render_all
21
- puts board.decorator.title
22
-
23
- print_error "No lists were found." if lists.empty?
24
-
25
- print_lists
26
- end
27
-
28
- def show
29
- puts board.decorator.title
30
-
31
- print_error "No lists were found." if lists.empty?
32
-
33
- print_lists_with_cards
34
- end
35
-
36
- private
37
- attr_reader :board
38
-
39
- def print_lists_with_cards
40
- lists.each do |list|
41
- title_for(list)
42
-
43
- print_error "No cards were found." if list.cards.empty?
44
-
45
- list.cards(unformatted).each do |card|
46
- title_for(card)
47
- end
48
- end
49
- puts
50
- end
51
-
52
- def print_lists
53
- lists.each do |list|
54
- title_for(list)
55
- end
56
- puts
57
- end
58
-
59
- def lists
60
- board.decorator.lists
61
- end
62
-
63
- def unformatted
64
- {
65
- ansicolor: false,
66
- colour: nil,
67
- underline: nil
68
- }
69
- end
70
- end
71
- end
@@ -1,100 +0,0 @@
1
- module Troo
2
- class CardDecorator
3
- include DecoratorHelpers
4
-
5
- def initialize(card, options = {})
6
- @card = card
7
- @options = options
8
- end
9
-
10
- def short
11
- [default_str, id_str, name_str].join + "\n"
12
- end
13
-
14
- def name_str
15
- highlight(name, options)
16
- end
17
-
18
- def default_str
19
- default.center(3)
20
- end
21
-
22
- def id_str
23
- highlight(brackets(id) + " ", options).rjust(6)
24
- end
25
-
26
- def name
27
- (card.name && card.name.chomp) || "N/A"
28
- end
29
-
30
- def default
31
- card.default? ? "*" : ""
32
- end
33
-
34
- def id
35
- card.short_id
36
- end
37
-
38
- def description
39
- if card.desc.nil? || card.desc.empty?
40
- "There are no further details at this time."
41
- else
42
- word_wrap(card.desc)
43
- end
44
- end
45
-
46
- def comments
47
- if card.comments.any? && card.comments.size > 3
48
- message = "(There are more comments, use: 'troo show comments #{card.short_id}' to view all comments.)"
49
- [decorated_recent_comments, message].join("\n")
50
- elsif card.comments.any?
51
- decorated_all_comments
52
- else
53
- "No comments have been left."
54
- end
55
- end
56
-
57
- def members
58
- if card.members.any?
59
- MemberPresenter.new(card).show
60
- else
61
- "No members have been assigned."
62
- end
63
- end
64
-
65
- def last_activity_date
66
- Time.parse(card.last_activity_date).strftime("%a, %b %d at %H:%M")
67
- end
68
-
69
- def board
70
- card.board.decorator(options).short
71
- end
72
-
73
- def list
74
- card.list.decorator(options).short
75
- end
76
-
77
- private
78
- attr_reader :card
79
-
80
- def options
81
- defaults.merge!(@options)
82
- end
83
-
84
- def defaults
85
- {
86
- ansicolor: true,
87
- colour: Esc.magenta,
88
- underline: Esc.underline
89
- }
90
- end
91
-
92
- def decorated_recent_comments
93
- card.recent_comments.map { |comment| comment.decorator.as_view }.join
94
- end
95
-
96
- def decorated_all_comments
97
- card.comments.map { |comment| comment.decorator.as_view }.join
98
- end
99
- end
100
- end
@@ -1,27 +0,0 @@
1
- module Troo
2
- class CardPresenter
3
- class << self
4
- def show(card, options = {})
5
- new(card, options).show
6
- end
7
- end
8
-
9
- include DecoratorHelpers
10
-
11
- def initialize(card, options = {})
12
- @card = card
13
- @options = options
14
- end
15
-
16
- def show
17
- print Template.parse(decorated_card, "/../views/card.erb")
18
- end
19
-
20
- private
21
- attr_reader :card
22
-
23
- def decorated_card
24
- @decorated_card ||= card.decorator
25
- end
26
- end
27
- end
@@ -1,33 +0,0 @@
1
- module Troo
2
- class CommentDecorator
3
- include DecoratorHelpers
4
-
5
- def initialize(comment, options = {})
6
- @comment = comment
7
- @options = options
8
- end
9
-
10
- def as_view
11
- Template.parse(self, "/../views/comment.erb")
12
- end
13
-
14
- def member_username
15
- [comment.member.username, ":"].join
16
- end
17
-
18
- def text
19
- word_wrap(comment.text)
20
- end
21
-
22
- def date
23
- Time.parse(comment.date).strftime("%a, %b %d at %H:%M")
24
- end
25
-
26
- def id
27
- brackets(comment.id)
28
- end
29
-
30
- private
31
- attr_reader :comment
32
- end
33
- end
@@ -1,31 +0,0 @@
1
- module Troo
2
- class CommentPresenter
3
- class << self
4
- def show(card, options = {})
5
- new(card, options).show
6
- end
7
- end
8
-
9
- include DecoratorHelpers
10
-
11
- def initialize(card, options = {})
12
- @card = card
13
- @options = options
14
- end
15
-
16
- def show
17
- spacing do
18
- print card.decorator.short
19
-
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 }
24
- end
25
- end
26
- end
27
-
28
- private
29
- attr_reader :card
30
- end
31
- end