3llo 0.1.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 (56) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.travis.yml +5 -0
  4. data/3llo.gemspec +29 -0
  5. data/CODE_OF_CONDUCT.md +49 -0
  6. data/Gemfile +7 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +58 -0
  9. data/Rakefile +10 -0
  10. data/bin/3llo +29 -0
  11. data/lib/3llo/api/board.rb +47 -0
  12. data/lib/3llo/api/card.rb +93 -0
  13. data/lib/3llo/api/list.rb +37 -0
  14. data/lib/3llo/api/user.rb +34 -0
  15. data/lib/3llo/api.rb +4 -0
  16. data/lib/3llo/board_command_factory.rb +29 -0
  17. data/lib/3llo/card_command_factory.rb +49 -0
  18. data/lib/3llo/client.rb +62 -0
  19. data/lib/3llo/command_factory.rb +40 -0
  20. data/lib/3llo/commands/.gitkeep +0 -0
  21. data/lib/3llo/commands/board/invalid.rb +33 -0
  22. data/lib/3llo/commands/board/list.rb +29 -0
  23. data/lib/3llo/commands/board/select.rb +31 -0
  24. data/lib/3llo/commands/card/invalid.rb +36 -0
  25. data/lib/3llo/commands/card/list.rb +37 -0
  26. data/lib/3llo/commands/card/list_mine.rb +30 -0
  27. data/lib/3llo/commands/card/move.rb +43 -0
  28. data/lib/3llo/commands/card/self_assign.rb +31 -0
  29. data/lib/3llo/commands/card/show.rb +29 -0
  30. data/lib/3llo/commands/error.rb +18 -0
  31. data/lib/3llo/commands/exit.rb +16 -0
  32. data/lib/3llo/commands/help.rb +15 -0
  33. data/lib/3llo/commands/invalid.rb +18 -0
  34. data/lib/3llo/commands/list/cards.rb +29 -0
  35. data/lib/3llo/commands/list/invalid.rb +33 -0
  36. data/lib/3llo/commands/list/list.rb +29 -0
  37. data/lib/3llo/configuration.rb +39 -0
  38. data/lib/3llo/controller.rb +35 -0
  39. data/lib/3llo/errors.rb +7 -0
  40. data/lib/3llo/interface.rb +30 -0
  41. data/lib/3llo/list_command_factory.rb +29 -0
  42. data/lib/3llo/presenter/.gitkeep +0 -0
  43. data/lib/3llo/presenter/board/list.rb +25 -0
  44. data/lib/3llo/presenter/card/list.rb +43 -0
  45. data/lib/3llo/presenter/card/list_mine.rb +25 -0
  46. data/lib/3llo/presenter/card/move.rb +25 -0
  47. data/lib/3llo/presenter/card/show.rb +39 -0
  48. data/lib/3llo/presenter/help.rb +38 -0
  49. data/lib/3llo/presenter/list/cards.rb +41 -0
  50. data/lib/3llo/presenter/list/list.rb +25 -0
  51. data/lib/3llo/presenter.rb +8 -0
  52. data/lib/3llo/version.rb +3 -0
  53. data/lib/3llo.rb +14 -0
  54. data/lib/container.rb +24 -0
  55. data/lib/core_ext.rb +41 -0
  56. metadata +100 -0
@@ -0,0 +1,25 @@
1
+ module Tr3llo
2
+ module Presenter
3
+ module Card
4
+ class MovePresenter
5
+ def initialize(interface)
6
+ @interface = interface
7
+ end
8
+
9
+ def prompt_for_list_id(lists)
10
+ interface.puts("List of lists in this board")
11
+ lists.each(&method(:present_list))
12
+ interface.prompt("Select list ID")
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :interface
18
+
19
+ def present_list(list)
20
+ interface.puts "[#{list[:id].labelize}] - #{list[:name]}"
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,39 @@
1
+ module Tr3llo
2
+ module Presenter
3
+ module Card
4
+ class ShowPresenter
5
+ def initialize(interface)
6
+ @interface = interface
7
+ end
8
+
9
+ def print!(card)
10
+ interface.print_frame { present_card(card) }
11
+ end
12
+
13
+ private
14
+
15
+ attr_reader :interface
16
+
17
+ def present_card(card)
18
+ if card.has_key?(:labels)
19
+ label_str = card[:labels].map { |label| colorize_label(label) }.join(", ")
20
+ else
21
+ label_str = ''
22
+ end
23
+
24
+ interface.puts(
25
+ "ID: ".labelize + card[:id] + "\n" +
26
+ "Name: ".labelize + card[:name] + " (#{label_str})" "\n" +
27
+ "Description: ".labelize + card[:desc] + "\n" +
28
+ "List: ".labelize + card[:list][:name] + "\n" +
29
+ "Link: ".labelize + card[:shortUrl] + "\n"
30
+ )
31
+ end
32
+
33
+ def colorize_label(label)
34
+ "##{label[:name]}".paint(label[:color])
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,38 @@
1
+ module Tr3llo
2
+ module Presenter
3
+ class HelpPresenter
4
+ def initialize(interface)
5
+ @interface = interface
6
+ end
7
+
8
+ def print!
9
+ interface.print_frame do
10
+ interface.puts menu_text
11
+ end
12
+ end
13
+
14
+ private
15
+
16
+ attr_reader :interface
17
+
18
+ def menu_text
19
+ %q{
20
+ 3llo - CLI for Trello
21
+
22
+ Usage:
23
+ board list - Show list of board
24
+ board select <board_id> - Select board
25
+ card list - Show list of cards grouped by list
26
+ card list mine - Show list of my cards
27
+ card show <card_id> - Show card information
28
+ card move <card_id> <list_id> - Move card to a list
29
+ card self-assign <card_id> - Self-assign a card
30
+ list list - Show all lists
31
+ list cards <list_id> - Show all cards in list
32
+ help - Show help menu
33
+ exit - Exit program
34
+ }
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,41 @@
1
+ module Tr3llo
2
+ module Presenter
3
+ module List
4
+ class CardsPresenter
5
+ def initialize(interface)
6
+ @interface = interface
7
+ end
8
+
9
+ def print!(cards)
10
+ interface.print_frame do
11
+ cards.each { |card| present_card(card) }
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :interface
18
+
19
+ def present_card(card)
20
+ if card.has_key?(:labels)
21
+ label_str = card[:labels].map { |label| colorize_label(label) }.join(", ")
22
+ else
23
+ label_str = ''
24
+ end
25
+
26
+ if card[:subscribed]
27
+ subscribed_str = "[✓]"
28
+ else
29
+ subscribed_str = "[ ]"
30
+ end
31
+
32
+ interface.puts "#{subscribed_str} #{card[:id].labelize}] - #{card[:name]} (#{label_str})"
33
+ end
34
+
35
+ def colorize_label(label)
36
+ "##{label[:name]}".paint(label[:color])
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,25 @@
1
+ module Tr3llo
2
+ module Presenter
3
+ module List
4
+ class ListPresenter
5
+ def initialize(interface)
6
+ @interface = interface
7
+ end
8
+
9
+ def print!(lists)
10
+ interface.print_frame do
11
+ lists.each { |list| present_list(list) }
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ attr_reader :interface
18
+
19
+ def present_list(list)
20
+ interface.puts "[#{list[:id].labelize}] - #{list[:name]}"
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,8 @@
1
+ require '3llo/presenter/help'
2
+ require '3llo/presenter/board/list'
3
+ require '3llo/presenter/card/list'
4
+ require '3llo/presenter/card/list_mine'
5
+ require '3llo/presenter/card/move'
6
+ require '3llo/presenter/card/show'
7
+ require '3llo/presenter/list/list'
8
+ require '3llo/presenter/list/cards'
@@ -0,0 +1,3 @@
1
+ module Tr3llo
2
+ VERSION = "0.1.8"
3
+ end
data/lib/3llo.rb ADDED
@@ -0,0 +1,14 @@
1
+ require "core_ext"
2
+ require "3llo/version"
3
+ require "3llo/client"
4
+ require "3llo/presenter"
5
+ require "3llo/interface"
6
+ require 'container'
7
+ require 'json'
8
+
9
+ require '3llo/configuration'
10
+ require '3llo/controller'
11
+ require '3llo/errors'
12
+ require '3llo/api'
13
+ require '3llo/presenter'
14
+ require '3llo/command_factory'
data/lib/container.rb ADDED
@@ -0,0 +1,24 @@
1
+ class Container
2
+ class KeyNotFoundError < ::KeyError
3
+ attr_reader :key
4
+
5
+ def initialize(key)
6
+ @key = key
7
+ super
8
+ end
9
+ end
10
+
11
+ def initialize
12
+ @data = {}
13
+ end
14
+
15
+ def resolve(key)
16
+ @data.fetch(key)
17
+ rescue ::KeyError
18
+ raise KeyNotFoundError.new(key)
19
+ end
20
+
21
+ def register(key, value)
22
+ @data[key] = value
23
+ end
24
+ end
data/lib/core_ext.rb ADDED
@@ -0,0 +1,41 @@
1
+ class String
2
+ COLOR = {
3
+ red: 31,
4
+ blue: 34,
5
+ green: 32,
6
+ black: 37,
7
+ purple: 35,
8
+ yellow: 33,
9
+ orange: 33
10
+ }.freeze
11
+
12
+ def colorize(*code)
13
+ "\e[#{code.join(";")}m#{self}\e[0m"
14
+ end
15
+
16
+ def labelize(*code)
17
+ colorize(93)
18
+ end
19
+
20
+ COLOR.each_pair do |color, code|
21
+ define_method(color) do
22
+ colorize(code)
23
+ end
24
+ end
25
+
26
+ def paint(color)
27
+ if respond_to?(color.to_sym)
28
+ public_send(color)
29
+ else
30
+ self
31
+ end
32
+ end
33
+
34
+ def short
35
+ if self.size > 50
36
+ self.truncate(50) + "..."
37
+ else
38
+ self
39
+ end
40
+ end
41
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: 3llo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.8
5
+ platform: ruby
6
+ authors:
7
+ - Cẩm Huỳnh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-02 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: CLI for Trello
14
+ email:
15
+ - huynhquancam@gmail.com
16
+ executables:
17
+ - 3llo
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".gitignore"
22
+ - ".travis.yml"
23
+ - 3llo.gemspec
24
+ - CODE_OF_CONDUCT.md
25
+ - Gemfile
26
+ - LICENSE.txt
27
+ - README.md
28
+ - Rakefile
29
+ - bin/3llo
30
+ - lib/3llo.rb
31
+ - lib/3llo/api.rb
32
+ - lib/3llo/api/board.rb
33
+ - lib/3llo/api/card.rb
34
+ - lib/3llo/api/list.rb
35
+ - lib/3llo/api/user.rb
36
+ - lib/3llo/board_command_factory.rb
37
+ - lib/3llo/card_command_factory.rb
38
+ - lib/3llo/client.rb
39
+ - lib/3llo/command_factory.rb
40
+ - lib/3llo/commands/.gitkeep
41
+ - lib/3llo/commands/board/invalid.rb
42
+ - lib/3llo/commands/board/list.rb
43
+ - lib/3llo/commands/board/select.rb
44
+ - lib/3llo/commands/card/invalid.rb
45
+ - lib/3llo/commands/card/list.rb
46
+ - lib/3llo/commands/card/list_mine.rb
47
+ - lib/3llo/commands/card/move.rb
48
+ - lib/3llo/commands/card/self_assign.rb
49
+ - lib/3llo/commands/card/show.rb
50
+ - lib/3llo/commands/error.rb
51
+ - lib/3llo/commands/exit.rb
52
+ - lib/3llo/commands/help.rb
53
+ - lib/3llo/commands/invalid.rb
54
+ - lib/3llo/commands/list/cards.rb
55
+ - lib/3llo/commands/list/invalid.rb
56
+ - lib/3llo/commands/list/list.rb
57
+ - lib/3llo/configuration.rb
58
+ - lib/3llo/controller.rb
59
+ - lib/3llo/errors.rb
60
+ - lib/3llo/interface.rb
61
+ - lib/3llo/list_command_factory.rb
62
+ - lib/3llo/presenter.rb
63
+ - lib/3llo/presenter/.gitkeep
64
+ - lib/3llo/presenter/board/list.rb
65
+ - lib/3llo/presenter/card/list.rb
66
+ - lib/3llo/presenter/card/list_mine.rb
67
+ - lib/3llo/presenter/card/move.rb
68
+ - lib/3llo/presenter/card/show.rb
69
+ - lib/3llo/presenter/help.rb
70
+ - lib/3llo/presenter/list/cards.rb
71
+ - lib/3llo/presenter/list/list.rb
72
+ - lib/3llo/version.rb
73
+ - lib/container.rb
74
+ - lib/core_ext.rb
75
+ homepage: https://github.com/qcam/3llo
76
+ licenses:
77
+ - MIT
78
+ metadata:
79
+ allowed_push_host: https://rubygems.org
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.4.5
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Trello CLI
100
+ test_files: []