slack-incoming-webhooks 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +7 -4
- data/lib/slack/incoming/webhooks.rb +3 -3
- data/lib/slack/incoming/webhooks/configuration.rb +20 -20
- data/lib/slack/incoming/webhooks/version.rb +1 -1
- data/slack-incoming-webhooks.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f3a835e3d30231ed9e4c919c51ce4c86b764b86
|
4
|
+
data.tar.gz: 89a11e8605b153da0088183bb5815b0bbfdd4b91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7228dc1c0f67c4ea49b58ca0222dada15d127183a337d07fb7ed2657315ccc3e16f6437f132e036427f89474b4c425ac7f9f292612f4a605c777d8c610dfd147
|
7
|
+
data.tar.gz: a23cc7528b0da09f0bee4737205ac68ae543950ffa5218a24fb773d0dae9f655d58d37d2a5f740355159bc76e0d5d7709af0a63b760f4c5a3c0b3b0b73a491d3
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# Slack::Incoming::Webhooks
|
2
|
+
[![Build Status](https://travis-ci.org/shoyan/slack-incoming-webhooks.svg)](https://travis-ci.org/shoyan/slack-incoming-webhooks)
|
3
|
+
|
2
4
|
A simple wrapper for posting to slack.
|
3
5
|
|
4
6
|
## Example
|
@@ -32,19 +34,20 @@ Or install it yourself as:
|
|
32
34
|
|
33
35
|
### Setting Defaults
|
34
36
|
On initialization you can set default payloads by passing an options hash.
|
35
|
-
Options please refer to [incoming-webhooks](https://api.slack.com/incoming-webhooks).
|
37
|
+
Options please refer to [incoming-webhooks](https://api.slack.com/incoming-webhooks) and [chat.postMessage](https://api.slack.com/methods/chat.postMessage).
|
38
|
+
.
|
36
39
|
|
37
40
|
```ruby
|
38
41
|
slack = Slack::Incoming::Webhooks.new "WEBHOOK_URL", channel: '#other-channel',
|
39
42
|
username: 'monkey-bot'
|
40
43
|
```
|
41
44
|
|
42
|
-
Once a notifier has been initialized, you can update the default channel or username or attachments .
|
45
|
+
Once a notifier has been initialized, you can update the default channel or username or attachments or etc.
|
43
46
|
|
44
47
|
```ruby
|
45
48
|
slack.channel = '#other-channel'
|
46
49
|
slack.username = 'monkey-bot'
|
47
|
-
slack.attachments = { color: '#36a64f', title: 'Slack API Documentation' }
|
50
|
+
slack.attachments = [{ color: '#36a64f', title: 'Slack API Documentation' }]
|
48
51
|
```
|
49
52
|
|
50
53
|
### Attachments
|
@@ -75,7 +78,7 @@ slack.post "with an attachment"
|
|
75
78
|
or attachments method.
|
76
79
|
|
77
80
|
```ruby
|
78
|
-
slack.attachments = { color: '#36a64f', title: 'Slack API Documentation' }
|
81
|
+
slack.attachments = [{ color: '#36a64f', title: 'Slack API Documentation' }]
|
79
82
|
```
|
80
83
|
## Console
|
81
84
|
run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -10,11 +10,11 @@ module Slack
|
|
10
10
|
include Connection
|
11
11
|
include Request
|
12
12
|
|
13
|
-
attr_accessor :webhook_url
|
13
|
+
attr_accessor :webhook_url
|
14
14
|
|
15
|
-
def initialize(webhook_url,
|
15
|
+
def initialize(webhook_url, options={})
|
16
16
|
@webhook_url = webhook_url
|
17
|
-
|
17
|
+
options.each { |key, val| send("#{key}=", val) }
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -1,28 +1,28 @@
|
|
1
1
|
module Slack
|
2
2
|
module Incoming
|
3
3
|
module Configuration
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
4
|
+
VALID_OPTIONS_KEYS = [
|
5
|
+
:token,
|
6
|
+
:channel,
|
7
|
+
:text,
|
8
|
+
:username,
|
9
|
+
:attachments,
|
10
|
+
:as_user,
|
11
|
+
:parse,
|
12
|
+
:link_names,
|
13
|
+
:unfurl_links,
|
14
|
+
:unfurl_media,
|
15
|
+
:icon_url,
|
16
|
+
:icon_emoji
|
17
|
+
].freeze
|
19
18
|
|
20
|
-
|
21
|
-
payload[:attachments]
|
22
|
-
end
|
19
|
+
attr_accessor(*VALID_OPTIONS_KEYS)
|
23
20
|
|
24
|
-
def
|
25
|
-
|
21
|
+
def payload
|
22
|
+
VALID_OPTIONS_KEYS.inject({}) do |o, k|
|
23
|
+
o.merge!(k => send(k)) unless send(k).nil?
|
24
|
+
o
|
25
|
+
end
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -19,6 +19,6 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_development_dependency "bundler"
|
22
|
+
spec.add_development_dependency "bundler"
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack-incoming-webhooks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shohei Yamasaki
|
@@ -14,16 +14,16 @@ dependencies:
|
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
81
|
version: '0'
|
82
82
|
requirements: []
|
83
83
|
rubyforge_project:
|
84
|
-
rubygems_version: 2.
|
84
|
+
rubygems_version: 2.4.5
|
85
85
|
signing_key:
|
86
86
|
specification_version: 4
|
87
87
|
summary: A simple wrapper for posting to slack.
|