slack-notification 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/slack_notification.rb +12 -0
- data/slack-notification.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d48baf58d70ad1a83cd4a8f82fd832f4ffe29319fb58dd22e654bb701e71391f
|
4
|
+
data.tar.gz: 8be9a3b3a81a092622066c295d5b7011713420e240350eb06ed18e9dd52cf9a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3b2950e3653af693a91176c5424c41a46602765c00dfc15db85212493bbda625e335bff453d906453fe1601d38dc2240552eeb47d799078b959133355c7e212
|
7
|
+
data.tar.gz: 37fdaefd47f2985f90d2d06e2b5054cd720724f3e11a366773df9fb0c58db58aeed65e4ac181fd293161bd9efcf75ae29d832552acf83ccd8aee0f213045419b
|
data/README.md
CHANGED
@@ -59,8 +59,12 @@ String: The fields value becomes the message title, and no fields are submitted.
|
|
59
59
|
Hash: Format: `{ title_1: :value_1, [...] }`
|
60
60
|
Array: Array of hashes, each of format: `{ title: 'Field name', value: field_value, short: true }`
|
61
61
|
|
62
|
+
### Configuration
|
63
|
+
|
62
64
|
Channels can be made available by setting ENV variables beginning with `SLACK_URL_`.
|
63
65
|
|
66
|
+
If you are using Rails credentials, the `:slack` will take priority over ENV variables, ir present.
|
67
|
+
|
64
68
|
## License
|
65
69
|
|
66
70
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/slack_notification.rb
CHANGED
@@ -78,11 +78,23 @@ private
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def slack_urls
|
81
|
+
return credentials_urls if credentials_urls?
|
82
|
+
|
81
83
|
ENV.select { |k, _| k.match?(/SLACK_URL_/) }.map do |key, url|
|
82
84
|
{ key.gsub('SLACK_URL_', '').downcase => url }
|
83
85
|
end.reduce({}, :merge)
|
84
86
|
end
|
85
87
|
|
88
|
+
def credentials_urls?
|
89
|
+
defined?(Rails) && Rails.application.credentials.respond_to?(:slack)
|
90
|
+
end
|
91
|
+
|
92
|
+
def credentials_urls
|
93
|
+
Rails.application.credentials.slack.mapeach_with_object({}) do |(k, v), h|
|
94
|
+
h[k.to_s.gsub('_', '-')] = v
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
86
98
|
def validated_type(type = nil)
|
87
99
|
valid_types = %i[success info warning failure]
|
88
100
|
return type if type.blank? || type.in?(valid_types)
|
data/slack-notification.gemspec
CHANGED