capistrano-notifier 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
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
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.3@capistrano_notifier --install --create
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
5
+ group :development, :test do
6
+ group :darwin do
7
+ gem 'rb-fsevent'
8
+ gem 'growl'
9
+ end
10
+ end
11
+
data/Guardfile ADDED
@@ -0,0 +1,6 @@
1
+ guard 'rspec', :version => 2 do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
6
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Justin Campbell
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,38 @@
1
+ # CapistranoNotifier
2
+
3
+ ## Install
4
+
5
+ In your Gemfile:
6
+
7
+ ```rb
8
+ gem 'capistrano-notifier'
9
+ ```
10
+
11
+ and then `bundle install`
12
+
13
+ ## Configure
14
+
15
+ ```rb
16
+ require 'capistrano-notifier'
17
+
18
+ set :notify_method, :test # :smtp, :sendmail, or any other valid ActionMailer delivery method
19
+ set :notify_from, "capistrano@domain.com"
20
+ set :notify_to, ["john@doe.com", "jane@doe.com"]
21
+ set :notify_github_project, "MyCompany/project-name"
22
+
23
+ namespace :deploy do
24
+ desc "Capistrano Notifier"
25
+ task :notify do
26
+ Capistrano::Notifier.new(self).perform
27
+ end
28
+ end
29
+
30
+ after 'deploy', 'deploy:notify'
31
+ ```
32
+
33
+ ## Test
34
+
35
+ ```sh
36
+ cap deploy:notify
37
+ ```
38
+
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ begin
2
+ require 'bundler/gem_tasks'
3
+ rescue LoadError
4
+ puts "Ruby >= 1.9 required for build tasks"
5
+ end
6
+
7
+ require 'rspec/core/rake_task'
8
+
9
+ task :default => :spec
10
+
11
+ desc "Run the test suite"
12
+ RSpec::Core::RakeTask.new
13
+
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/capistrano_notifier/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Justin Campbell"]
6
+ gem.email = ["justin@justincampbell.me"]
7
+ gem.description = %q{Capistrano Notifier}
8
+ gem.summary = %q{Capistrano Notifier}
9
+ gem.homepage = "http://github.com/CramerDev/capistrano-notifier"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- spec/*`.split("\n")
14
+ gem.name = "capistrano-notifier"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = CapistranoNotifier::VERSION
17
+
18
+ gem.add_dependency 'actionmailer'
19
+ gem.add_dependency 'activesupport'
20
+
21
+ gem.add_development_dependency 'guard-rspec'
22
+ gem.add_development_dependency 'rspec'
23
+ end
@@ -0,0 +1 @@
1
+ require 'capistrano_notifier'
@@ -0,0 +1,127 @@
1
+ require "action_mailer"
2
+ require "active_support"
3
+ require "capistrano_notifier/version"
4
+
5
+ module Capistrano
6
+ class Notifier
7
+ def initialize(capistrano)
8
+ @cap = capistrano
9
+ end
10
+
11
+ def perform
12
+ mail = ActionMailer::Base.mail({
13
+ :body => text,
14
+ :delivery_method => notify_method,
15
+ :from => from,
16
+ :subject => subject,
17
+ :to => to
18
+ })
19
+
20
+ mail.deliver
21
+
22
+ puts ActionMailer::Base.deliveries if notify_method == :test
23
+ end
24
+
25
+ private
26
+
27
+ def application
28
+ cap.application.titleize
29
+ end
30
+
31
+ def body
32
+ <<-BODY
33
+ #{user} deployed
34
+ #{application} branch
35
+ #{branch} to
36
+ #{stage} on
37
+ #{now.strftime("%m/%d/%Y")} at
38
+ #{now.strftime("%I:%M %p %Z")}
39
+
40
+ #{git_range}
41
+ #{git_log}
42
+ BODY
43
+ end
44
+
45
+ def branch
46
+ cap.branch
47
+ end
48
+
49
+ def cap
50
+ @cap
51
+ end
52
+
53
+ def current_revision
54
+ cap.current_revision[0,7]
55
+ end
56
+
57
+ def from
58
+ cap.notify_from
59
+ end
60
+
61
+ def git_log
62
+ `git log #{git_range} --no-merges --format=format:"%h %s (%an)"`
63
+ end
64
+
65
+ def git_range
66
+ "#{previous_revision}..#{current_revision}"
67
+ end
68
+
69
+ def github_commit_prefix
70
+ "#{github_prefix}/commit"
71
+ end
72
+
73
+ def github_compare_prefix
74
+ "#{github_prefix}/compare"
75
+ end
76
+
77
+ def github_prefix
78
+ "https://github.com/#{github_project}"
79
+ end
80
+
81
+ def github_project
82
+ cap.notify_github_project
83
+ end
84
+
85
+ def html
86
+ body.gsub(
87
+ /([0-9a-f]{7})\.\.([0-9a-f]{7})/, "<a href=\"#{github_compare_prefix}/\\1...\\2\">\\1..\\2</a>"
88
+ ).gsub(
89
+ /^([0-9a-f]{7})/, "<a href=\"#{github_commit_prefix}/\\0\">\\0</a>"
90
+ )
91
+ end
92
+
93
+ def previous_revision
94
+ cap.previous_revision[0,7]
95
+ end
96
+
97
+ def notify_method
98
+ cap.notify_method
99
+ end
100
+
101
+ def now
102
+ @now ||= Time.new
103
+ end
104
+
105
+ def stage
106
+ cap.stage
107
+ end
108
+
109
+ def subject
110
+ "#{user} deployed #{application}@#{branch} to #{stage}"
111
+ end
112
+
113
+ def text
114
+ body.gsub(/([0-9a-f]{7})\.\.([0-9a-f]{7})/, "#{github_compare_prefix}/\\1...\\2")
115
+ end
116
+
117
+ def to
118
+ cap.notify_to
119
+ end
120
+
121
+ def user
122
+ user = ENV['DEPLOYER']
123
+ user = `git config --get user.name`.strip if user.nil?
124
+ end
125
+ end
126
+ end
127
+
@@ -0,0 +1,3 @@
1
+ module CapistranoNotifier
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "spec_helper"
2
+
3
+ describe Capistrano::Notifier do
4
+ it { described_class.should be_a Class }
5
+ end
@@ -0,0 +1,2 @@
1
+ require "capistrano-notifier"
2
+
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-notifier
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Justin Campbell
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: actionmailer
16
+ requirement: &70167707711460 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70167707711460
25
+ - !ruby/object:Gem::Dependency
26
+ name: activesupport
27
+ requirement: &70167707710840 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70167707710840
36
+ - !ruby/object:Gem::Dependency
37
+ name: guard-rspec
38
+ requirement: &70167707709840 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70167707709840
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &70167707709260 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70167707709260
58
+ description: Capistrano Notifier
59
+ email:
60
+ - justin@justincampbell.me
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - .gitignore
66
+ - .rspec
67
+ - .rvmrc
68
+ - Gemfile
69
+ - Guardfile
70
+ - LICENSE
71
+ - README.md
72
+ - Rakefile
73
+ - capistrano-notifier.gemspec
74
+ - lib/capistrano-notifier.rb
75
+ - lib/capistrano_notifier.rb
76
+ - lib/capistrano_notifier/version.rb
77
+ - spec/capistrano_notifier_spec.rb
78
+ - spec/spec_helper.rb
79
+ homepage: http://github.com/CramerDev/capistrano-notifier
80
+ licenses: []
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 1.8.17
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: Capistrano Notifier
103
+ test_files:
104
+ - spec/capistrano_notifier_spec.rb
105
+ - spec/spec_helper.rb