slack-notifier 1.5.0 → 1.5.1

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: 925192e85bf32025c381022231f46be23cc105ee
4
- data.tar.gz: bb98f67682a680108c5f588d0617db386f840820
3
+ metadata.gz: e74413c9d125dd2a973d6035bdc86e6f28549839
4
+ data.tar.gz: 6081e63972a12dc07acc866e13f8e6bae8a1992d
5
5
  SHA512:
6
- metadata.gz: aa9fba36d2d9d5d90cad1b07ae3204e3508b597d6ed971cdb59cdfcd77cb808994758c7a3a28517fee3715aaf375a9dadd2fa0c8729a60edf8a5f79cbb8658d5
7
- data.tar.gz: f21f76221f0a82cf50fc4c5fc0f4c4a04c313d8023d813be6268d3e7b2f7d143f79848faf14a203442686dcd43dc830cfd858eee01e27e68218861e27310c31b
6
+ metadata.gz: 252d1d23a8bb02cfe9ebee51c8d68436799daa59c95572dd18bc481797069ed2fa6fac96869845ffeae900fbf5d73c9df9b4e910f9190f7ca85937293e8d3e31
7
+ data.tar.gz: bda7747d3bd8e34a0ca2798d50c06c4f2b6e426c2552c2d389247f6ed60ce48a82d26e7f77e7e9c179388e831163d36a237dfe139cdddec689fdb154ee3b7d1b
@@ -20,7 +20,7 @@ module Slack
20
20
  end
21
21
 
22
22
  if attachments = options[:attachments] || options["attachments"]
23
- attachments.each do |attachment|
23
+ wrap_array(attachments).each do |attachment|
24
24
  ["text", :text].each do |key|
25
25
  attachment[key] = LinkFormatter.format(attachment[key]) if attachment.has_key?(key)
26
26
  end
@@ -67,5 +67,15 @@ module Slack
67
67
  def escape(text)
68
68
  text.gsub(HTML_ESCAPE_REGEXP, HTML_ESCAPE)
69
69
  end
70
+
71
+ def wrap_array(object)
72
+ if object.nil?
73
+ []
74
+ elsif object.respond_to?(:to_ary)
75
+ object.to_ary || [object]
76
+ else
77
+ [object]
78
+ end
79
+ end
70
80
  end
71
81
  end
@@ -1,5 +1,5 @@
1
1
  module Slack
2
2
  class Notifier
3
- VERSION = "1.5.0"
3
+ VERSION = "1.5.1"
4
4
  end
5
5
  end
@@ -62,6 +62,19 @@ describe Slack::Notifier do
62
62
  }.not_to raise_error
63
63
  end
64
64
 
65
+ it "passes attachment messages through LinkFormatter, even if a single value is passed" do
66
+ expect( Slack::Notifier::LinkFormatter ).to receive(:format)
67
+ .with("a random message")
68
+ expect( Slack::Notifier::LinkFormatter ).to receive(:format)
69
+ .with("attachment message")
70
+ attachment = {
71
+ color: "#000",
72
+ text: "attachment message",
73
+ fallback: "fallback message"
74
+ }
75
+ subject.ping "a random message", attachments: attachment
76
+ end
77
+
65
78
  context "with a default channel set" do
66
79
 
67
80
  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.5.0
4
+ version: 1.5.1
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-30 00:00:00.000000000 Z
11
+ date: 2015-12-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: " A slim ruby wrapper for posting to slack webhooks "
14
14
  email: