sinatra-slack 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -10
- data/lib/sinatra/slack.rb +1 -1
- data/lib/sinatra/slack/helpers/slack_attachment.rb +8 -13
- data/lib/sinatra/slack/helpers/slack_response.rb +3 -1
- data/lib/sinatra/slack/version.rb +1 -1
- metadata +58 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9064aff79dee088edcdfd96da33ded34cf4e259c4e07cf68368cd7224f1ac903
|
4
|
+
data.tar.gz: '0587a095b8661c6db382e65ad7cd1a2403ad7d151afd7536b9f638e0087e95e3'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 240c87518280fdf1fd55f76953731b061747d4b2989c8dbf38f20650ae469864945297ab695e923effb29f42d9ea94180c163fbd4ec2693bb6ceac1fd067c0c6
|
7
|
+
data.tar.gz: 2dba2ea99440f3d79ab358ca576694bef7dfbd8b5c74663199bc6a022669be169f06aec548d7a0f3c971ee602b11cf687d0d9e9bc821b3f77302c5575dc2cb86
|
data/README.md
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
# Sinatra::Slack
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/sinatra-slack.svg)](https://badge.fury.io/rb/sinatra-slack)
|
4
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/37325817408caa0872e6/maintainability)](https://codeclimate.com/github/nunonamorado/sinatra-slack/maintainability)
|
5
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/37325817408caa0872e6/test_coverage)](https://codeclimate.com/github/nunonamorado/sinatra-slack/test_coverage)
|
6
|
+
|
7
|
+
|
8
|
+
|
3
9
|
> Note: WIP
|
4
10
|
|
5
|
-
Creating your first Slack Slash Command application has never been to easy. Combining `sinatra` and `sinatra-slack` DSL, you can quickly create a app that processes
|
11
|
+
Creating your first Slack Slash Command application has never been to easy. Combining `sinatra` and `sinatra-slack` DSL, you can quickly create a app that processes Slash Commands with ease.
|
6
12
|
|
7
13
|
## Installation
|
8
14
|
|
@@ -20,6 +26,10 @@ Or install it yourself as:
|
|
20
26
|
|
21
27
|
$ gem install sinatra-slack
|
22
28
|
|
29
|
+
## Dependencies
|
30
|
+
|
31
|
+
This gem currently requires you to use [Thin](https://github.com/macournoyer/thin).
|
32
|
+
|
23
33
|
## Example
|
24
34
|
|
25
35
|
Go to folder example for more information. Learn how to create a Slack App in https://api.slack.com
|
@@ -35,7 +45,7 @@ class App < Sinatra::Base
|
|
35
45
|
|
36
46
|
configure :production, :development do
|
37
47
|
enable :logging
|
38
|
-
|
48
|
+
|
39
49
|
before { logger.info "Received: #{params}" }
|
40
50
|
end
|
41
51
|
|
@@ -49,11 +59,11 @@ class App < Sinatra::Base
|
|
49
59
|
end
|
50
60
|
```
|
51
61
|
|
52
|
-
##
|
53
|
-
|
54
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
62
|
+
## TODO
|
55
63
|
|
56
|
-
|
64
|
+
- Adds specs;
|
65
|
+
- Update message helper to use the new [Block Kit](https://api.slack.com/reference/messaging/block-elements);
|
66
|
+
- Add more [Interactive Component Elements](https://api.slack.com/reference/messaging/interactive-components). Currently there is only support for *buttons* and *menu*.
|
57
67
|
|
58
68
|
## Contributing
|
59
69
|
|
@@ -62,7 +72,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/nunona
|
|
62
72
|
## License
|
63
73
|
|
64
74
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
65
|
-
|
66
|
-
## Code of Conduct
|
67
|
-
|
68
|
-
Everyone interacting in the Sinatra::Slack project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/sinatra-slack/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/sinatra/slack.rb
CHANGED
@@ -95,7 +95,7 @@ module Sinatra
|
|
95
95
|
handle_with_rescue do
|
96
96
|
halt 401, 'Invalid Headers' unless authorized?
|
97
97
|
|
98
|
-
get_options = self.class.instance_method "#{path}_options"
|
98
|
+
get_options = self.class.instance_method "#{path}_options"
|
99
99
|
options = get_options.bind(self).call
|
100
100
|
|
101
101
|
halt 400 unless options
|
@@ -13,11 +13,6 @@ module Sinatra
|
|
13
13
|
@attachment_type = 'default'
|
14
14
|
@color = '#3AA3E3'
|
15
15
|
@actions = []
|
16
|
-
|
17
|
-
@text = ''
|
18
|
-
@fallback = ''
|
19
|
-
@image_url = ''
|
20
|
-
@title = ''
|
21
16
|
end
|
22
17
|
|
23
18
|
def action_button(name, text, value)
|
@@ -40,17 +35,17 @@ module Sinatra
|
|
40
35
|
|
41
36
|
def to_json
|
42
37
|
att_obj = {}
|
43
|
-
|
44
38
|
att_obj[:callback_id] = @callback_id
|
39
|
+
att_obj[:actions] = @actions unless @actions.empty?
|
45
40
|
|
46
|
-
|
47
|
-
att_obj[:color] = color unless color.empty?
|
48
|
-
att_obj[:attachment_type] = attachment_type unless attachment_type.empty?
|
49
|
-
att_obj[:text] = text unless text.empty?
|
50
|
-
att_obj[:fallback] = fallback unless fallback.empty?
|
51
|
-
att_obj[:image_url] = image_url unless image_url.empty?
|
41
|
+
attrs = %i[title color attachment_type text fallback image_url]
|
52
42
|
|
53
|
-
|
43
|
+
attrs.each do |a|
|
44
|
+
a_value = send(a)
|
45
|
+
next if !a_value || a_value.empty?
|
46
|
+
|
47
|
+
att_obj[a] = a_value
|
48
|
+
end
|
54
49
|
|
55
50
|
att_obj
|
56
51
|
end
|
@@ -7,13 +7,14 @@ module Sinatra
|
|
7
7
|
module Helpers
|
8
8
|
# Represents a message sent to the Slack Channel.
|
9
9
|
class SlackResponse
|
10
|
-
attr_accessor :text, :replace_original, :mrkdwn
|
10
|
+
attr_accessor :text, :replace_original, :mrkdwn, :response_type
|
11
11
|
|
12
12
|
def initialize(callback_id)
|
13
13
|
@callback_id = callback_id
|
14
14
|
@text = nil
|
15
15
|
@attachments = []
|
16
16
|
@replace_original = true
|
17
|
+
@response_type = 'ephemeral'
|
17
18
|
@mrkdwn = false
|
18
19
|
end
|
19
20
|
|
@@ -31,6 +32,7 @@ module Sinatra
|
|
31
32
|
response[:text] = @text if @text
|
32
33
|
response[:mrkdwn] = @mrkdwn
|
33
34
|
response[:replace_original] = @replace_original
|
35
|
+
response[:response_type] = @response_type
|
34
36
|
|
35
37
|
response[:attachments] = @attachments.map(&:to_json) unless @attachments.empty?
|
36
38
|
|
metadata
CHANGED
@@ -1,15 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-slack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nuno Namorado
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry-byebug
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
13
69
|
- !ruby/object:Gem::Dependency
|
14
70
|
name: async_sinatra
|
15
71
|
requirement: !ruby/object:Gem::Requirement
|