3llo 0.1.12 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e2baa0808c76ad5fa178cd90ce1c4f1297416d5
4
- data.tar.gz: b77d48d5bb3d238bf16caf70c346f4b7d807aea7
3
+ metadata.gz: 7e700e928448190099e127af4aa5286e9088d983
4
+ data.tar.gz: 6ef4c1f9b9ae424e7696e4d30398f7bc63319301
5
5
  SHA512:
6
- metadata.gz: 30e67bcc4cf3db9489c9e6b6d545a6f3a5907b698770070fd552ed35c0e5d44846f1790a7f44ed548dec2888e38a93a5e3437302e45abffa2a9de955778072fb
7
- data.tar.gz: 42735d92541c1c1a93df419f4cfdfd037e507641e1f515fe466026c31a599ba7afe741bedc0f4b7429ed18eacdf9be86bfe5cf110821db502b292b8fe65dd17d
6
+ metadata.gz: 42007554dd4936601e24e55b616d2b77fe0ff8e14823816923902a4d73290bc12e82d7f7bb78556f478b5dd1b0494bc0e41335ab5e25a7be08f45ca74e742406
7
+ data.tar.gz: 0959136caad56c2ff684d4e6fc5114d8ad66c317febcad2da6bcf9877f82a571015ce8a4053a9a0c91c53a06c9503066fc07856c165df0090c0678d980683398
data/README.md CHANGED
@@ -47,7 +47,9 @@ There are a couple of commands available in 3llo.
47
47
  * `card self-assign <card_id>`: Self-assign a card.
48
48
  * `card comments <card_id>`: Show recent comments of a card.
49
49
  * `card comment <card_id>`: Add a comment to a card.
50
+ * `card archive <card_id>`: Archive a card.
50
51
  * `list list`: List all the lists of the active board.
52
+ * `list archive-cards <list_id>`: Archives all the cards on the specified list.
51
53
  * `help`: Show help menu.
52
54
  * `exit`: Exit.
53
55
 
@@ -118,6 +118,18 @@ module Tr3llo
118
118
  )
119
119
  end
120
120
 
121
+ def archive(card_id)
122
+ url = "/cards/#{card_id}?closed=true"
123
+ JSON.parse(
124
+ client.put(
125
+ url,
126
+ key: api_key,
127
+ token: api_token
128
+ ),
129
+ symbolize_names: true
130
+ )
131
+ end
132
+
121
133
  private
122
134
 
123
135
  def api_key
@@ -15,6 +15,17 @@ module Tr3llo
15
15
  )
16
16
  end
17
17
 
18
+ def archive_cards(list_id)
19
+ JSON.parse(
20
+ client.post(
21
+ "/lists/#{list_id}/archiveAllCards",
22
+ key: api_key,
23
+ token: api_token
24
+ ),
25
+ symbolize_names: true
26
+ )
27
+ end
28
+
18
29
  private
19
30
 
20
31
  def client
@@ -8,6 +8,7 @@ require '3llo/commands/card/invalid'
8
8
  require '3llo/commands/card/comments'
9
9
  require '3llo/commands/card/comment'
10
10
  require '3llo/commands/card/add'
11
+ require '3llo/commands/card/archive'
11
12
 
12
13
  module Tr3llo
13
14
  class CardCommandFactory
@@ -52,6 +53,9 @@ module Tr3llo
52
53
  card_id, _ = args
53
54
  board_id = $container.resolve(:board)[:id]
54
55
  Command::Card::AssignCommand.new(card_id, board_id)
56
+ when 'archive'
57
+ card_id, _ = args
58
+ Command::Card::ArchiveCommand.new(card_id)
55
59
  else
56
60
  Command::Card::InvalidCommand.new
57
61
  end
@@ -26,7 +26,6 @@ module Tr3llo
26
26
 
27
27
  http = Net::HTTP.new(uri.host, uri.port)
28
28
  http.use_ssl = true
29
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
30
29
  request = Net::HTTP::Get.new(uri.request_uri)
31
30
 
32
31
  res = http.request(request)
@@ -42,9 +41,12 @@ module Tr3llo
42
41
 
43
42
  http = Net::HTTP.new(uri.host, uri.port)
44
43
  http.use_ssl = true
45
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
46
- request = Net::HTTP::Post.new(uri.request_uri, 'Content-Type' => 'application/json')
47
- request.body = params.to_json
44
+ req_headers = {
45
+ 'Accept' => 'application/json',
46
+ 'Content-Type' => 'application/json',
47
+ }
48
+ request = Net::HTTP::Post.new(uri.request_uri, req_headers)
49
+ request.body = JSON.dump(params)
48
50
 
49
51
  res = http.request(request)
50
52
 
@@ -55,12 +57,16 @@ module Tr3llo
55
57
  end
56
58
 
57
59
  def put(path, params)
58
- uri = URI("#{BASE_URL}#{path}?#{query_string(params)}")
60
+ uri = URI("#{BASE_URL}#{path}")
59
61
 
60
62
  http = Net::HTTP.new(uri.host, uri.port)
61
63
  http.use_ssl = true
62
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
63
- request = Net::HTTP::Put.new(uri.request_uri)
64
+ req_headers = {
65
+ 'Accept' => 'application/json',
66
+ 'Content-Type' => 'application/json',
67
+ }
68
+ request = Net::HTTP::Put.new(uri.request_uri, req_headers)
69
+ request.body = JSON.dump(params)
64
70
 
65
71
  res = http.request(request)
66
72
 
@@ -0,0 +1,31 @@
1
+ module Tr3llo
2
+ module Command
3
+ module Card
4
+ class ArchiveCommand
5
+ def initialize(card_id)
6
+ @card_id = card_id
7
+ end
8
+
9
+ def execute
10
+ interface.print_frame do
11
+ archive_card
12
+ interface.puts("Card has been archived.")
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ attr_reader :card_id
19
+
20
+ def archive_card
21
+ card = API::Card.find(card_id)
22
+ API::Card.archive(card_id)
23
+ end
24
+
25
+ def interface
26
+ $container.resolve(:interface)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -24,6 +24,7 @@ module Tr3llo
24
24
  card assign <card_id> - Assign a user to a card
25
25
  card comments <card_id> - Load recent comments of a card
26
26
  card comment <card_id> - Add a comment to a card
27
+ card archive <card_id> - Archive a card
27
28
  }
28
29
  end
29
30
 
@@ -0,0 +1,39 @@
1
+ module Tr3llo
2
+ module Command
3
+ module List
4
+ class ArchiveCardsCommand
5
+ def initialize(list_id)
6
+ @list_id = list_id
7
+ end
8
+
9
+ def execute
10
+ interface.print_frame do
11
+ approved = prompt_for_approvement!
12
+ if approved
13
+ archive_cards
14
+ interface.puts("Cards have been archived.")
15
+ end
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ attr_reader :list_id
22
+
23
+ def prompt_for_approvement!
24
+ Tr3llo::Presenter::ConfirmationPresenter
25
+ .new(interface)
26
+ .prompt_for_confirmation('Are you sure you want to archive all cards?')
27
+ end
28
+
29
+ def archive_cards
30
+ API::List.archive_cards(list_id)
31
+ end
32
+
33
+ def interface
34
+ $container.resolve(:interface)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -17,6 +17,7 @@ module Tr3llo
17
17
 
18
18
  list list - Show all lists
19
19
  list cards <list_id> - Show all cards in list
20
+ list archive-cards <list_id> - Archive all cards in list
20
21
  }
21
22
  end
22
23
 
@@ -1,6 +1,7 @@
1
1
  require '3llo/commands/list/list'
2
2
  require '3llo/commands/list/cards'
3
3
  require '3llo/commands/list/invalid'
4
+ require '3llo/commands/list/archive_cards'
4
5
 
5
6
  module Tr3llo
6
7
  class ListCommandFactory
@@ -17,6 +18,9 @@ module Tr3llo
17
18
  when 'cards'
18
19
  list_id, _ = args
19
20
  Command::List::CardsCommand.new(list_id)
21
+ when 'archive-cards'
22
+ list_id, _ = args
23
+ Command::List::ArchiveCardsCommand.new(list_id)
20
24
  else
21
25
  Command::List::InvalidCommand.new
22
26
  end
@@ -8,3 +8,4 @@ require '3llo/presenter/card/comments'
8
8
  require '3llo/presenter/card/assign'
9
9
  require '3llo/presenter/list/list'
10
10
  require '3llo/presenter/list/cards'
11
+ require '3llo/presenter/confirmation'
@@ -0,0 +1,18 @@
1
+ module Tr3llo
2
+ module Presenter
3
+ class ConfirmationPresenter
4
+ def initialize(interface)
5
+ @interface = interface
6
+ end
7
+
8
+ def prompt_for_confirmation(message)
9
+ answer = interface.input.select(message, ['No', 'Yes'])
10
+ answer == 'Yes' ? true : false
11
+ end
12
+
13
+ private
14
+
15
+ attr_reader :interface
16
+ end
17
+ end
18
+ end
@@ -20,21 +20,23 @@ module Tr3llo
20
20
  3llo - CLI for Trello
21
21
 
22
22
  Usage:
23
- board list - Show list of board
24
- board select - Select board
25
- card list - Show list of cards grouped by list
26
- card list mine - Show list of my cards
27
- card add - Create a card
28
- card show <card_id> - Show card information
29
- card move <card_id> - Move card to a list
30
- card self-assign <card_id> - Self-assign a card
31
- card assign <card_id> - Assign a user to a card
32
- card comments <card_id> - Load recent comments of a card
33
- card comment <card_id> - Add a comment to a card
34
- list list - Show all lists
35
- list cards <list_id> - Show all cards in list
36
- help - Show help menu
37
- exit - Exit program
23
+ board list - Show list of board
24
+ board select - Select board
25
+ card list - Show list of cards grouped by list
26
+ card list mine - Show list of my cards
27
+ card add - Create a card
28
+ card show <card_id> - Show card information
29
+ card move <card_id> - Move card to a list
30
+ card self-assign <card_id> - Self-assign a card
31
+ card assign <card_id> - Assign a user to a card
32
+ card comments <card_id> - Load recent comments of a card
33
+ card comment <card_id> - Add a comment to a card
34
+ card archive <card_id> - Archive a card
35
+ list list - Show all lists
36
+ list cards <list_id> - Show all cards in list
37
+ list archive-cards <list_id> - Archive all cards in list
38
+ help - Show help menu
39
+ exit - Exit program
38
40
  }
39
41
  end
40
42
  end
@@ -1,3 +1,3 @@
1
1
  module Tr3llo
2
- VERSION = "0.1.12"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: 3llo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cẩm Huỳnh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-21 00:00:00.000000000 Z
11
+ date: 2018-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-prompt
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.11.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.11.0
27
27
  description: CLI for Trello
@@ -32,8 +32,8 @@ executables:
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
- - ".gitignore"
36
- - ".travis.yml"
35
+ - .gitignore
36
+ - .travis.yml
37
37
  - 3llo.gemspec
38
38
  - CODE_OF_CONDUCT.md
39
39
  - Gemfile
@@ -56,6 +56,7 @@ files:
56
56
  - lib/3llo/commands/board/list.rb
57
57
  - lib/3llo/commands/board/select.rb
58
58
  - lib/3llo/commands/card/add.rb
59
+ - lib/3llo/commands/card/archive.rb
59
60
  - lib/3llo/commands/card/assign.rb
60
61
  - lib/3llo/commands/card/comment.rb
61
62
  - lib/3llo/commands/card/comments.rb
@@ -69,6 +70,7 @@ files:
69
70
  - lib/3llo/commands/exit.rb
70
71
  - lib/3llo/commands/help.rb
71
72
  - lib/3llo/commands/invalid.rb
73
+ - lib/3llo/commands/list/archive_cards.rb
72
74
  - lib/3llo/commands/list/cards.rb
73
75
  - lib/3llo/commands/list/invalid.rb
74
76
  - lib/3llo/commands/list/list.rb
@@ -86,6 +88,7 @@ files:
86
88
  - lib/3llo/presenter/card/list_mine.rb
87
89
  - lib/3llo/presenter/card/move.rb
88
90
  - lib/3llo/presenter/card/show.rb
91
+ - lib/3llo/presenter/confirmation.rb
89
92
  - lib/3llo/presenter/help.rb
90
93
  - lib/3llo/presenter/list/cards.rb
91
94
  - lib/3llo/presenter/list/list.rb
@@ -103,17 +106,17 @@ require_paths:
103
106
  - lib
104
107
  required_ruby_version: !ruby/object:Gem::Requirement
105
108
  requirements:
106
- - - ">="
109
+ - - '>='
107
110
  - !ruby/object:Gem::Version
108
111
  version: '0'
109
112
  required_rubygems_version: !ruby/object:Gem::Requirement
110
113
  requirements:
111
- - - ">="
114
+ - - '>='
112
115
  - !ruby/object:Gem::Version
113
116
  version: '0'
114
117
  requirements: []
115
118
  rubyforge_project:
116
- rubygems_version: 2.5.1
119
+ rubygems_version: 2.0.14.1
117
120
  signing_key:
118
121
  specification_version: 4
119
122
  summary: Trello CLI