capistrano-pusher 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 591a30589281f4a1d15a2113a3ede58a135c1c22
4
+ data.tar.gz: e0535a241616b2ff89ad1b4143292cd7215e1cb7
5
+ SHA512:
6
+ metadata.gz: 81c40bd4f517c6e2381507720a34d2328957d3bda5d9aeef8f5b1e6ff00a05ca7eb9c23db76bfe2aaa60b0a485d978cc11645c778d9ec171b543ab57e241d444
7
+ data.tar.gz: fe2fb65fa768264f5957757eceb55be3a0f897d6001de1d61cbfb41ff564e64353bee17e2fb4a944060f2e240914b627b1a4edf1f30d355d817e8200e515269e
@@ -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
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - 2
3
+ - 2.1.0
4
+ - 2.0.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-pusher.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 seenmyfate
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.
@@ -0,0 +1,82 @@
1
+ # Capistrano Pusher [![Build Status](https://travis-ci.org/onthebeach/capistrano-pusher.svg)](https://travis-ci.org/onthebeach/capistrano-pusher) [![Code Climate](https://codeclimate.com/github/onthebeach/capistrano-pusher/badges/gpa.svg)](https://codeclimate.com/github/onthebeach/capistrano-pusher) [![Gem Version](https://badge.fury.io/rb/capistrano-pusher.svg)](http://badge.fury.io/rb/capistrano-pusher)
2
+
3
+ Publish deploy notifications to [Pusher](https://pusher.com) - for [Capistrano v3](https://github.com/capistrano/capistrano).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'capistrano-pusher'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install capistrano-pusher
18
+
19
+ ## Usage
20
+
21
+ Require the gem in your `Capfile`:
22
+
23
+ require 'capistrano/pusher'
24
+
25
+ And then set the required variables in `config/deploy.rb`:
26
+
27
+ set :pusher_url, 'http://abc:123@api.pusherapp.com/apps/0'
28
+
29
+ The task will run automatically on deploy. Alternatively, you can notify of a deploy started manually by using:
30
+
31
+ bundle exec cap production pusher:notify_started
32
+
33
+ Or to notify of a finished deploy:
34
+
35
+ bundle exec cap production pusher:notify_finished
36
+
37
+ By default, this will publish something along the lines of:
38
+
39
+ Revision 64a3c1de of my_app deployed to production by seenmyfate in 333 seconds.
40
+
41
+ If a deploy has failed, the following message will be published by default:
42
+
43
+ production deploy of my_app with revision/branch 64a3c1de failed
44
+
45
+ As with the other tasks, it is also possible to notify failures manually:
46
+
47
+ bundle exec cap production pusher:notify_failed
48
+
49
+ ### Customisation
50
+
51
+ Any of the defaults can be over-ridden in `config/deploy.rb`:
52
+
53
+ set :pusher_channel, 'capistrano'
54
+ set :pusher_user, ENV['GIT_AUTHOR_NAME']
55
+ set :pusher_payload, -> {
56
+ {
57
+ message: fetch(:pusher_message),
58
+ user: fetch(:pusher_user),
59
+ application: fetch(:application),
60
+ revision: fetch(:current_revision),
61
+ branch: fetch(:branch),
62
+ stage: fetch(:stage),
63
+ state: fetch(:pusher_state)
64
+ }
65
+ }
66
+ set :pusher_deploy_completed_text, -> {
67
+ elapsed = Integer(fetch(:time_finished) - fetch(:time_started))
68
+ "Revision #{fetch(:current_revision, fetch(:branch))} of " \
69
+ "#{fetch(:application)} deployed to #{fetch(:stage)} by #{fetch(:pusher_user)} " \
70
+ "in #{elapsed} seconds."
71
+ }
72
+ set :pusher_deploy_started_text, -> {
73
+ "#{fetch(:stage)} deploy started with revision/branch #{fetch(:current_revision, fetch(:branch))} for #{fetch(:application)}"
74
+ }
75
+ set :pusher_deploy_failed_text, -> {
76
+ "#{fetch(:stage)} deploy of #{fetch(:application)} with revision/branch #{fetch(:current_revision, fetch(:branch))} failed"
77
+ }
78
+
79
+ ### Copyright
80
+
81
+ Copyright (c) 2014 OnTheBeach Ltd. See LICENSE.txt for
82
+ further details.
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'capistrano-pusher'
7
+ spec.version = '1.0.0'
8
+ spec.authors = ['seenmyfate']
9
+ spec.email = ['seenmyfate@gmail.com']
10
+ spec.summary = %q{Publish deployment notifications to Pusher}
11
+ spec.description = %q{Publish deployment notifications to Pusher}
12
+ spec.homepage = ''
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_runtime_dependency 'pusher'
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.7'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'rspec'
25
+ end
File without changes
@@ -0,0 +1,15 @@
1
+ require 'pusher'
2
+ module Capistrano
3
+ class Push
4
+
5
+ def initialize(url, channel)
6
+ @url, @channel = url, channel
7
+ end
8
+
9
+ def trigger(state, payload)
10
+ Pusher.url = @url
11
+ Pusher[@channel].trigger(state, payload)
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,2 @@
1
+ require 'capistrano/push'
2
+ load File.expand_path('../tasks/pusher.cap', __FILE__)
@@ -0,0 +1,70 @@
1
+ namespace :pusher do
2
+ desc 'Notify Pusher of a deployment - :pusher_url must be set'
3
+ task :notify_started do
4
+ run_locally do
5
+ info 'Notifying Pusher of started deploy'
6
+ set :time_started, Time.now.to_i
7
+ set :pusher_message, fetch(:pusher_deploy_started_text)
8
+ set :pusher_state, :started
9
+ Capistrano::Push.new(fetch(:pusher_url), fetch(:pusher_channel)).
10
+ trigger(fetch(:pusher_state), fetch(:pusher_payload))
11
+ end
12
+ end
13
+ before 'deploy:starting', 'pusher:notify_started'
14
+
15
+ desc 'Notify Pusher of a deployment - :pusher_url must be set'
16
+ task :notify_finished do
17
+ run_locally do
18
+ info 'Notifying Pusher of completed deploy'
19
+ set :time_finished, Time.now.to_i
20
+ set :pusher_message, fetch(:pusher_deploy_finished_text)
21
+ set :pusher_state, :finished
22
+ Capistrano::Push.new(fetch(:pusher_url), fetch(:pusher_channel)).
23
+ trigger(fetch(:pusher_state), fetch(:pusher_payload))
24
+ end
25
+ end
26
+ after 'deploy:finished', 'pusher:notify_finished'
27
+
28
+ desc 'Notify Pusher of a deployment failure - :pusher_url must be set'
29
+ task :notify_failed do
30
+ run_locally do
31
+ info 'Notifying Pusher of failed deploy'
32
+ set :time_finished, Time.now.to_i
33
+ set :pusher_message, fetch(:pusher_deploy_failed_text)
34
+ set :pusher_state, :failed
35
+ Capistrano::Push.new(fetch(:pusher_url), fetch(:pusher_channel)).
36
+ trigger(fetch(:pusher_state), fetch(:pusher_payload))
37
+ end
38
+ end
39
+ after 'deploy:failed', 'pusher:notify_failed'
40
+ end
41
+
42
+ namespace :load do
43
+ task :defaults do
44
+ set :pusher_channel, 'capistrano'
45
+ set :pusher_user, ENV['GIT_AUTHOR_NAME']
46
+ set :pusher_payload, -> {
47
+ {
48
+ message: fetch(:pusher_message),
49
+ user: fetch(:pusher_user),
50
+ application: fetch(:application),
51
+ revision: fetch(:current_revision),
52
+ branch: fetch(:branch),
53
+ stage: fetch(:stage),
54
+ state: fetch(:pusher_state)
55
+ }
56
+ }
57
+ set :pusher_deploy_completed_text, -> {
58
+ elapsed = Integer(fetch(:time_finished) - fetch(:time_started))
59
+ "Revision #{fetch(:current_revision, fetch(:branch))} of " \
60
+ "#{fetch(:application)} deployed to #{fetch(:stage)} by #{fetch(:pusher_user)} " \
61
+ "in #{elapsed} seconds."
62
+ }
63
+ set :pusher_deploy_started_text, -> {
64
+ "#{fetch(:stage)} deploy started with revision/branch #{fetch(:current_revision, fetch(:branch))} for #{fetch(:application)}"
65
+ }
66
+ set :pusher_deploy_failed_text, -> {
67
+ "#{fetch(:stage)} deploy of #{fetch(:application)} with revision/branch #{fetch(:current_revision, fetch(:branch))} failed"
68
+ }
69
+ end
70
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+ require 'capistrano/push'
3
+
4
+ module Capistrano
5
+
6
+ describe Push do
7
+ let(:pusher) { Push.new(pusher_url, pusher_channel) }
8
+ let(:pusher_url) { 'http://abc:123@api.pusherapp.com/apps/0' }
9
+ let(:pusher_channel) { 'capistrano' }
10
+
11
+ describe '.new' do
12
+ it 'takes a url and a channel' do
13
+ expect(pusher)
14
+ end
15
+ end
16
+
17
+ describe '#trigger' do
18
+ let(:channel) { instance_double('Pusher::Channel') }
19
+ let(:pusher_payload) { double }
20
+ let(:pusher_state) { double }
21
+
22
+ it 'delegates to Pusher' do
23
+ expect(Pusher).to receive(:[]).with(pusher_channel).and_return(channel)
24
+ expect(channel).to receive(:trigger).with(pusher_state, pusher_payload)
25
+
26
+ pusher.trigger(pusher_state, pusher_payload)
27
+ end
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,7 @@
1
+ require 'rspec'
2
+
3
+ RSpec.configure do |rspec|
4
+ rspec.mock_with :rspec do |mocks|
5
+ mocks.verify_doubled_constant_names = true
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-pusher
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - seenmyfate
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pusher
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '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'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
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
+ description: Publish deployment notifications to Pusher
70
+ email:
71
+ - seenmyfate@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - capistrano-pusher.gemspec
83
+ - lib/capistrano-pusher.rb
84
+ - lib/capistrano/push.rb
85
+ - lib/capistrano/pusher.rb
86
+ - lib/capistrano/tasks/pusher.cap
87
+ - spec/lib/capistrano/push_spec.rb
88
+ - spec/spec_helper.rb
89
+ homepage: ''
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.4.2
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Publish deployment notifications to Pusher
113
+ test_files:
114
+ - spec/lib/capistrano/push_spec.rb
115
+ - spec/spec_helper.rb