capistrano-haller 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/CHANGELOG +11 -0
- data/Gemfile +4 -0
- data/LICENSE +18 -0
- data/README.md +43 -0
- data/Rakefile +7 -0
- data/VERSION +1 -0
- data/capistrano-haller.gemspec +16 -0
- data/lib/capistrano/haller.rb +31 -0
- data/lib/haller.rb +58 -0
- data/resources/capistrano-logo.png +0 -0
- data/test/haller_test.rb +28 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 17dda265210d1a6e106c69b813e14601f5537a06
|
4
|
+
data.tar.gz: cb29cacb16436d0c8a81a5322839cf3318ca6c7a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a6e27b7c80c7f1c9f3c9fc50d10825c454e1a93e991fc6b8b1fa4ee5413f43734629310d5303868e8844a621f54642f1d253aa1ddce46cf64df13e363ae0c631
|
7
|
+
data.tar.gz: 9de3c3ff9f9ef4efdeb7a8fb67ad2b7f3fb13dfcc24a1c842436c6b786f30aa09d4508cbda08fd7c6287d60da74dcac7d8ed87eb00646a935a76416859ffdf49
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Gemfile.lock
|
data/CHANGELOG
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Copyright (c) 2011-2013 Dan Sosedoff.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to
|
8
|
+
do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
14
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
15
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
16
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
17
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
18
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Capistrano Haller
|
2
|
+
|
3
|
+
Notifies team members by posting to your hall channel when you deploy your code.
|
4
|
+
|
5
|
+
### Installation
|
6
|
+
|
7
|
+
Gemfile
|
8
|
+
``` ruby
|
9
|
+
gem 'capistrano-haller', require: false
|
10
|
+
```
|
11
|
+
|
12
|
+
`bundle install`
|
13
|
+
|
14
|
+
deploy.rb
|
15
|
+
``` ruby
|
16
|
+
require 'capistrano/haller'
|
17
|
+
set :hall_room_key, 'xxx'
|
18
|
+
set :hall_message, "Branch #{branch} was deployed to #{rails_env}."
|
19
|
+
```
|
20
|
+
|
21
|
+
Test
|
22
|
+
`cap hall_notify:notify_hall_room`
|
23
|
+
|
24
|
+
The `hall_notify:notify_hall_room` will run after `deploy`.
|
25
|
+
|
26
|
+
##### Warning
|
27
|
+
master is not stable!
|
28
|
+
|
29
|
+
### Contributing and Support
|
30
|
+
|
31
|
+
Please use GH issues for bug reports and feature requests.
|
32
|
+
|
33
|
+
To contribute, fork and submit a pull request.
|
34
|
+
|
35
|
+
### Compatability
|
36
|
+
|
37
|
+
This plugin is intended for Capistrano version 2.x, and is meant to run in rails deploy scripts. However, it should work in capistrano script that sets the `branch` and `rails_env` variables.
|
38
|
+
|
39
|
+
### License
|
40
|
+
|
41
|
+
MIT
|
42
|
+
|
43
|
+
See `LICENSE`
|
data/Rakefile
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.4
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "capistrano-haller"
|
3
|
+
spec.version = File.open(File.expand_path('../VERSION', __FILE__)).read
|
4
|
+
spec.author = "Jack Forrest"
|
5
|
+
spec.email = "jack@smashingboxes.com"
|
6
|
+
spec.homepage = "https://github.com/smashingboxes/capistrano-haller"
|
7
|
+
spec.summary = %q{Hall chat notifications for capistrano deploys}
|
8
|
+
spec.description = %q{Posts messages in hall channels after capistrano deployes}
|
9
|
+
spec.license = "MIT"
|
10
|
+
|
11
|
+
spec.files = `git ls-files`.split("\n")
|
12
|
+
spec.require_paths = ["lib"]
|
13
|
+
|
14
|
+
spec.add_runtime_dependency "capistrano", "< 3.0"
|
15
|
+
spec.add_development_dependency "rake"
|
16
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
require 'haller'
|
3
|
+
|
4
|
+
Haller::CAPISTRANO_THUMB_URL =
|
5
|
+
'https://raw.github.com/smashingboxes/capistrano-haller/master/resources/capistrano-logo.png'
|
6
|
+
|
7
|
+
configuration = if Capistrano::Configuration.respond_to?(:instance)
|
8
|
+
Capistrano::Configuration.instance(:must_exist)
|
9
|
+
else
|
10
|
+
Capistrano.configuration(:must_exist)
|
11
|
+
end
|
12
|
+
|
13
|
+
configuration.load do
|
14
|
+
namespace :hall_notify do
|
15
|
+
desc "Notify a hall channel of deployment"
|
16
|
+
task :notify_hall_room do
|
17
|
+
if not exists?(:hall_room_key) or hall_room_key.empty?
|
18
|
+
logger.important("You must set hall_room_key for hall notifications to work!")
|
19
|
+
else
|
20
|
+
begin
|
21
|
+
Haller.new(hall_room_key,
|
22
|
+
sender_icon_url: Haller::CAPISTRANO_THUMB_URL,
|
23
|
+
).send_message( exists?(:hall_message) ? hall_message : "Branch #{branch} was deployed to #{rails_env}.")
|
24
|
+
rescue Haller::HallApiError => e
|
25
|
+
logger.important("Could not contact hall API for deployment notification.")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
after 'deploy', 'hall_notify:notify_hall_room'
|
30
|
+
end
|
31
|
+
end
|
data/lib/haller.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'net/https'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class Haller
|
5
|
+
class HallApiError < StandardError; end
|
6
|
+
ROOT_URI = 'https://hall.com'
|
7
|
+
ENDPOINT = '/api/1/services/generic/'
|
8
|
+
|
9
|
+
OPTION_DEFAULTS = {
|
10
|
+
sender_title: 'Haller',
|
11
|
+
sender_icon_url: nil}
|
12
|
+
|
13
|
+
attr_accessor :room_key
|
14
|
+
attr_accessor :options
|
15
|
+
|
16
|
+
def initialize(room_key, options = {})
|
17
|
+
@options = OPTION_DEFAULTS.merge(options)
|
18
|
+
@room_key = room_key
|
19
|
+
end
|
20
|
+
|
21
|
+
def send_message(message)
|
22
|
+
post(message_json(message))
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
|
27
|
+
def full_path
|
28
|
+
ENDPOINT + room_key
|
29
|
+
end
|
30
|
+
|
31
|
+
def uri
|
32
|
+
URI.parse(ROOT_URI)
|
33
|
+
end
|
34
|
+
|
35
|
+
def post(json)
|
36
|
+
req = Net::HTTP::Post.new(full_path, {'Content-Type' => 'application/json'})
|
37
|
+
req.body = json
|
38
|
+
|
39
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
40
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
41
|
+
http.use_ssl = true
|
42
|
+
|
43
|
+
begin
|
44
|
+
response = http.request(req)
|
45
|
+
unless ['200', '201'].include?(response.code)
|
46
|
+
raise StandardError, "HTTP Status: #{response.code}"
|
47
|
+
end
|
48
|
+
rescue StandardError => e
|
49
|
+
raise HallApiError, e.message
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def message_json(body)
|
54
|
+
{ title: options[:sender_title],
|
55
|
+
message: body,
|
56
|
+
picture: options[:sender_icon_url]}.to_json
|
57
|
+
end
|
58
|
+
end
|
Binary file
|
data/test/haller_test.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'haller'
|
3
|
+
|
4
|
+
class TestHaller < Minitest::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@haller = Haller.new('testkey')
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_fails_softly_on_network_error
|
10
|
+
Net::HTTP.stub :new, mock_broken_http do
|
11
|
+
assert_raises(Haller::HallApiError) { @haller.send_message('anyang!') }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
def mock_broken_http
|
18
|
+
http = Minitest::Mock.new
|
19
|
+
http.expect :verify_mode=, nil, [OpenSSL::SSL::VERIFY_NONE]
|
20
|
+
http.expect :use_ssl=, nil, [true]
|
21
|
+
|
22
|
+
def http.request(req)
|
23
|
+
raise SocketError
|
24
|
+
end
|
25
|
+
|
26
|
+
return http
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-haller
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jack Forrest
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-06 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: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Posts messages in hall channels after capistrano deployes
|
42
|
+
email: jack@smashingboxes.com
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- .gitignore
|
48
|
+
- CHANGELOG
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- VERSION
|
54
|
+
- capistrano-haller.gemspec
|
55
|
+
- lib/capistrano/haller.rb
|
56
|
+
- lib/haller.rb
|
57
|
+
- resources/capistrano-logo.png
|
58
|
+
- test/haller_test.rb
|
59
|
+
homepage: https://github.com/smashingboxes/capistrano-haller
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.1.11
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: Hall chat notifications for capistrano deploys
|
83
|
+
test_files: []
|