slacked 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +10 -4
- data/lib/slacked/slack_post.rb +13 -7
- data/lib/slacked/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 754d79d20a83f26f90777e3f386eb26382bd83a61c212156cabbdf1f5b5f970e
|
4
|
+
data.tar.gz: d9f5f2e038b9905df35bce18591ebd1d209b3daecf01c902f4eb697c96b12563
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b930dcf234123c5997070120c9747252189e25f476de92dc44fcc9cc4a4fb7a4094c782fb12db20b8fe7e29b4d2d9bf4d4e6434d64144d8bfa5fe29b5e1f1c6
|
7
|
+
data.tar.gz: b05b1537b869823d3ddd6299ca6450c03207e12cf5a00131b20b3fe942c90178adfbe9c91d9c5473cf56fd685678df40aba713ad207c2da2b079cd0408cf2c85
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ Then run the installer:
|
|
32
32
|
|
33
33
|
$ bundle exec rails g slacked:install
|
34
34
|
|
35
|
-
This will create a .env file in the root of the rails application. Specify the Webhook Url and the message to be sent.
|
35
|
+
This will create a .env file in the root of the rails application. Specify the default Webhook Url and the message to be sent.
|
36
36
|
|
37
37
|
```ruby
|
38
38
|
SLACK_WEBHOOK= "WEBHOOK_URL"
|
@@ -41,7 +41,7 @@ SLACK_DEFAULT_MESSAGE= "TEST"
|
|
41
41
|
|
42
42
|
|
43
43
|
## Usage
|
44
|
-
Set the
|
44
|
+
Set the SLACK_WEBHOOK env variable with the default value of the webhook which you want to send the messages. If you would like to send messages to different webhooks, you can do so by specifying the webhook url in the `config` parameter to `Slacked#post` or `Slacked#post_async`.
|
45
45
|
If you want to send a unique message in your application like 'Application is running' you can set the SLACK_DEFAULT_MESSAGE and call the message methods without sending an argument.
|
46
46
|
|
47
47
|
|
@@ -82,7 +82,12 @@ or
|
|
82
82
|
Slacked.post_async "Let's play fetch!", {icon_emoji: ':dog:'}
|
83
83
|
```
|
84
84
|
|
85
|
-
|
85
|
+
or
|
86
|
+
```ruby
|
87
|
+
Slacked.post_async 'This goes to a specific channel!', {webhook_url: <WEBHOOK_URL>}
|
88
|
+
```
|
89
|
+
|
90
|
+
Right now we only have the config for the icon and the webhook url, if you need another one let us know or submit a pull request.
|
86
91
|
|
87
92
|
## Example
|
88
93
|
|
@@ -107,11 +112,12 @@ config.slacked_disabled = true
|
|
107
112
|
|
108
113
|
The default value is false
|
109
114
|
|
110
|
-
## Contributors
|
115
|
+
## Contributors
|
111
116
|
|
112
117
|
- [Kaio Magalhães](https://github.com/kaiomagalhaes)
|
113
118
|
- [Lockyy](https://github.com/Lockyy)
|
114
119
|
- [Sean H.](https://github.com/seathony)
|
120
|
+
- [Tomas Barry](https://github.com/TomasBarry)
|
115
121
|
|
116
122
|
|
117
123
|
## License
|
data/lib/slacked/slack_post.rb
CHANGED
@@ -1,15 +1,20 @@
|
|
1
1
|
module Slacked
|
2
2
|
SLACK_PROFILE_IMAGE=':robot_face:'
|
3
|
-
SLACK_WEBHOOK_URL_KEY='SLACK_WEBHOOK'
|
3
|
+
SLACK_WEBHOOK_URL_KEY = 'SLACK_WEBHOOK'
|
4
4
|
SLACK_DEFAULT_MESSAGE_KEY='SLACK_DEFAULT_MESSAGE'
|
5
|
-
SLACK_DEFAULT_CONFIG= {
|
6
|
-
|
7
|
-
|
5
|
+
SLACK_DEFAULT_CONFIG = {
|
6
|
+
icon_emoji: SLACK_PROFILE_IMAGE,
|
7
|
+
webhook_url: ENV[SLACK_WEBHOOK_URL_KEY]
|
8
|
+
}.freeze
|
8
9
|
|
9
10
|
class << self
|
10
11
|
def post message = ENV[SLACK_DEFAULT_MESSAGE_KEY], config = SLACK_DEFAULT_CONFIG
|
11
12
|
return false if message.nil? || message.empty? || disabled?
|
12
|
-
|
13
|
+
|
14
|
+
merged_configs = SLACK_DEFAULT_CONFIG.merge(config)
|
15
|
+
webhook_url = merged_configs.fetch(:webhook_url, SLACK_WEBHOOK_URL_KEY)
|
16
|
+
slack_notifier(webhook_url)
|
17
|
+
.ping(message, merged_configs)
|
13
18
|
end
|
14
19
|
|
15
20
|
def post_async message= ENV[SLACK_DEFAULT_MESSAGE_KEY], config = SLACK_DEFAULT_CONFIG
|
@@ -27,8 +32,9 @@ module Slacked
|
|
27
32
|
end
|
28
33
|
|
29
34
|
private
|
30
|
-
|
31
|
-
|
35
|
+
|
36
|
+
def slack_notifier(webhook_url)
|
37
|
+
Slack::Notifier.new(webhook_url)
|
32
38
|
end
|
33
39
|
|
34
40
|
def rails?
|
data/lib/slacked/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slacked
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2019-07-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -172,8 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '0'
|
174
174
|
requirements: []
|
175
|
-
|
176
|
-
rubygems_version: 2.4.8
|
175
|
+
rubygems_version: 3.0.4
|
177
176
|
signing_key:
|
178
177
|
specification_version: 4
|
179
178
|
summary: A super simple and easy way to send notifications to Slack from your Rails
|