slack_trello 0.3.0 → 0.5.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 +4 -4
- data/README.md +78 -4
- data/lib/slack_trello.rb +9 -10
- data/lib/slack_trello/{copy_cards_command.rb → commands/copy_cards.rb} +11 -11
- data/lib/slack_trello/{create_card_command.rb → commands/create_card.rb} +11 -15
- data/lib/slack_trello/{retro_command.rb → commands/retro.rb} +13 -17
- data/lib/slack_trello/{work_command.rb → commands/work.rb} +12 -12
- data/lib/slack_trello/{speaker.rb → slack_helpers/speaker.rb} +3 -2
- data/lib/slack_trello/{text_parser.rb → slack_helpers/text_parser.rb} +5 -4
- data/lib/slack_trello/{copy_cards.rb → trello_helpers/copy_cards.rb} +4 -5
- data/lib/slack_trello/{create_trello_card.rb → trello_helpers/create_card.rb} +4 -4
- data/lib/slack_trello/{trello_lookup.rb → trello_helpers/lookup.rb} +2 -2
- data/lib/slack_trello/version.rb +1 -1
- metadata +11 -12
- data/lib/slack_trello/response_parser.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26f2990100c4de1e0af8d6b3636450be18c240ce
|
4
|
+
data.tar.gz: d9666f4d7cdff344148a142767525ed002379469
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1c6b60e941556fe2f58db30341857a0371ce1a6492646dc4db57fd8b483da463731a893123aaf653e5fad147c2f9e76165452eca019ca7ecf7ce80ff18175dd
|
7
|
+
data.tar.gz: 446fbd9e29a3704095b75ea9c00986a91cbfadacf1722ee9fe5ad71273a3db7d1050c457f5387b88cf95dcc7916b547a2dc550fe2f347d3eb0f3b16ee3ed82bb
|
data/README.md
CHANGED
@@ -2,6 +2,84 @@
|
|
2
2
|
|
3
3
|
The slack_trello gem makes it easy to parse POST requests sent to a Ruby application by the Slack API. The gem is geared towards making Trello cards based on Slack POST requests, but the core modules and classes are generic and can be repourposed for other tasks as well.
|
4
4
|
|
5
|
+
The Slack [slash commands](https://api.slack.com/slash-commands) send POST requests like this:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
{
|
9
|
+
"token" => "gIkuvaNzQIHg97ATvDxqgjtO",
|
10
|
+
"team_id" => "T0001",
|
11
|
+
"team_domain" => "example",
|
12
|
+
"channel_id" => "C2147483705",
|
13
|
+
"channel_name" => "test",
|
14
|
+
"user_id" => "U2147483697",
|
15
|
+
"user_name" => "Steve",
|
16
|
+
"command" => "/some_command",
|
17
|
+
"text" => "(some_arg another_arg) some stuff blah"
|
18
|
+
}
|
19
|
+
```
|
20
|
+
|
21
|
+
The slack_trello gem parses these POST params and makes Trello cards.
|
22
|
+
|
23
|
+
### Work Command
|
24
|
+
|
25
|
+
Example usage of this command in Slack (assume the command is run in the #pandas channel):
|
26
|
+
|
27
|
+
```
|
28
|
+
/work Do some important stuff
|
29
|
+
```
|
30
|
+
|
31
|
+
This will create a Trello card in the From Chat list of the Pandas Backlog Trello board. The code can be invoked as follows:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
SlackTrello::Commands::Work.new(params, ENV["SLACK_WEBHOOK_URL"]).run
|
35
|
+
```
|
36
|
+
|
37
|
+
### Retro Command
|
38
|
+
|
39
|
+
Example usage of this command in Slack (assume the command is run in the #pandas channel):
|
40
|
+
|
41
|
+
```
|
42
|
+
/retro (questions) Why are we building that feature?
|
43
|
+
```
|
44
|
+
|
45
|
+
This will create a Trello card in the Questions list of the Pandas Retro Trello board. The code can be invoked as follows:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
SlackTrello::Commands::Retro.new(params, ENV["SLACK_WEBHOOK_URL"]).run
|
49
|
+
```
|
50
|
+
|
51
|
+
### Card Command
|
52
|
+
|
53
|
+
Example usage of this command in Slack (this command can run in any channel and function the same):
|
54
|
+
|
55
|
+
```
|
56
|
+
/card (pandaland on_deck) Build a cool cmap
|
57
|
+
```
|
58
|
+
|
59
|
+
This will create a Trello card in the On Deck list of the Pandaland Trello board. The code can be invoked as follows:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
SlackTrello::Commands::Card.new(params, ENV["SLACK_WEBHOOK_URL"]).run
|
63
|
+
```
|
64
|
+
|
65
|
+
### CopyCards Command
|
66
|
+
|
67
|
+
Example usage of this command in Slack (this command can run in any channel and function the same):
|
68
|
+
|
69
|
+
```
|
70
|
+
/copy_cards (recurring_engineering pandas pandaland on_deck)
|
71
|
+
```
|
72
|
+
|
73
|
+
This will copy all the cards from the the Pandas list of the Recurring Engineering Trello board to the On Deck list of the Pandaland Trello board. The code can be invoked as follows:
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
SlackTrello::Commands::CopyCards.new(params, ENV["SLACK_WEBHOOK_URL"]).run
|
77
|
+
```
|
78
|
+
|
79
|
+
## Usage
|
80
|
+
|
81
|
+
The [slack-responder](https://github.com/medivo/slack-responder) Rails application includes the slack_trello gem and demonstrates how a Rails application that responds to Slack POST requests can be set up. Cloning the slack-responder application is the easiest way to get up-and-running with the slack_trello gem.
|
82
|
+
|
5
83
|
## Installation
|
6
84
|
|
7
85
|
Add this line to your application's Gemfile:
|
@@ -18,7 +96,3 @@ Or install it yourself as:
|
|
18
96
|
|
19
97
|
$ gem install slack_trello
|
20
98
|
|
21
|
-
## Usage
|
22
|
-
|
23
|
-
The [slack-responder](https://github.com/medivo/slack-responder) Rails application includes the slack_trello gem and demonstrates how a Rails application that responds to Slack POST requests can be set up. Cloning the slack-responder application is the easiest way to get up-and-running with the slack_trello gem.
|
24
|
-
|
data/lib/slack_trello.rb
CHANGED
@@ -1,19 +1,18 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
1
3
|
require "active_support/core_ext/string"
|
2
4
|
require "slack-notifier"
|
3
5
|
|
4
6
|
require "slack_trello/version"
|
5
|
-
require "slack_trello/trello_lookup"
|
6
|
-
require "slack_trello/text_parser"
|
7
|
-
require "slack_trello/response_parser"
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
require
|
8
|
+
def require_all(pattern)
|
9
|
+
root = File.expand_path("../", File.dirname(__FILE__))
|
10
|
+
Dir.glob("#{root}/#{pattern}/**/*.rb").sort.each { |path| require path }
|
11
|
+
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
require "slack_trello/retro_command"
|
13
|
+
require_all("lib/slack_trello/slack_helpers")
|
14
|
+
require_all("lib/slack_trello/trello_helpers")
|
15
|
+
require_all("lib/slack_trello/commands")
|
17
16
|
|
18
17
|
module SlackTrello
|
19
18
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
module SlackTrello; class
|
1
|
+
module SlackTrello; module Commands; class CopyCards
|
2
2
|
|
3
|
-
include TextParser
|
3
|
+
include SlackTrello::SlackHelpers::TextParser
|
4
4
|
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :slack_post_response, :webhook_url
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@
|
7
|
+
def initialize(slack_post_args, webhook_url)
|
8
|
+
@slack_post_response = OpenStruct.new(slack_post_args)
|
9
9
|
@webhook_url = webhook_url
|
10
10
|
end
|
11
11
|
|
@@ -22,7 +22,7 @@ module SlackTrello; class CopyCardsCommand
|
|
22
22
|
|
23
23
|
def help_message
|
24
24
|
%{:cry: Invalid format
|
25
|
-
Your message: #{
|
25
|
+
Your message: #{slack_post_response.text}
|
26
26
|
Example: /copy_cards (source_board, source_list, destination_board, destination_list)
|
27
27
|
}
|
28
28
|
end
|
@@ -30,10 +30,10 @@ Example: /copy_cards (source_board, source_list, destination_board, destination_
|
|
30
30
|
def speaker
|
31
31
|
args = {
|
32
32
|
webhook_url: webhook_url,
|
33
|
-
channel:
|
34
|
-
username:
|
33
|
+
channel: slack_post_response.channel_name,
|
34
|
+
username: slack_post_response.user_name
|
35
35
|
}
|
36
|
-
Speaker.new(args)
|
36
|
+
SlackTrello::SlackHelpers::Speaker.new(args)
|
37
37
|
end
|
38
38
|
|
39
39
|
def card_copier
|
@@ -63,8 +63,8 @@ Example: /copy_cards (source_board, source_list, destination_board, destination_
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def success_message
|
66
|
-
":mega: [#{
|
66
|
+
":mega: [#{slack_post_response.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
67
|
end
|
68
68
|
|
69
|
-
end; end
|
69
|
+
end; end; end
|
70
70
|
|
@@ -1,11 +1,11 @@
|
|
1
|
-
module SlackTrello; class
|
1
|
+
module SlackTrello; module Commands; class CreateCard
|
2
2
|
|
3
|
-
include TextParser
|
3
|
+
include SlackTrello::SlackHelpers::TextParser
|
4
4
|
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :slack_post_response, :webhook_url
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@
|
7
|
+
def initialize(slack_post_args, webhook_url)
|
8
|
+
@slack_post_response = OpenStruct.new(slack_post_args)
|
9
9
|
@webhook_url = webhook_url
|
10
10
|
end
|
11
11
|
|
@@ -33,10 +33,10 @@ For example, Some Board Name => some_board_name
|
|
33
33
|
def speaker
|
34
34
|
args = {
|
35
35
|
webhook_url: webhook_url,
|
36
|
-
channel:
|
37
|
-
username:
|
36
|
+
channel: slack_post_response.channel_name,
|
37
|
+
username: slack_post_response.user_name
|
38
38
|
}
|
39
|
-
Speaker.new(args)
|
39
|
+
SlackTrello::SlackHelpers::Speaker.new(args)
|
40
40
|
end
|
41
41
|
|
42
42
|
def trello_card_creator
|
@@ -45,7 +45,7 @@ For example, Some Board Name => some_board_name
|
|
45
45
|
list_name: trello_list_name,
|
46
46
|
card_name: card_title
|
47
47
|
}
|
48
|
-
@trello_card_creator ||=
|
48
|
+
@trello_card_creator ||= SlackTrello::TrelloHelpers::CreateCard.new(args)
|
49
49
|
end
|
50
50
|
|
51
51
|
def trello_card
|
@@ -65,16 +65,12 @@ For example, Some Board Name => some_board_name
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def success_message
|
68
|
-
":mega: [#{
|
68
|
+
":mega: [#{slack_post_response.user_name}] has created a new trello card: <#{trello_card.short_url}|#{slack_post_response.text.strip}>"
|
69
69
|
end
|
70
70
|
|
71
71
|
def card_title
|
72
72
|
text_message
|
73
73
|
end
|
74
74
|
|
75
|
-
|
76
|
-
parser.text
|
77
|
-
end
|
78
|
-
|
79
|
-
end; end
|
75
|
+
end; end; end
|
80
76
|
|
@@ -1,11 +1,11 @@
|
|
1
|
-
module SlackTrello; class
|
1
|
+
module SlackTrello; module Commands; class Retro
|
2
2
|
|
3
|
-
include TextParser
|
3
|
+
include SlackTrello::SlackHelpers::TextParser
|
4
4
|
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :slack_post_response, :webhook_url
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@
|
7
|
+
def initialize(slack_post_args, webhook_url)
|
8
|
+
@slack_post_response = OpenStruct.new(slack_post_args)
|
9
9
|
@webhook_url = webhook_url
|
10
10
|
end
|
11
11
|
|
@@ -34,10 +34,10 @@ For example, Some List Name => some_list_name
|
|
34
34
|
def speaker
|
35
35
|
args = {
|
36
36
|
webhook_url: webhook_url,
|
37
|
-
channel:
|
38
|
-
username:
|
37
|
+
channel: slack_post_response.channel_name,
|
38
|
+
username: slack_post_response.user_name
|
39
39
|
}
|
40
|
-
Speaker.new(args)
|
40
|
+
SlackTrello::SlackHelpers::Speaker.new(args)
|
41
41
|
end
|
42
42
|
|
43
43
|
def trello_card_creator
|
@@ -46,7 +46,7 @@ For example, Some List Name => some_list_name
|
|
46
46
|
list_name: trello_list_name,
|
47
47
|
card_name: card_title
|
48
48
|
}
|
49
|
-
@trello_card_creator ||=
|
49
|
+
@trello_card_creator ||= SlackTrello::TrelloHelpers::CreateCard.new(args)
|
50
50
|
end
|
51
51
|
|
52
52
|
def trello_card
|
@@ -54,7 +54,7 @@ For example, Some List Name => some_list_name
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def trello_board_name
|
57
|
-
"#{
|
57
|
+
"#{slack_post_response.channel_name.titleize} Retro"
|
58
58
|
end
|
59
59
|
|
60
60
|
def trello_list_name
|
@@ -66,15 +66,11 @@ For example, Some List Name => some_list_name
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def success_message
|
69
|
-
":mega: [#{
|
69
|
+
":mega: [#{slack_post_response.user_name}] has created a new trello card: <#{trello_card.short_url}|#{slack_post_response.text.strip}>"
|
70
70
|
end
|
71
71
|
|
72
72
|
def card_title
|
73
|
-
"#{text_message} -- #{
|
74
|
-
end
|
75
|
-
|
76
|
-
def text
|
77
|
-
parser.text
|
73
|
+
"#{text_message} -- #{slack_post_response.user_name}"
|
78
74
|
end
|
79
75
|
|
80
76
|
def list_names
|
@@ -83,5 +79,5 @@ For example, Some List Name => some_list_name
|
|
83
79
|
end
|
84
80
|
end
|
85
81
|
|
86
|
-
end; end
|
82
|
+
end; end; end
|
87
83
|
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module SlackTrello; class
|
1
|
+
module SlackTrello; module Commands; class Work
|
2
2
|
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :slack_post_response, :webhook_url
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@
|
5
|
+
def initialize(slack_post_args, webhook_url)
|
6
|
+
@slack_post_response = OpenStruct.new(slack_post_args)
|
7
7
|
@webhook_url = webhook_url
|
8
8
|
end
|
9
9
|
|
@@ -20,10 +20,10 @@ module SlackTrello; class WorkCommand
|
|
20
20
|
def speaker
|
21
21
|
args = {
|
22
22
|
webhook_url: webhook_url,
|
23
|
-
channel:
|
24
|
-
username:
|
23
|
+
channel: slack_post_response.channel_name,
|
24
|
+
username: slack_post_response.user_name
|
25
25
|
}
|
26
|
-
Speaker.new(args)
|
26
|
+
SlackTrello::SlackHelpers::Speaker.new(args)
|
27
27
|
end
|
28
28
|
|
29
29
|
def trello_card_creator
|
@@ -32,7 +32,7 @@ module SlackTrello; class WorkCommand
|
|
32
32
|
list_name: trello_list_name,
|
33
33
|
card_name: card_title
|
34
34
|
}
|
35
|
-
@trello_card_creator ||=
|
35
|
+
@trello_card_creator ||= SlackTrello::TrelloHelpers::CreateCard.new(args)
|
36
36
|
end
|
37
37
|
|
38
38
|
def trello_card
|
@@ -40,7 +40,7 @@ module SlackTrello; class WorkCommand
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def trello_board_name
|
43
|
-
"#{
|
43
|
+
"#{slack_post_response.channel_name.titleize} Backlog"
|
44
44
|
end
|
45
45
|
|
46
46
|
def trello_list_name
|
@@ -52,12 +52,12 @@ module SlackTrello; class WorkCommand
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def success_message
|
55
|
-
":mega: [#{
|
55
|
+
":mega: [#{slack_post_response.user_name}] has created a new work card: <#{trello_card.short_url}|#{slack_post_response.text.strip}>"
|
56
56
|
end
|
57
57
|
|
58
58
|
def card_title
|
59
|
-
"(UNSIZED) #{
|
59
|
+
"(UNSIZED) #{slack_post_response.text.strip} {tag???}"
|
60
60
|
end
|
61
61
|
|
62
|
-
end; end
|
62
|
+
end; end; end
|
63
63
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module SlackTrello; class Speaker
|
1
|
+
module SlackTrello; module SlackHelpers; class Speaker
|
2
2
|
|
3
3
|
def initialize(args)
|
4
4
|
@webhook_url = args.fetch(:webhook_url)
|
@@ -20,4 +20,5 @@ module SlackTrello; class Speaker
|
|
20
20
|
@channel.start_with?("#") ? @channel : "##{@channel}"
|
21
21
|
end
|
22
22
|
|
23
|
-
end; end
|
23
|
+
end; end; end
|
24
|
+
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module SlackTrello; module TextParser
|
1
|
+
module SlackTrello; module SlackHelpers; module TextParser
|
2
2
|
|
3
3
|
def args
|
4
4
|
return "" unless valid_text_format?
|
@@ -18,8 +18,6 @@ module SlackTrello; module TextParser
|
|
18
18
|
args.length
|
19
19
|
end
|
20
20
|
|
21
|
-
private
|
22
|
-
|
23
21
|
def regex
|
24
22
|
/\((.+?)\)(.+)?/
|
25
23
|
end
|
@@ -28,6 +26,9 @@ module SlackTrello; module TextParser
|
|
28
26
|
text.match(regex)
|
29
27
|
end
|
30
28
|
|
31
|
-
|
29
|
+
def text
|
30
|
+
slack_post_response.text
|
31
|
+
end
|
32
32
|
|
33
|
+
end; end; end
|
33
34
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module SlackTrello; class CopyCards
|
1
|
+
module SlackTrello; module TrelloHelpers; class CopyCards
|
2
2
|
|
3
3
|
attr_reader :source_board, :source_list, :destination_board, :destination_list
|
4
4
|
|
@@ -11,16 +11,15 @@ module SlackTrello; class CopyCards
|
|
11
11
|
|
12
12
|
def run
|
13
13
|
source_cards.each do |source_card|
|
14
|
-
creator =
|
14
|
+
creator = CreateCard.new(board_name: destination_board, list_name: destination_list, card_name: source_card.name)
|
15
15
|
creator.first_or_create
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
def source_cards
|
20
|
-
l =
|
20
|
+
l = Lookup.list(source_board, source_list)
|
21
21
|
l.cards
|
22
22
|
end
|
23
23
|
|
24
|
-
end; end
|
25
|
-
|
24
|
+
end; end; end
|
26
25
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module SlackTrello; class
|
1
|
+
module SlackTrello; module TrelloHelpers; class CreateCard
|
2
2
|
|
3
3
|
attr_reader :board_name, :list_name, :card_name
|
4
4
|
|
@@ -9,7 +9,7 @@ module SlackTrello; class CreateTrelloCard
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def first_or_create
|
12
|
-
card =
|
12
|
+
card = Lookup.card(board_name, list_name, card_name)
|
13
13
|
return card if card
|
14
14
|
create_card
|
15
15
|
end
|
@@ -22,8 +22,8 @@ module SlackTrello; class CreateTrelloCard
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def trello_list
|
25
|
-
|
25
|
+
Lookup.list(board_name, list_name)
|
26
26
|
end
|
27
27
|
|
28
|
-
end; end
|
28
|
+
end; end; end
|
29
29
|
|
data/lib/slack_trello/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack_trello
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Powers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -98,17 +98,16 @@ files:
|
|
98
98
|
- bin/console
|
99
99
|
- bin/setup
|
100
100
|
- lib/slack_trello.rb
|
101
|
-
- lib/slack_trello/copy_cards.rb
|
102
|
-
- lib/slack_trello/
|
103
|
-
- lib/slack_trello/
|
104
|
-
- lib/slack_trello/
|
105
|
-
- lib/slack_trello/
|
106
|
-
- lib/slack_trello/
|
107
|
-
- lib/slack_trello/
|
108
|
-
- lib/slack_trello/
|
109
|
-
- lib/slack_trello/
|
101
|
+
- lib/slack_trello/commands/copy_cards.rb
|
102
|
+
- lib/slack_trello/commands/create_card.rb
|
103
|
+
- lib/slack_trello/commands/retro.rb
|
104
|
+
- lib/slack_trello/commands/work.rb
|
105
|
+
- lib/slack_trello/slack_helpers/speaker.rb
|
106
|
+
- lib/slack_trello/slack_helpers/text_parser.rb
|
107
|
+
- lib/slack_trello/trello_helpers/copy_cards.rb
|
108
|
+
- lib/slack_trello/trello_helpers/create_card.rb
|
109
|
+
- lib/slack_trello/trello_helpers/lookup.rb
|
110
110
|
- lib/slack_trello/version.rb
|
111
|
-
- lib/slack_trello/work_command.rb
|
112
111
|
- slack_trello.gemspec
|
113
112
|
homepage: https://github.com/MrPowers/slack_trello
|
114
113
|
licenses:
|