3llo 0.1.11 → 0.1.12

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: 1e7e2c44a64f8a1b7ce84549c9ecc8c65c7bf793
4
- data.tar.gz: bac8d528a87bc23510aefc254002392b3062de08
3
+ metadata.gz: 5e2baa0808c76ad5fa178cd90ce1c4f1297416d5
4
+ data.tar.gz: b77d48d5bb3d238bf16caf70c346f4b7d807aea7
5
5
  SHA512:
6
- metadata.gz: c8d31fcd43b99d64453d7a0fe3cb79f691316b5438641c3cff14e494a81fcb8e7167672193cceaff61e970ac6a2014de3cf9d63047b1c2b447cd8f445f21e44a
7
- data.tar.gz: 9b535ae6a132468c0d9c10372f65019d587836518cd2c5f4cd111c909165c744a5572c4d06cf21480b835dcc69d7d94f66d26f6f2ab6ecd694532ae6a4449993
6
+ metadata.gz: 30e67bcc4cf3db9489c9e6b6d545a6f3a5907b698770070fd552ed35c0e5d44846f1790a7f44ed548dec2888e38a93a5e3437302e45abffa2a9de955778072fb
7
+ data.tar.gz: 42735d92541c1c1a93df419f4cfdfd037e507641e1f515fe466026c31a599ba7afe741bedc0f4b7429ed18eacdf9be86bfe5cf110821db502b292b8fe65dd17d
File without changes
data/lib/3llo/api/card.rb CHANGED
@@ -58,6 +58,7 @@ module Tr3llo
58
58
  client.get(
59
59
  "/cards/#{card_id}",
60
60
  list: true,
61
+ members: true,
61
62
  key: api_key,
62
63
  token: api_token,
63
64
  ),
data/lib/3llo/api/user.rb CHANGED
@@ -16,6 +16,19 @@ module Tr3llo
16
16
  )
17
17
  end
18
18
 
19
+ def find_all_by_board(board_id)
20
+ url = "/board/#{board_id}/members"
21
+
22
+ JSON.parse(
23
+ client.get(
24
+ url,
25
+ key: key,
26
+ token: token
27
+ ),
28
+ symbolize_names: true
29
+ )
30
+ end
31
+
19
32
  private
20
33
 
21
34
  def key
@@ -10,11 +10,11 @@ module Tr3llo
10
10
  end
11
11
 
12
12
  def factory
13
- case subcommand.to_sym
14
- when :list
13
+ case subcommand
14
+ when 'list'
15
15
  user_id = $container.resolve(:user)[:id]
16
16
  Command::Board::ListCommand.new(user_id)
17
- when :select
17
+ when 'select'
18
18
  Command::Board::SelectCommand.new
19
19
  else
20
20
  Command::Board::InvalidCommand.new
@@ -3,6 +3,7 @@ require '3llo/commands/card/list_mine'
3
3
  require '3llo/commands/card/show'
4
4
  require '3llo/commands/card/move'
5
5
  require '3llo/commands/card/self_assign'
6
+ require '3llo/commands/card/assign'
6
7
  require '3llo/commands/card/invalid'
7
8
  require '3llo/commands/card/comments'
8
9
  require '3llo/commands/card/comment'
@@ -47,6 +48,10 @@ module Tr3llo
47
48
  card_id, _ = args
48
49
  user_id = $container.resolve(:user)[:id]
49
50
  Command::Card::SelfAssignCommand.new(card_id, user_id)
51
+ when 'assign'
52
+ card_id, _ = args
53
+ board_id = $container.resolve(:board)[:id]
54
+ Command::Card::AssignCommand.new(card_id, board_id)
50
55
  else
51
56
  Command::Card::InvalidCommand.new
52
57
  end
@@ -0,0 +1,45 @@
1
+ module Tr3llo
2
+ module Command
3
+ module Card
4
+ class AssignCommand
5
+ def initialize(card_id, board_id)
6
+ @card_id = card_id
7
+ @board_id = board_id
8
+ end
9
+
10
+ def execute
11
+ interface.print_frame do
12
+ user_id = prompt_for_user_id!(@board_id)
13
+ assign_card(user_id)
14
+ interface.puts("Card has been assigned.")
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ attr_reader :user_id, :card_id
21
+
22
+ def assign_card(user_id)
23
+ card = API::Card.find(card_id)
24
+ members = card[:idMembers] << user_id
25
+ API::Card.assign_members(card_id, members)
26
+ end
27
+
28
+ def prompt_for_user_id!(board_id)
29
+ board_id = $container.resolve(:board)[:id]
30
+ users = Tr3llo::API::User.find_all_by_board(board_id)
31
+
32
+ @user_id =
33
+ Tr3llo::Presenter::Card::AssignPresenter
34
+ .new(interface)
35
+ .prompt_for_user_id(users)
36
+ end
37
+
38
+ def interface
39
+ $container.resolve(:interface)
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+
@@ -21,6 +21,7 @@ module Tr3llo
21
21
  card show <card_id> - Show card information
22
22
  card move <card_id> - Move card to a list
23
23
  card self-assign <card_id> - Self-assign a card
24
+ card assign <card_id> - Assign a user to a card
24
25
  card comments <card_id> - Load recent comments of a card
25
26
  card comment <card_id> - Add a comment to a card
26
27
  }
@@ -10,11 +10,11 @@ module Tr3llo
10
10
  end
11
11
 
12
12
  def factory
13
- case subcommand.to_sym
14
- when :list
13
+ case subcommand
14
+ when 'list'
15
15
  board_id = $container.resolve(:board)[:id]
16
16
  Command::List::ListCommand.new(board_id)
17
- when :cards
17
+ when 'cards'
18
18
  list_id, _ = args
19
19
  Command::List::CardsCommand.new(list_id)
20
20
  else
@@ -5,5 +5,6 @@ require '3llo/presenter/card/list_mine'
5
5
  require '3llo/presenter/card/move'
6
6
  require '3llo/presenter/card/show'
7
7
  require '3llo/presenter/card/comments'
8
+ require '3llo/presenter/card/assign'
8
9
  require '3llo/presenter/list/list'
9
10
  require '3llo/presenter/list/cards'
@@ -0,0 +1,24 @@
1
+ module Tr3llo
2
+ module Presenter
3
+ module Card
4
+ class AssignPresenter
5
+ def initialize(interface)
6
+ @interface = interface
7
+ end
8
+
9
+ def prompt_for_user_id(users)
10
+ interface.input.select(
11
+ 'Choose the user to be assigned',
12
+ users.map { |user| [user[:username], user[:id]] }.to_h
13
+ )
14
+ end
15
+
16
+ private
17
+
18
+ attr_reader :interface
19
+
20
+ end
21
+ end
22
+ end
23
+ end
24
+
@@ -37,11 +37,15 @@ module Tr3llo
37
37
  subscribed_str = "[ ]"
38
38
  end
39
39
 
40
- interface.puts "#{subscribed_str} #{card[:id].labelize}] - #{card[:name]} (#{label_str}) [#{members_str}]"
40
+ interface.puts "[#{subscribed_str} #{card[:id].labelize}] - #{card[:name]} (#{label_str}) [#{members_str}]"
41
41
  end
42
42
 
43
43
  def colorize_label(label)
44
- "##{label[:name]}".paint(label[:color])
44
+ if label[:color]
45
+ "##{label[:name]}".paint(label[:color])
46
+ else
47
+ "##{label[:name]}"
48
+ end
45
49
  end
46
50
  end
47
51
  end
@@ -21,6 +21,12 @@ module Tr3llo
21
21
  label_str = ''
22
22
  end
23
23
 
24
+ if card.has_key?(:members)
25
+ member_str = card[:members].map { |member| member[:username] }.join(", ")
26
+ else
27
+ member_str = ''
28
+ end
29
+
24
30
  interface.puts(
25
31
  "ID: ".labelize + card[:id] + "\n" +
26
32
  "Name: ".labelize + card[:name] + " (#{label_str})" "\n" +
@@ -29,12 +35,18 @@ module Tr3llo
29
35
  "Subscribed: ".labelize + (card[:badges][:subscribed] ? "Yes" : "No") + "\n" +
30
36
  "Comments: ".labelize + card[:badges][:comments].to_s + "\n" +
31
37
  "Attachments: ".labelize + card[:badges][:attachments].to_s + "\n" +
32
- "Link: ".labelize + card[:shortUrl] + "\n"
38
+ "Link: ".labelize + card[:shortUrl] + "\n" +
39
+ "Labes: ".labelize + label_str + "\n" +
40
+ "Members: ".labelize + member_str + "\n"
33
41
  )
34
42
  end
35
43
 
36
44
  def colorize_label(label)
37
- "##{label[:name]}".paint(label[:color])
45
+ if label[:color]
46
+ "##{label[:name]}".paint(label[:color])
47
+ else
48
+ "##{label[:name]}"
49
+ end
38
50
  end
39
51
  end
40
52
  end
@@ -28,6 +28,7 @@ module Tr3llo
28
28
  card show <card_id> - Show card information
29
29
  card move <card_id> - Move card to a list
30
30
  card self-assign <card_id> - Self-assign a card
31
+ card assign <card_id> - Assign a user to a card
31
32
  card comments <card_id> - Load recent comments of a card
32
33
  card comment <card_id> - Add a comment to a card
33
34
  list list - Show all lists
@@ -33,7 +33,11 @@ module Tr3llo
33
33
  end
34
34
 
35
35
  def colorize_label(label)
36
- "##{label[:name]}".paint(label[:color])
36
+ if label[:color]
37
+ "##{label[:name]}".paint(label[:color])
38
+ else
39
+ "##{label[:name]}"
40
+ end
37
41
  end
38
42
  end
39
43
  end
data/lib/3llo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tr3llo
2
- VERSION = "0.1.11"
2
+ VERSION = "0.1.12"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: 3llo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
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: 2017-09-25 00:00:00.000000000 Z
11
+ date: 2018-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-prompt
@@ -37,7 +37,7 @@ files:
37
37
  - 3llo.gemspec
38
38
  - CODE_OF_CONDUCT.md
39
39
  - Gemfile
40
- - LICENSE.txt
40
+ - LICENSE.md
41
41
  - README.md
42
42
  - Rakefile
43
43
  - bin/3llo
@@ -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/assign.rb
59
60
  - lib/3llo/commands/card/comment.rb
60
61
  - lib/3llo/commands/card/comments.rb
61
62
  - lib/3llo/commands/card/invalid.rb
@@ -79,6 +80,7 @@ files:
79
80
  - lib/3llo/presenter.rb
80
81
  - lib/3llo/presenter/.gitkeep
81
82
  - lib/3llo/presenter/board/list.rb
83
+ - lib/3llo/presenter/card/assign.rb
82
84
  - lib/3llo/presenter/card/comments.rb
83
85
  - lib/3llo/presenter/card/list.rb
84
86
  - lib/3llo/presenter/card/list_mine.rb
@@ -111,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
113
  version: '0'
112
114
  requirements: []
113
115
  rubyforge_project:
114
- rubygems_version: 2.5.2
116
+ rubygems_version: 2.5.1
115
117
  signing_key:
116
118
  specification_version: 4
117
119
  summary: Trello CLI