slack-notify 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e75c555cef9d6c7b413b5ab5ae37baa9f7c9a02
4
- data.tar.gz: d2c6913f055d0786e00d1bfe0fb27316e4298d9a
3
+ metadata.gz: 00ae9577d0c514b298a64e4516e24b1b3a888e11
4
+ data.tar.gz: 168e894c3fbc4206e0451bb9ff626b2232f6a23b
5
5
  SHA512:
6
- metadata.gz: 35134ea19abf2ea554e5ac308f759e9093671633e8fd7f9e88bff2093c5dfe720e16c17f86565fa596d571acecb4c7a17e5da690332454883405a1c74d3f6f12
7
- data.tar.gz: a5d8b639e4c2f0eebc812a6f6b558c4b5ebac6a7e7bfb02f7af78eeec1819e6f431c1b31d56e6fd0d78a0f1374270ee124ceec92b3188c10d39c98ba01d66f3c
6
+ metadata.gz: 3ae2ba9457d0f19474275265e844a8fd2461d6e7ee1154bd990cc4f3238ae7c23bf1d327c9e3e6d598e1b99cdb3d41f5a7720b7072560fbe16f318549dc9e016
7
+ data.tar.gz: e56fd9be21863aa0f1ce9656063918ec059383318b526f50cac12184ba9c5cd227869432a5f3596886ec967ed139a9864dc47134ee4ea822c770e03e370a15cd
data/README.md CHANGED
@@ -59,12 +59,18 @@ client.notify("Another message", "#channel2")
59
59
  client.notify("Message", ["#channel1", "#channel2"])
60
60
  ```
61
61
 
62
+ Send direct message:
63
+
64
+ ```ruby
65
+ client.notify("Hello There!", "@username")
66
+ ```
67
+
62
68
  ## Gotchas
63
69
 
64
- Some of the issues while Slack is in beta:
70
+ Current issues with Slack API:
65
71
 
66
- - No message raised if domain is not valid
67
- - Slack raises error 500 on bad request
72
+ - No message raised if team subdomain is invalid
73
+ - 500 server error is raised on bad requests
68
74
 
69
75
  ## License
70
76
 
data/lib/slack-notify.rb CHANGED
@@ -33,7 +33,7 @@ module SlackNotify
33
33
 
34
34
  def format_channel(channel)
35
35
  [channel || @channel].flatten.compact.uniq.map do |name|
36
- name[0] != "#" ? "##{name}" : name
36
+ name[0].match(/^(#|@)/) && name || "##{name}"
37
37
  end
38
38
  end
39
39
 
@@ -72,4 +72,4 @@ module SlackNotify
72
72
  "https://#{@team}.slack.com"
73
73
  end
74
74
  end
75
- end
75
+ end
@@ -1,3 +1,3 @@
1
1
  module SlackNotify
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -139,6 +139,17 @@ describe SlackNotify::Client do
139
139
  end
140
140
  end
141
141
 
142
+ context "when direct message" do
143
+ before do
144
+ client.stub(:send_payload).and_return(true)
145
+ client.notify("Message", "@user")
146
+ end
147
+
148
+ it "sends payload to a user" do
149
+ expect(client).to have_received(:send_payload).with(text: "Message", username: "webhookbot", channel: "@user")
150
+ end
151
+ end
152
+
142
153
  context "when team name is invalid" do
143
154
  before do
144
155
  stub_request(:post, "https://foo.slack.com/services/hooks/incoming-webhook?token=token").
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-notify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Sosedoff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-11 00:00:00.000000000 Z
11
+ date: 2014-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler