slack_trello 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/slack_trello.rb +1 -0
- data/lib/slack_trello/copy_cards.rb +2 -2
- data/lib/slack_trello/copy_cards_command.rb +70 -0
- data/lib/slack_trello/create_card_command.rb +1 -6
- data/lib/slack_trello/create_trello_card.rb +11 -6
- data/lib/slack_trello/retro_command.rb +1 -6
- data/lib/slack_trello/trello_lookup.rb +9 -2
- data/lib/slack_trello/version.rb +1 -1
- data/lib/slack_trello/work_command.rb +1 -6
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c412d076e38c5e27813959ae64e1db1c0daeb607
|
4
|
+
data.tar.gz: e714b20fe5e54749f90f046b84cf76b5fa272b51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 173e23b8b2c3f2384dbad5cef280f64c99a69bc81645510f38b071952528290424bc32c2696f119065fecacac42e4e99bad9b49c3f645da0c1e40d9784a4726d
|
7
|
+
data.tar.gz: 53b536445db574c7352d456a1c258c8a2fbc3f221a2608c499e58521e81c2d1d4571480c68336595b1bbdab0c565458e956321cb43606f834b8a1e0d058b1171
|
data/lib/slack_trello.rb
CHANGED
@@ -10,6 +10,7 @@ require "slack_trello/create_trello_card"
|
|
10
10
|
require "slack_trello/copy_cards"
|
11
11
|
require "slack_trello/speaker"
|
12
12
|
|
13
|
+
require "slack_trello/copy_cards_command"
|
13
14
|
require "slack_trello/create_card_command"
|
14
15
|
require "slack_trello/work_command"
|
15
16
|
require "slack_trello/retro_command"
|
@@ -11,8 +11,8 @@ module SlackTrello; class CopyCards
|
|
11
11
|
|
12
12
|
def run
|
13
13
|
source_cards.each do |source_card|
|
14
|
-
creator = CreateTrelloCard.new(destination_board, destination_list, source_card.name)
|
15
|
-
creator.
|
14
|
+
creator = CreateTrelloCard.new(board_name: destination_board, list_name: destination_list, card_name: source_card.name)
|
15
|
+
creator.first_or_create
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module SlackTrello; class CopyCardsCommand
|
2
|
+
|
3
|
+
include TextParser
|
4
|
+
|
5
|
+
attr_reader :parser, :webhook_url
|
6
|
+
|
7
|
+
def initialize(args, webhook_url)
|
8
|
+
@parser = ResponseParser.new(args)
|
9
|
+
@webhook_url = webhook_url
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
return help_message unless valid_text_format?
|
14
|
+
return help_message unless num_args == 4
|
15
|
+
|
16
|
+
card_copier.run
|
17
|
+
speaker.speak success_message
|
18
|
+
"You should see a notification with a link. If not, the card might not have been created."
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def help_message
|
24
|
+
%{:cry: Invalid format
|
25
|
+
Your message: #{parser.text}
|
26
|
+
Example: /copy_cards (source_board, source_list, destination_board, destination_list)
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def speaker
|
31
|
+
args = {
|
32
|
+
webhook_url: webhook_url,
|
33
|
+
channel: parser.channel_name,
|
34
|
+
username: parser.user_name
|
35
|
+
}
|
36
|
+
Speaker.new(args)
|
37
|
+
end
|
38
|
+
|
39
|
+
def card_copier
|
40
|
+
args = {
|
41
|
+
source_board_name: source_board_name,
|
42
|
+
source_list_name: source_list_name,
|
43
|
+
destination_board_name: destination_board_name,
|
44
|
+
destination_list_name: destination_list_name
|
45
|
+
}
|
46
|
+
@card_copier ||= CardCopier.new(args)
|
47
|
+
end
|
48
|
+
|
49
|
+
def source_board_name
|
50
|
+
args[0]
|
51
|
+
end
|
52
|
+
|
53
|
+
def source_list_name
|
54
|
+
args[1]
|
55
|
+
end
|
56
|
+
|
57
|
+
def destination_board_name
|
58
|
+
args[2]
|
59
|
+
end
|
60
|
+
|
61
|
+
def destination_list_name
|
62
|
+
args[3]
|
63
|
+
end
|
64
|
+
|
65
|
+
def success_message
|
66
|
+
":mega: [#{parser.user_name}] has copied all the cards from the #{source_list_name} of the #{source_board_name} to the #{destination_list_name} of the #{destination_board_name}"
|
67
|
+
end
|
68
|
+
|
69
|
+
end; end
|
70
|
+
|
@@ -12,7 +12,6 @@ module SlackTrello; class CreateCardCommand
|
|
12
12
|
def run
|
13
13
|
return help_message unless valid_text_format?
|
14
14
|
return help_message unless num_args == 2
|
15
|
-
return board_not_found_message unless trello_card_creator.trello_board
|
16
15
|
return list_not_found_message unless trello_card_creator.trello_list
|
17
16
|
|
18
17
|
trello_card
|
@@ -50,7 +49,7 @@ For example, Some Board Name => some_board_name
|
|
50
49
|
end
|
51
50
|
|
52
51
|
def trello_card
|
53
|
-
trello_card_creator.
|
52
|
+
@card ||= trello_card_creator.first_or_create
|
54
53
|
end
|
55
54
|
|
56
55
|
def trello_board_name
|
@@ -61,10 +60,6 @@ For example, Some Board Name => some_board_name
|
|
61
60
|
args[1]
|
62
61
|
end
|
63
62
|
|
64
|
-
def board_not_found_message
|
65
|
-
"A Trello board named '#{trello_board_name}' must be created and the Trello user in the codebase must be added to the board for this command to function for this Slack room."
|
66
|
-
end
|
67
|
-
|
68
63
|
def list_not_found_message
|
69
64
|
"A Trello list named #{trello_list_name} must be added to the '#{trello_board_name}' board for this command to function."
|
70
65
|
end
|
@@ -8,12 +8,17 @@ module SlackTrello; class CreateTrelloCard
|
|
8
8
|
@card_name = args.fetch(:card_name)
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
def first_or_create
|
12
|
+
card = TrelloLookup.card(board_name, list_name, card_name)
|
13
|
+
return card if card
|
14
|
+
create_card
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_card
|
18
|
+
card = Trello::Card.new
|
19
|
+
card.name = card_name
|
20
|
+
card.list_id = trello_list.id
|
21
|
+
card.save
|
17
22
|
end
|
18
23
|
|
19
24
|
def trello_list
|
@@ -12,7 +12,6 @@ module SlackTrello; class RetroCommand
|
|
12
12
|
def run
|
13
13
|
return help_message unless valid_text_format?
|
14
14
|
return help_message unless num_args == 1
|
15
|
-
return board_not_found_message unless trello_card_creator.trello_board
|
16
15
|
return list_not_found_message unless trello_card_creator.trello_list
|
17
16
|
|
18
17
|
trello_card
|
@@ -51,7 +50,7 @@ For example, Some List Name => some_list_name
|
|
51
50
|
end
|
52
51
|
|
53
52
|
def trello_card
|
54
|
-
trello_card_creator.
|
53
|
+
@card ||= trello_card_creator.first_or_create
|
55
54
|
end
|
56
55
|
|
57
56
|
def trello_board_name
|
@@ -62,10 +61,6 @@ For example, Some List Name => some_list_name
|
|
62
61
|
args[0]
|
63
62
|
end
|
64
63
|
|
65
|
-
def board_not_found_message
|
66
|
-
"A Trello board named '#{trello_board_name}' must be created and the Trello user in the codebase must be added to the board for this command to function for this Slack room."
|
67
|
-
end
|
68
|
-
|
69
64
|
def list_not_found_message
|
70
65
|
"A Trello list named #{trello_list_name} must be added to the '#{trello_board_name}' board for this command to function."
|
71
66
|
end
|
@@ -3,18 +3,25 @@ module SlackTrello; class TrelloLookup
|
|
3
3
|
class << self
|
4
4
|
|
5
5
|
def board(board_name)
|
6
|
-
|
6
|
+
Trello::Board.all.find do |b|
|
7
7
|
spaceify(b.name) == spaceify(board_name) && b.closed == false
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
def list(board_name, list_name)
|
12
12
|
b = board(board_name)
|
13
|
-
|
13
|
+
b.lists.find do |l|
|
14
14
|
spaceify(l.name) == spaceify(list_name)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
def card(board_name, list_name, card_name)
|
19
|
+
l = list(board_name, list_name)
|
20
|
+
l.cards.find do |c|
|
21
|
+
spaceify(c.name) == spaceify(card_name)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
18
25
|
def spaceify(str)
|
19
26
|
str.gsub(/-|_/, " ").downcase
|
20
27
|
end
|
data/lib/slack_trello/version.rb
CHANGED
@@ -8,7 +8,6 @@ module SlackTrello; class WorkCommand
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def run
|
11
|
-
return board_not_found_message unless trello_card_creator.trello_board
|
12
11
|
return list_not_found_message unless trello_card_creator.trello_list
|
13
12
|
|
14
13
|
trello_card
|
@@ -37,7 +36,7 @@ module SlackTrello; class WorkCommand
|
|
37
36
|
end
|
38
37
|
|
39
38
|
def trello_card
|
40
|
-
trello_card_creator.
|
39
|
+
@card ||= trello_card_creator.first_or_create
|
41
40
|
end
|
42
41
|
|
43
42
|
def trello_board_name
|
@@ -48,10 +47,6 @@ module SlackTrello; class WorkCommand
|
|
48
47
|
'From Chat'
|
49
48
|
end
|
50
49
|
|
51
|
-
def board_not_found_message
|
52
|
-
"A Trello board named '#{trello_board_name}' must be created and the Trello user in the codebase must be added to the board for the work command to function for this Slack room."
|
53
|
-
end
|
54
|
-
|
55
50
|
def list_not_found_message
|
56
51
|
"A Trello list named #{trello_list_name} must be added to the '#{trello_board_name}' board for the work command to function."
|
57
52
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack_trello
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Powers
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- bin/setup
|
100
100
|
- lib/slack_trello.rb
|
101
101
|
- lib/slack_trello/copy_cards.rb
|
102
|
+
- lib/slack_trello/copy_cards_command.rb
|
102
103
|
- lib/slack_trello/create_card_command.rb
|
103
104
|
- lib/slack_trello/create_trello_card.rb
|
104
105
|
- lib/slack_trello/response_parser.rb
|