slack-notifier 0.0.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 +7 -0
- data/lib/slack-notifier.rb +42 -0
- data/lib/slack-notifier/version.rb +5 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a218d8098c4a507b24dfabf7d41c1b97cbdddcf8
|
4
|
+
data.tar.gz: c1032a1bec30c243919bc765f176780bb18197a7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1d3a04d6314781ec07df75aed2d0734543ba31228744fd20169c44613527364e4832cac10140505757ec66cdaab0ef4cdcbc11ff1af1568a59ff4d0a77530e7c
|
7
|
+
data.tar.gz: 3bfd02e02985ee952a363d0155fd6f695b6f4bc75cc1bef52026be541bb9d870d0938c32a2aabf714514b04b817255ab33fcac9ac9c8f732a1e6bb99b9ba4e85
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Slack
|
5
|
+
class Notifier
|
6
|
+
|
7
|
+
# these act as defaults
|
8
|
+
# if they are set
|
9
|
+
attr_accessor :channel, :username
|
10
|
+
|
11
|
+
attr_reader :team, :token
|
12
|
+
|
13
|
+
def initialize team, token
|
14
|
+
@team = team
|
15
|
+
@token = token
|
16
|
+
end
|
17
|
+
|
18
|
+
def ping message, options={}
|
19
|
+
payload = { text: message }.merge(default_payload).merge(options)
|
20
|
+
|
21
|
+
unless payload.has_key? :channel
|
22
|
+
raise ArgumentError, "You must set a channel"
|
23
|
+
end
|
24
|
+
|
25
|
+
HTTParty.post( endpoint, body: "payload=#{payload.to_json}" )
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def default_payload
|
31
|
+
payload = {}
|
32
|
+
payload[:channel] = team if team
|
33
|
+
payload[:username] = username if username
|
34
|
+
payload
|
35
|
+
end
|
36
|
+
|
37
|
+
def endpoint
|
38
|
+
"https://#{team}.slack.com/services/hooks/incoming-webhook?token=#{token}"
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: slack-notifier
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Steven Sloan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.11.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.11.0
|
27
|
+
description: ' A simple wrapper for posting to slack channels '
|
28
|
+
email:
|
29
|
+
- stevenosloan@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- lib/slack-notifier/version.rb
|
35
|
+
- lib/slack-notifier.rb
|
36
|
+
homepage: http://github.com/stevenosloan/slack-notifier
|
37
|
+
licenses:
|
38
|
+
- MIT
|
39
|
+
metadata: {}
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 2.0.5
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: A simple wrapper for posting to slack channels
|
60
|
+
test_files: []
|