slack-notifier 1.4.0 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4b8594811b3092b0dd7f63d28babf5c154758a1
4
- data.tar.gz: 892cc4f5174554ff2711773f96162fdf968b9555
3
+ metadata.gz: 925192e85bf32025c381022231f46be23cc105ee
4
+ data.tar.gz: bb98f67682a680108c5f588d0617db386f840820
5
5
  SHA512:
6
- metadata.gz: 29ac1440fc2206c3bbfb939983a5a9445313a10a587f54760e62ee18d8c27c8d8d1341c5e537b5106f36d76167892899f12220484cb3013b251be434ba478ea5
7
- data.tar.gz: eccee2d94d9679638a7341eb0fd2c7fab2572561590ac4318623719bc219bbc4771bea8a2c3416f872559067501f447c98ed2d1d3fadbc16da1975f1700fb241
6
+ metadata.gz: aa9fba36d2d9d5d90cad1b07ae3204e3508b597d6ed971cdb59cdfcd77cb808994758c7a3a28517fee3715aaf375a9dadd2fa0c8729a60edf8a5f79cbb8658d5
7
+ data.tar.gz: f21f76221f0a82cf50fc4c5fc0f4c4a04c313d8023d813be6268d3e7b2f7d143f79848faf14a203442686dcd43dc830cfd858eee01e27e68218861e27310c31b
@@ -15,7 +15,10 @@ module Slack
15
15
  end
16
16
 
17
17
  def ping message, options={}
18
- message = LinkFormatter.format(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
- payload = default_payload.merge(options).merge(text: message)
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
 
@@ -1,5 +1,5 @@
1
1
  module Slack
2
2
  class Notifier
3
- VERSION = "1.4.0"
3
+ VERSION = "1.5.0"
4
4
  end
5
5
  end
@@ -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.0
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-10-16 00:00:00.000000000 Z
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: