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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9488331ba45f6066c5fddfd33cff93decc0b3cc
4
- data.tar.gz: 8f2c3e47025f193555be8e2b4d41114ce18c44fc
3
+ metadata.gz: 3f3a835e3d30231ed9e4c919c51ce4c86b764b86
4
+ data.tar.gz: 89a11e8605b153da0088183bb5815b0bbfdd4b91
5
5
  SHA512:
6
- metadata.gz: 67eb4e6be927f15387c05ed3c0a70c3c2d4f620635eb145106e4734561334854c859d3080917cf72ea246d9d58cd0e68d8411b582c1875dd4909084369926cdb
7
- data.tar.gz: 5463129c70110bdd2cbf39eda765ba711b231a8b50cff985f88accb840c3e8b8437d132b051dcb3f45a4d27149e6783926b694a115d4bf96f716dcefedbf4a7f
6
+ metadata.gz: 7228dc1c0f67c4ea49b58ca0222dada15d127183a337d07fb7ed2657315ccc3e16f6437f132e036427f89474b4c425ac7f9f292612f4a605c777d8c610dfd147
7
+ data.tar.gz: a23cc7528b0da09f0bee4737205ac68ae543950ffa5218a24fb773d0dae9f655d58d37d2a5f740355159bc76e0d5d7709af0a63b760f4c5a3c0b3b0b73a491d3
@@ -1,3 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.1.5
4
+ script: bundle exec rspec spec
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, :payload
13
+ attr_accessor :webhook_url
14
14
 
15
- def initialize(webhook_url, payload={})
15
+ def initialize(webhook_url, options={})
16
16
  @webhook_url = webhook_url
17
- @payload = payload
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
- def channel
5
- payload[:channel]
6
- end
7
-
8
- def channel= channel
9
- payload[:channel] = channel
10
- end
11
-
12
- def username
13
- payload[:username]
14
- end
15
-
16
- def username= username
17
- payload[:username] = username
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
- def attachments
21
- payload[:attachments]
22
- end
19
+ attr_accessor(*VALID_OPTIONS_KEYS)
23
20
 
24
- def attachments= attachments
25
- payload[:attachments] = [attachments]
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
@@ -1,7 +1,7 @@
1
1
  module Slack
2
2
  module Incoming
3
3
  class Webhooks
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
6
6
  end
7
7
  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", "~> 1.9"
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.1.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: '1.9'
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: '1.9'
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.2.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.