talking-capistrano 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in talking-capistrano.gemspec
4
+ gemspec
5
+
6
+ gem "capistrano"
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Avner Cohen
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,35 @@
1
+ # Talking::Capistrano
2
+
3
+ Capisrano task to notify start|end|erros of a capistrano deploy execution
4
+
5
+ * Current code is based on thr `say` command in OSX, espeak can also be used, however, I didn't bother yet. PR always welcome
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'talking-capistrano'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install talking-capistrano
20
+
21
+ ## Usage
22
+
23
+ Simply add:
24
+
25
+ require 'talking-capistrano'
26
+
27
+ In your deploy.rb, enjoy
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ module Talking
2
+ module Capistrano
3
+ VERSION = "0.0.4"
4
+ end
5
+ end
@@ -0,0 +1,30 @@
1
+ {"voices": [
2
+ "Agnes",
3
+ "Albert",
4
+ "Alex",
5
+ "Bad",
6
+ "News",
7
+ "Bahh",
8
+ "Bells",
9
+ "Boing",
10
+ "Bruce",
11
+ "Bubbles",
12
+ "Cellos",
13
+ "Deranged",
14
+ "Fred",
15
+ "Good News",
16
+ "Hysterical",
17
+ "Junior",
18
+ "Kathy",
19
+ "Pipe Organ",
20
+ "Princess",
21
+ "Ralph",
22
+ "Trinoids",
23
+ "Vicki",
24
+ "Victoria",
25
+ "Whisper",
26
+ "Zarvox"],
27
+ "say_deploy_completed": ["Deploying to - ENV - Completed!"],
28
+ "say_deploy_failed": ["Oops, Deploying to - ENV - went kaakehn!"],
29
+ "say_deploy_started": ["Deploying to - ENV - Yahllah!"]
30
+ }
@@ -0,0 +1,68 @@
1
+ require 'capistrano'
2
+
3
+ require "talking-capistrano/version"
4
+
5
+ require 'JSON'
6
+
7
+ module TalkingCapistrano
8
+ @DATA_SET = JSON.load( File.read(File.join(File.dirname(__FILE__), '/talking-capistrano.json' )) )
9
+ def self.say_deploy_started(rails_env ="unknown env")
10
+ get_item(:say_deploy_started).sub! "ENV", rails_env
11
+ end
12
+ def self.say_deploy_completed(rails_env ="unknown env")
13
+ get_item(:say_deploy_completed).sub! "ENV", rails_env
14
+ end
15
+ def self.say_deploy_failed(rails_env ="unknown env")
16
+ get_item(:say_deploy_failed).sub! "ENV", rails_env
17
+ end
18
+ def self.say_speaker_name
19
+ get_item(:voices)
20
+ end
21
+
22
+ private
23
+
24
+ def self.get_item(arr)
25
+ @DATA_SET[arr.to_s].shuffle(random: Time.now.to_i).first
26
+ end
27
+ end
28
+
29
+ ## In a capistrano scope
30
+ Capistrano::Configuration.instance.load do
31
+
32
+ set :speaker, TalkingCapistrano::say_speaker_name
33
+ set :say_deploy_started, TalkingCapistrano::say_deploy_started(rails_env)
34
+ set :say_deploy_completed, TalkingCapistrano::say_deploy_completed(rails_env)
35
+ set :say_deploy_failed, TalkingCapistrano::say_deploy_failed(rails_env)
36
+
37
+ set :say_command, "say"
38
+
39
+ #Say related tasks to notify deployments to the group
40
+ namespace :deploy do
41
+ namespace :say do
42
+ task :about_to_deploy do
43
+ `#{say_command} #{say_deploy_started} -v '#{speaker}' &`
44
+ end
45
+ end
46
+ end
47
+
48
+
49
+ #Overide capistrano code deploy, to add the on error hook, seems to not be called otherwise
50
+ namespace :deploy do
51
+ task :update_code, :except => { :no_release => true } do
52
+ on_rollback do
53
+ `#{say_command} #{say_deploy_failed} -v #{speaker} &`;
54
+ run "rm -rf #{release_path}; true"
55
+ end
56
+ strategy.deploy!
57
+ finalize_update
58
+ end
59
+ end
60
+
61
+
62
+ # Say notifications on deploy stages
63
+ before "deploy", "deploy:say:about_to_deploy"
64
+ after "deploy" do
65
+ `#{say_command} #{say_deploy_completed} -v '#{speaker}' &`
66
+ end
67
+
68
+ end
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'talking-capistrano/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "talking-capistrano"
8
+ gem.version = Talking::Capistrano::VERSION
9
+ gem.authors = ["Avner Cohen"]
10
+ gem.email = ["avner.cohen@fiverr.com"]
11
+ gem.description = %q{Capisrano task to notify start|end|erros of a capistrano deploy execution}
12
+ gem.summary = %q{Capisrano task to notify start|end|erros of a capistrano deploy execution}
13
+ gem.homepage = "https://github.com/fiverr/talking-capistrano.git"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.files << "lib/talking-capistrano.json"
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: talking-capistrano
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Avner Cohen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-14 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Capisrano task to notify start|end|erros of a capistrano deploy execution
15
+ email:
16
+ - avner.cohen@fiverr.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - lib/talking-capistrano.json
27
+ - lib/talking-capistrano.rb
28
+ - lib/talking-capistrano/version.rb
29
+ - talking-capistrano.gemspec
30
+ homepage: https://github.com/fiverr/talking-capistrano.git
31
+ licenses: []
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project:
50
+ rubygems_version: 1.8.24
51
+ signing_key:
52
+ specification_version: 3
53
+ summary: Capisrano task to notify start|end|erros of a capistrano deploy execution
54
+ test_files: []