capistrano-slackbot 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 34a33cc2a1935244889836bacbc80f12a40d2b2e
4
+ data.tar.gz: ccdc400d0d24eac909957bcd3c0b1fde165cf138
5
+ SHA512:
6
+ metadata.gz: 7bc3a6d0b73fee64466f9cdb74687faf3b43ffc90196c939ba3d9ef9ef44eb32109f0e9446635f1aaefac1d0650313fef92be24a00e9c9258973f4a377d68ef4
7
+ data.tar.gz: f74646c60da48222288cd57998cf9f08e87c30b09a68969cca4fb0638a76fe68a4414cc2e055cdc79ad5fb82baad14367b2412998e534a3dbab588e943ea89fa
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
4
+ - 2.1.0
5
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-slackbot.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Mikhail Topolskiy
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,45 @@
1
+ # Capistrano::Slackbot
2
+
3
+ Slack intergation for Capistrano 3.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+ ```yaml
9
+ gem "capistrano-slackbot"
10
+ ```
11
+
12
+ And then execute:
13
+ ```bash
14
+ $ bundle
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ Add capistrano/slackbot to your Capfile:
20
+ ```ruby
21
+ # Capfile
22
+
23
+ require "capistrano/slackbot"
24
+ ```
25
+
26
+ Then add some configuation options to your deploy.rb:
27
+ ```ruby
28
+ # deploy.rb
29
+
30
+ set :slack_team, "your-team"
31
+ set :slack_token, ENV["SLACK_TOKEN"] # from your "Incoming Webhook" integration
32
+ set :slack_options, { channel: "#general", icon_emoji: ":shipit:" } # arbitrary additional options passed to slack
33
+ ```
34
+
35
+ And deploy away!
36
+
37
+ ![capistrano-slackbot](https://googledrive.com/host/0B03_MIH-1qgoX3A4OWh5djFWUmc/capistrano-slackbot.png)
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it ( https://github.com/[my-github-username]/capistrano-slackbot/fork )
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require "rspec/core/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano/slackbot/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capistrano-slackbot"
8
+ spec.version = Capistrano::Slackbot::VERSION
9
+ spec.authors = ["Mikhail Topolskiy"]
10
+ spec.email = ["mikhail.topolskiy@gmail.com"]
11
+ spec.summary = %q{Slack integration for Capistrano 3}
12
+ spec.description = %q{Send capistrano deployment notificatons to https://slack.com/}
13
+ spec.homepage = "https://github.com/whatthewhat/capistrano-slackbot"
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_dependency "capistrano", ">= 3.0"
22
+ spec.add_dependency "faraday"
23
+
24
+ spec.add_development_dependency "bundler", "> 1.0"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec", "~> 3.0.0.beta2"
27
+ spec.add_development_dependency "webmock", "~> 1.17.4"
28
+ end
@@ -0,0 +1,29 @@
1
+ require "json"
2
+ require "faraday"
3
+
4
+ class SlackNotifier
5
+ def initialize(args = {})
6
+ @team = args.fetch(:team) { raise ArgumentError, "slack team not set!" }
7
+ @token = args.fetch(:token) { raise ArgumentError, "slack token not set!" }
8
+ @options = args.fetch(:options) { {} }
9
+ end
10
+
11
+ def notify(text)
12
+ payload = { text: text }.merge(@options)
13
+
14
+ connection.post url, payload.to_json
15
+ end
16
+
17
+ private
18
+ def url
19
+ "https://#{ @team }.slack.com/services/hooks/incoming-webhook?token=#{ @token }"
20
+ end
21
+
22
+ def connection
23
+ Faraday.new do |faraday|
24
+ faraday.headers['Content-Type'] = 'application/json'
25
+ faraday.headers['Content-Encoding'] = 'UTF-8'
26
+ faraday.adapter Faraday.default_adapter
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Slackbot
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ require "capistrano/slackbot/version"
2
+ require "capistrano/slackbot/slack_notifier"
3
+
4
+ load File.expand_path('../tasks/slack.rake', __FILE__)
@@ -0,0 +1,13 @@
1
+ namespace :slack do
2
+ task :finished do
3
+ SlackNotifier.new(
4
+ team: fetch(:slack_team),
5
+ token: fetch(:slack_token),
6
+ options: fetch(:slack_options, {})
7
+ ).notify(revision_log_message)
8
+ end
9
+ end
10
+
11
+ namespace :deploy do
12
+ after :finishing, "slack:finished"
13
+ end
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+ require "capistrano/slackbot/slack_notifier"
3
+
4
+ describe SlackNotifier do
5
+ before(:each) do
6
+ stub_request(:post, /slack.com/)
7
+ end
8
+
9
+ describe "#notify" do
10
+ subject {
11
+ SlackNotifier.new(
12
+ team: "some-team",
13
+ token: "secret_token",
14
+ options: { custom_option: "hello there" }
15
+ )
16
+ }
17
+
18
+ it "posts to slack's webhook with right params" do
19
+ subject.notify("Oh Hai!")
20
+
21
+ expect(WebMock).to have_requested(:post,
22
+ "https://some-team.slack.com/services/hooks/incoming-webhook?token=secret_token"
23
+ ).with( body: { text: "Oh Hai!", custom_option: "hello there" }.to_json )
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,8 @@
1
+ require 'bundler/setup'
2
+
3
+ require 'webmock/rspec'
4
+ WebMock.disable_net_connect!(allow_localhost: true)
5
+
6
+ RSpec.configure do |config|
7
+ config.order = "random"
8
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-slackbot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mikhail Topolskiy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>'
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>'
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 3.0.0.beta2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 3.0.0.beta2
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 1.17.4
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 1.17.4
97
+ description: Send capistrano deployment notificatons to https://slack.com/
98
+ email:
99
+ - mikhail.topolskiy@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - .travis.yml
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - capistrano-slackbot.gemspec
111
+ - lib/capistrano/slackbot.rb
112
+ - lib/capistrano/slackbot/slack_notifier.rb
113
+ - lib/capistrano/slackbot/version.rb
114
+ - lib/capistrano/tasks/slack.rake
115
+ - spec/slack_notifier_spec.rb
116
+ - spec/spec_helper.rb
117
+ homepage: https://github.com/whatthewhat/capistrano-slackbot
118
+ licenses:
119
+ - MIT
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.0.14
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: Slack integration for Capistrano 3
141
+ test_files:
142
+ - spec/slack_notifier_spec.rb
143
+ - spec/spec_helper.rb