slack-notifier 1.4.0 → 1.5.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-notifier.rb +10 -2
- data/lib/slack-notifier/version.rb +1 -1
- data/spec/integration/ping_integration_test.rb +1 -0
- data/spec/lib/slack-notifier_spec.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 925192e85bf32025c381022231f46be23cc105ee
|
4
|
+
data.tar.gz: bb98f67682a680108c5f588d0617db386f840820
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa9fba36d2d9d5d90cad1b07ae3204e3508b597d6ed971cdb59cdfcd77cb808994758c7a3a28517fee3715aaf375a9dadd2fa0c8729a60edf8a5f79cbb8658d5
|
7
|
+
data.tar.gz: f21f76221f0a82cf50fc4c5fc0f4c4a04c313d8023d813be6268d3e7b2f7d143f79848faf14a203442686dcd43dc830cfd858eee01e27e68218861e27310c31b
|
data/lib/slack-notifier.rb
CHANGED
@@ -15,7 +15,10 @@ module Slack
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def ping message, options={}
|
18
|
-
message
|
18
|
+
if message.is_a?(Hash)
|
19
|
+
message, options = nil, message
|
20
|
+
end
|
21
|
+
|
19
22
|
if attachments = options[:attachments] || options["attachments"]
|
20
23
|
attachments.each do |attachment|
|
21
24
|
["text", :text].each do |key|
|
@@ -23,10 +26,15 @@ module Slack
|
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
26
|
-
|
29
|
+
|
30
|
+
payload = default_payload.merge(options)
|
27
31
|
client = payload.delete(:http_client) || http_client
|
28
32
|
http_options = payload.delete(:http_options)
|
29
33
|
|
34
|
+
unless message.nil?
|
35
|
+
payload.merge!(text: LinkFormatter.format(message))
|
36
|
+
end
|
37
|
+
|
30
38
|
params = { payload: payload.to_json }
|
31
39
|
params[:http_options] = http_options if http_options
|
32
40
|
|
@@ -4,3 +4,4 @@ require_relative '../../lib/slack-notifier'
|
|
4
4
|
notifier = Slack::Notifier.new ENV['SLACK_WEBHOOK_URL'], username: 'notifier'
|
5
5
|
puts "testing with ruby #{RUBY_VERSION}"
|
6
6
|
notifier.ping "hello/こんにちは from notifier test script on ruby: #{RUBY_VERSION}\225"
|
7
|
+
notifier.ping attachments: [{color:"#1BF5AF",fallback:"fallback",text:"attachment"}]
|
@@ -46,6 +46,22 @@ describe Slack::Notifier do
|
|
46
46
|
}]
|
47
47
|
end
|
48
48
|
|
49
|
+
it "allows sending only an attachment" do
|
50
|
+
expect( Slack::Notifier::DefaultHTTPClient ).to receive(:post).with(
|
51
|
+
URI.parse('http://example.com'),
|
52
|
+
payload: '{"channel":"foo","attachments":[{"text":"attachment","fallback":"fallback"}]}'
|
53
|
+
)
|
54
|
+
|
55
|
+
expect{
|
56
|
+
described_class.new('http://example.com')
|
57
|
+
.ping channel: 'foo',
|
58
|
+
attachments: [{
|
59
|
+
text: 'attachment',
|
60
|
+
fallback: 'fallback'
|
61
|
+
}]
|
62
|
+
}.not_to raise_error
|
63
|
+
end
|
64
|
+
|
49
65
|
context "with a default channel set" do
|
50
66
|
|
51
67
|
before :each do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack-notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Sloan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: " A slim ruby wrapper for posting to slack webhooks "
|
14
14
|
email:
|