slack-webhook 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ab7ad797eaae0e58378bf7323642c3b20f0cdad2
4
+ data.tar.gz: 6b53436d4e151770720258b52e10f7b6e7a12740
5
+ SHA512:
6
+ metadata.gz: 0a4a044d340e03e1d0afb7c531f772e71605d0a0fa884da263739357d94f9de8be33990c72f33a78bf13f4acf8056b6a57837bebbb8915a017ec6be80fbdf13d
7
+ data.tar.gz: e2a1af6ae34a46a0498220aa662a6a974c2820e1ee325fe3ee2b1f82ec875a20d58eadf718b8b866bb00587fbccc4494f5280a491e18e785b3e60bfde9e18859
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in slack.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Jeffrey Warren
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Slack Webhook Gem
2
+
3
+ A simple ruby gem for getting functionality out of Slack's webhooks.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'slack'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install slack
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ Slack.configure do |config|
25
+ config.channel = '#engineering' # or '@jeff'
26
+ config.icon_emoji = ':ghost:'
27
+ config.url = 'https://hooks.slack.com/services/id_1/id_2/token'
28
+ config.username = 'deploybot'
29
+ end
30
+ ```
31
+
32
+ Example usage in capistrano to notify deployments
33
+
34
+ ```ruby
35
+ task :notify_start do
36
+ if ['production', 'staging'].include?(fetch(:rails_env))
37
+ Slack.post("Deploying `#{fetch(:branch)}` to `#{fetch(:rails_env)}`")
38
+ end
39
+ end
40
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/lib/slack.rb ADDED
@@ -0,0 +1,46 @@
1
+ require "slack/version"
2
+ require 'json'
3
+ require 'net/http'
4
+ require 'uri'
5
+
6
+ module Slack
7
+
8
+ class << self
9
+ attr_accessor :configuration
10
+ end
11
+
12
+ def self.configure
13
+ self.configuration ||= Configuration.new
14
+ yield(configuration)
15
+ end
16
+
17
+ class Configuration
18
+ attr_accessor :channel, :icon_emoji, :url, :username
19
+
20
+ def initialize
21
+ @channel = '#general'
22
+ @icon_emoji = ':ghost:'
23
+ @url = ''
24
+ @username = 'slackbot'
25
+ end
26
+ end
27
+
28
+ def self.post(message)
29
+ channel = Slack.configuration.channel
30
+ icon_emoji = Slack.configuration.icon_emoji
31
+ url = Slack.configuration.url
32
+ username = Slack.configuration.username
33
+
34
+ uri = URI(url)
35
+ req = Net::HTTP::Post.new uri.path
36
+
37
+ req.body = {"channel" => channel, "username" => username, "text" => "<!channel> #{message}", "icon_emoji" => icon_emoji}.to_json
38
+
39
+ res = Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
40
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
41
+ http.ssl_version = :SSLv3
42
+ http.request req
43
+ end
44
+ end
45
+ end
46
+
@@ -0,0 +1,3 @@
1
+ module Slack
2
+ VERSION = "1.0.0"
3
+ end
data/slack.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'slack/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "slack-webhook"
8
+ spec.version = Slack::VERSION
9
+ spec.authors = ["Jeffrey Warren"]
10
+ spec.email = ["jtwarren@alum.mit.edu"]
11
+ spec.summary = %q{Provides basic slack webhook functionality}
12
+ spec.description = ""
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: slack-webhook
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jeffrey Warren
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: ''
42
+ email:
43
+ - jtwarren@alum.mit.edu
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - lib/slack.rb
54
+ - lib/slack/version.rb
55
+ - slack.gemspec
56
+ homepage: ''
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.4.5
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Provides basic slack webhook functionality
80
+ test_files: []