capistrano_mailer 3.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +232 -0
- data/Rakefile +53 -0
- data/VERSION.yml +5 -0
- data/about.yml +9 -0
- data/capistrano_mailer.gemspec +56 -0
- data/init.rb +3 -0
- data/lib/cap_mailer.rb +133 -0
- data/lib/capistrano/mailer.rb +28 -0
- data/test/build_gem_test.rb +18 -0
- data/views/cap_mailer/_section.html.erb +31 -0
- data/views/cap_mailer/_section.text.erb +23 -0
- data/views/cap_mailer/_section_custom.html.erb +15 -0
- data/views/cap_mailer/notification_email.text.html.erb +38 -0
- data/views/cap_mailer/notification_email.text.plain.erb +22 -0
- metadata +76 -0
data/README.rdoc
ADDED
@@ -0,0 +1,232 @@
|
|
1
|
+
= Capistrano Mailer v3.1.3 (20090925)
|
2
|
+
|
3
|
+
* For Capistrano Deployment Email Notification
|
4
|
+
* It is a Capistrano Plugin / Ruby Gem that requires ActionMailer
|
5
|
+
* It is MIT-LICENSE (License file is in source only for now because github won't build the gem if it is bundled with the gem... ?)
|
6
|
+
|
7
|
+
Ever wanted to be emailed whenever someone on the team does a cap deploy of trunk or some tag to some server.
|
8
|
+
Wouldn't it be nice to know about it every time a release was deployed? For large rails projects this type of coordination is essential,
|
9
|
+
and this plugin makes sure everyone on the need to know list is notified when something new is deployed.
|
10
|
+
|
11
|
+
This plugin/gem is an extension to Capistrano.
|
12
|
+
|
13
|
+
That means it registers itself with Capistrano as a plugin and is therefore available to call in your recipes.
|
14
|
+
|
15
|
+
If you are looking to roll your own email integration into capistrano then try this pastie:
|
16
|
+
http://pastie.org/146264 (thanks to Mislav Marohnić).
|
17
|
+
But if you want to take the easy road to riches then keep reading ;)
|
18
|
+
-- figurative "riches" of course, I promise nothing in return for your using this plugin
|
19
|
+
|
20
|
+
Important Note:
|
21
|
+
The first time you deploy to a server (a 'cold' deploy) capistrano mailer will cause an error because it uses capistrano's previous release variables, and when there are no previous releases capistrano throws an error. In the next version this will be fixed, just don't have time at the moment. If you would like to work on this 'first deploy' problem please fork my repo and work on it!
|
22
|
+
|
23
|
+
== Home Page
|
24
|
+
|
25
|
+
http://github.com/pboling/capistrano_mailer/tree/master
|
26
|
+
|
27
|
+
|
28
|
+
== Credit where Credit is Due
|
29
|
+
|
30
|
+
* Thanks to Dustin Deyoung of Sagebit, LLC (http://www.sagebit.com) for the beautiful HTML email templates.
|
31
|
+
|
32
|
+
|
33
|
+
== Requirements
|
34
|
+
|
35
|
+
* at least Rails 1.2.6 (might work with older versions, but has not been tested)
|
36
|
+
|
37
|
+
* at least Capistrano 2.4.3 (might work with capistrano as old as 2.1.0, but has not been tested)
|
38
|
+
|
39
|
+
* Known to be compatible with SCMs as of version 3.1.2: Perforce, SVN, and Git
|
40
|
+
|
41
|
+
* Known to be compatible with, but does not require, the deprec gem.
|
42
|
+
|
43
|
+
|
44
|
+
== Installation
|
45
|
+
|
46
|
+
Gem Using Git building from source:
|
47
|
+
|
48
|
+
mkdir -p ~/src
|
49
|
+
cd ~/src
|
50
|
+
git clone git://github.com/pboling/capistrano_mailer.git
|
51
|
+
cd capistrano_mailer
|
52
|
+
gem build capistrano_mailer.gemspec
|
53
|
+
sudo gem install capistrano_mailer-3.1.3.gem # (Or whatever version gets built)
|
54
|
+
|
55
|
+
Then cd to your rails app to optionally freeze the gem into your app:
|
56
|
+
|
57
|
+
rake gems:freeze GEM=capistrano_mailer
|
58
|
+
# You do NOT need to add a config.gem line to environment.rb for capistrano mailer.
|
59
|
+
|
60
|
+
Installing Gem from Github's Gem Server:
|
61
|
+
|
62
|
+
gem sources -a http://gems.github.com
|
63
|
+
sudo gem install pboling-capistrano_mailer
|
64
|
+
# You do NOT need to add a config.gem line to environment.rb for capistrano mailer.
|
65
|
+
|
66
|
+
Plugin using Git:
|
67
|
+
|
68
|
+
# Installation as plugin works... but the setup is slightly different. (See Usage below)
|
69
|
+
./script/plugin install git://github.com/pboling/capistrano_mailer.git
|
70
|
+
|
71
|
+
Using SVN (deprecated, repository is no longer updated):
|
72
|
+
|
73
|
+
./script/plugin install http://capistrano-mailer.googlecode.com/svn/trunk/capistrano_mailer
|
74
|
+
|
75
|
+
== Upgrading
|
76
|
+
|
77
|
+
From version 2.1.0 to version 3.x.x:
|
78
|
+
|
79
|
+
1. Update the way CapistranoMailer is configured using the new method: CapMailer.configure_capistrano_mailer, see below.
|
80
|
+
2. Update the require statement at the top of deploy.rb, see below (note for plugin change from capostrano_mailer to capistrano/mailer).
|
81
|
+
3. Change the mailer.send to mailer.send_notification_email in your cap recipe.
|
82
|
+
|
83
|
+
== Usage
|
84
|
+
|
85
|
+
1. Install as gem or plugin. You need to have already setup capistrano in the project, including the 'capify .' command.
|
86
|
+
|
87
|
+
2. Add this line to the top of your config/deploy.rb:
|
88
|
+
|
89
|
+
# For gem:
|
90
|
+
# You do NOT need to register the gem in your environment file using config.gem
|
91
|
+
require 'capistrano/mailer'
|
92
|
+
|
93
|
+
# For plugin:
|
94
|
+
# You must make capistrano_mailer's libraries available in Ruby's load path. This is one way to do that:
|
95
|
+
# Add to the top of your config/deploy.rb file:
|
96
|
+
$:.unshift 'vendor/plugins/capistrano_mailer/lib'
|
97
|
+
require 'capistrano/mailer'
|
98
|
+
|
99
|
+
3. Add a cap_mailer_settings.rb file to your config/ directory:
|
100
|
+
|
101
|
+
# If installed as a plugin might need the require here as well
|
102
|
+
|
103
|
+
ActionMailer::Base.delivery_method = :smtp
|
104
|
+
ActionMailer::Base.smtp_settings = {
|
105
|
+
:address => "mail.example.com",
|
106
|
+
:port => 25,
|
107
|
+
:domain => 'default.com',
|
108
|
+
:perform_deliveries => true,
|
109
|
+
:user_name => "releases@example.com",
|
110
|
+
:password => "mypassword",
|
111
|
+
:authentication => :login }
|
112
|
+
ActionMailer::Base.default_charset = "utf-8"# or "latin1" or whatever you are using
|
113
|
+
|
114
|
+
CapMailer.configure_capistrano_mailer do |config|
|
115
|
+
config[:recipient_addresses] = ["dev1@example.com"]
|
116
|
+
# NOTE: THERE IS A BUG IN RAILS 2.3.3 which forces us to NOT use anything but a simple email address string for the sender address.
|
117
|
+
# https://rails.lighthouseapp.com/projects/8994/tickets/2340
|
118
|
+
# Therefore %("Capistrano Deployment" <releases@example.com>) style addresses may not work in Rails 2.3.3
|
119
|
+
config[:sender_address] = "deployment@example.com"
|
120
|
+
config[:subject_prepend] = "[EMPTY-CAP-DEPLOY]"
|
121
|
+
config[:site_name] = "Empty Example.com App"
|
122
|
+
config[:email_content_type] = "text/html" # OR "text/plain" if you want the plain text version of the email
|
123
|
+
end
|
124
|
+
|
125
|
+
4. Add these two tasks to your deploy.rb:
|
126
|
+
|
127
|
+
namespace :show do
|
128
|
+
desc "Show some internal Cap-Fu: What's mah NAYM?!?"
|
129
|
+
task :me do
|
130
|
+
set :task_name, task_call_frames.first.task.fully_qualified_name
|
131
|
+
#puts "Running #{task_name} task"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
namespace :deploy do
|
136
|
+
...
|
137
|
+
|
138
|
+
desc "Send email notification of deployment (only send variables you want to be in the email)"
|
139
|
+
task :notify, :roles => :app do
|
140
|
+
show.me # this sets the task_name variable
|
141
|
+
mailer.send_notification_email([
|
142
|
+
:rails_env => rails_env,
|
143
|
+
:host => host,
|
144
|
+
:task_name => task_name,
|
145
|
+
:application => application,
|
146
|
+
:repository => repository,
|
147
|
+
:scm => scm,
|
148
|
+
:deploy_via => deploy_via,
|
149
|
+
:deploy_to => deploy_to,
|
150
|
+
:revision => revision,
|
151
|
+
:real_revision => real_revision,
|
152
|
+
:release_name => release_name,
|
153
|
+
:version_dir => version_dir,
|
154
|
+
:shared_dir => shared_dir,
|
155
|
+
:current_dir => current_dir,
|
156
|
+
:releases_path => releases_path,
|
157
|
+
:shared_path => shared_path,
|
158
|
+
:current_path => current_path,
|
159
|
+
:release_path => release_path,
|
160
|
+
:releases => releases,
|
161
|
+
:current_release => current_release,
|
162
|
+
:previous_release => previous_release,
|
163
|
+
:current_revision => current_revision,
|
164
|
+
:latest_revision => latest_revision,
|
165
|
+
:previous_revision => previous_revision,
|
166
|
+
:run_method => run_method,
|
167
|
+
:latest_release => latest_release,
|
168
|
+
],[ # Send some custom vars you've setup in your deploy.rb to be sent out with the notification email!
|
169
|
+
# will be rendered as a section of the email called 'Release Data'
|
170
|
+
#:some_other_var1 => some_other_var1,
|
171
|
+
#:some_other_var2 => some_other_var2,
|
172
|
+
#:some_other_var3 => some_other_var3
|
173
|
+
],[ # Send some more custom vars you've setup in your deploy.rb to be sent out with the notification email!
|
174
|
+
# will be rendered as a section of the email called 'Extra Information'
|
175
|
+
#:some_other_var4 => some_other_var4,
|
176
|
+
#:some_other_var5 => some_other_var5,
|
177
|
+
#:some_other_var6 => some_other_var6
|
178
|
+
],[ # and even more!!!
|
179
|
+
# these will not be rendered as a section, but will be passed to the email template in the @data hash,
|
180
|
+
# and be available there if you want to write your own template
|
181
|
+
]
|
182
|
+
)
|
183
|
+
end
|
184
|
+
|
185
|
+
...
|
186
|
+
end
|
187
|
+
|
188
|
+
Make _sure_ you've defined `rails_env`, `repository`, `deploy_to`, `host`, and `application`.
|
189
|
+
task_name is defined by the show:me task above, and the others are defined behind the scenes by Capistrano!
|
190
|
+
|
191
|
+
The only parameter to mailer.send_notification_email that is *required* is the first array of hashes, and _minimally_ it needs the keys:
|
192
|
+
:rails_env
|
193
|
+
:repository
|
194
|
+
:task_name (provided by the show:me task included in this readme)
|
195
|
+
:deploy_to
|
196
|
+
:host
|
197
|
+
:application
|
198
|
+
|
199
|
+
If anyone has a cool way of recording the *output* into a capistrano accessible variable,
|
200
|
+
so that it can be shoved into the release email that would be an excellent contribution!
|
201
|
+
|
202
|
+
5. Then add the hook somewhere in your deploy.rb:
|
203
|
+
|
204
|
+
after "deploy", "deploy:notify"
|
205
|
+
|
206
|
+
6. Enjoy and Happy Capping!
|
207
|
+
|
208
|
+
7. Customization
|
209
|
+
|
210
|
+
If you want to use your own views you'll need to recreate the notification_email view:
|
211
|
+
First you need to define where your templates are:
|
212
|
+
|
213
|
+
CapMailer.configure_capistrano_mailer do |config|
|
214
|
+
config[:template_root] = "app/views/capistrano_mailer/"
|
215
|
+
end
|
216
|
+
|
217
|
+
Then you'll need to create templates there called:
|
218
|
+
notification_email.text.html.erb
|
219
|
+
and / or
|
220
|
+
notification_email.text.plain.erb
|
221
|
+
|
222
|
+
Take a look at the templates that comes with the plugin to see how it is done (views/cap_mailer/...)
|
223
|
+
|
224
|
+
|
225
|
+
----------------------------------------------------------------------------------
|
226
|
+
This plugin is a collaboration between Sagebit, LLC (http://www.sagebit.com) and Peter Boling (http://www.peterboling.com).
|
227
|
+
Written initially while Peter Boling was working at Sagebit for use in various projects.
|
228
|
+
|
229
|
+
Author: Peter Boling, peter.boling at gmail dot com
|
230
|
+
|
231
|
+
Copyright (c) 2009 Peter Boling of 9thBit LLC, released under the MIT license
|
232
|
+
Copyright (c) 2007-8 Sagebit LLC, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'jeweler'
|
7
|
+
Jeweler::Tasks.new do |gemspec|
|
8
|
+
gemspec.name = "capistrano_mailer"
|
9
|
+
gemspec.summary = "Capistrano Deployment Email Notification"
|
10
|
+
gemspec.description = %q{Capistrano Deployment Email Notification. Keep the whole team informed of each release!}
|
11
|
+
gemspec.email = "peter.boling@gmail.com"
|
12
|
+
gemspec.homepage = "http://github.com/pboling/capistrano_mailer"
|
13
|
+
gemspec.authors = ["Peter Boling"]
|
14
|
+
gemspec.add_dependency 'action_mailer'
|
15
|
+
gemspec.files = ["README.rdoc",
|
16
|
+
"capistrano_mailer.gemspec",
|
17
|
+
"init.rb",
|
18
|
+
"about.yml",
|
19
|
+
"lib/cap_mailer.rb",
|
20
|
+
"lib/capistrano/mailer.rb",
|
21
|
+
"Rakefile",
|
22
|
+
"views/cap_mailer/_section.html.erb",
|
23
|
+
"views/cap_mailer/_section.text.erb",
|
24
|
+
"views/cap_mailer/_section_custom.html.erb",
|
25
|
+
"views/cap_mailer/_section_custom.html.erb",
|
26
|
+
"views/cap_mailer/notification_email.text.html.erb",
|
27
|
+
"views/cap_mailer/notification_email.text.plain.erb",
|
28
|
+
"VERSION.yml"]
|
29
|
+
end
|
30
|
+
Jeweler::GemcutterTasks.new
|
31
|
+
rescue LoadError
|
32
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'Default: run unit tests.'
|
36
|
+
task :default => :test
|
37
|
+
|
38
|
+
desc 'Test the capistrano_mailer gem.'
|
39
|
+
Rake::TestTask.new(:test) do |t|
|
40
|
+
t.libs << 'lib'
|
41
|
+
t.libs << 'test'
|
42
|
+
t.pattern = 'test/**/*_test.rb'
|
43
|
+
t.verbose = true
|
44
|
+
end
|
45
|
+
|
46
|
+
desc 'Generate documentation for the capistrano_mailer gem.'
|
47
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
48
|
+
rdoc.rdoc_dir = 'rdoc'
|
49
|
+
rdoc.title = 'capistrano_mailer'
|
50
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
51
|
+
rdoc.rdoc_files.include('README.markdown')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION.yml
ADDED
data/about.yml
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
author:
|
2
|
+
name: Peter Boling
|
3
|
+
homepage: http://www.peterboling.com
|
4
|
+
summary: Sends rails deployment notification emails from Capistrano
|
5
|
+
homepage: http://github.com/pboling/capistrano_mailer/tree/master
|
6
|
+
plugin: http://github.com/pboling/capistrano_mailer.git
|
7
|
+
license: MIT
|
8
|
+
version: 3.1.3
|
9
|
+
rails_version: 1.2.6+
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{capistrano_mailer}
|
8
|
+
s.version = "3.1.4"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Peter Boling"]
|
12
|
+
s.date = %q{2009-11-03}
|
13
|
+
s.description = %q{Capistrano Deployment Email Notification. Keep the whole team informed of each release!}
|
14
|
+
s.email = %q{peter.boling@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"README.rdoc",
|
20
|
+
"Rakefile",
|
21
|
+
"VERSION.yml",
|
22
|
+
"about.yml",
|
23
|
+
"capistrano_mailer.gemspec",
|
24
|
+
"init.rb",
|
25
|
+
"lib/cap_mailer.rb",
|
26
|
+
"lib/capistrano/mailer.rb",
|
27
|
+
"views/cap_mailer/_section.html.erb",
|
28
|
+
"views/cap_mailer/_section.text.erb",
|
29
|
+
"views/cap_mailer/_section_custom.html.erb",
|
30
|
+
"views/cap_mailer/_section_custom.html.erb",
|
31
|
+
"views/cap_mailer/notification_email.text.html.erb",
|
32
|
+
"views/cap_mailer/notification_email.text.plain.erb"
|
33
|
+
]
|
34
|
+
s.homepage = %q{http://github.com/pboling/capistrano_mailer}
|
35
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = %q{1.3.5}
|
38
|
+
s.summary = %q{Capistrano Deployment Email Notification}
|
39
|
+
s.test_files = [
|
40
|
+
"test/build_gem_test.rb"
|
41
|
+
]
|
42
|
+
|
43
|
+
if s.respond_to? :specification_version then
|
44
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
45
|
+
s.specification_version = 3
|
46
|
+
|
47
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
48
|
+
s.add_runtime_dependency(%q<action_mailer>, [">= 0"])
|
49
|
+
else
|
50
|
+
s.add_dependency(%q<action_mailer>, [">= 0"])
|
51
|
+
end
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<action_mailer>, [">= 0"])
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
data/init.rb
ADDED
data/lib/cap_mailer.rb
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
class CapMailer < ActionMailer::Base
|
2
|
+
|
3
|
+
@@config ||= {
|
4
|
+
:sender_address => %("#{(defined?(Rails) ? Rails.env.capitalize : defined?(RAILS_ENV) ? RAILS_ENV.capitalize : defined?(ENV) ? ENV['RAILS_ENV'] : "")} Capistrano Deployment" <capistrano.mailer@example.com>),
|
5
|
+
:recipient_addresses => [],
|
6
|
+
# Customize the subject line
|
7
|
+
:subject_prepend => "[DEPLOYMENT]-[#{(defined?(Rails) ? Rails.env.capitalize : defined?(RAILS_ENV) ? RAILS_ENV.capitalize : defined?(ENV) ? ENV['RAILS_ENV'] : "")}] ",
|
8
|
+
:subject_append => nil,
|
9
|
+
# Include which sections of the deployment email?
|
10
|
+
:sections => %w(deployment release_data source_control latest_release previous_release other_deployment_info extra_information),
|
11
|
+
:site_name => "",
|
12
|
+
:email_content_type => "text/html",
|
13
|
+
:template_root => "#{File.dirname(__FILE__)}/../views"
|
14
|
+
}
|
15
|
+
|
16
|
+
cattr_accessor :config
|
17
|
+
|
18
|
+
def self.configure_capistrano_mailer(&block)
|
19
|
+
yield @@config
|
20
|
+
end
|
21
|
+
|
22
|
+
self.template_root = config[:template_root]
|
23
|
+
|
24
|
+
def self.reloadable?() false end
|
25
|
+
|
26
|
+
def notification_email(cap_vars, release_data = {}, extra_information = {}, data = {})
|
27
|
+
body_hash = body_data_hash(cap_vars, release_data = {}, extra_information = {}, data = {})
|
28
|
+
subject "#{config[:subject_prepend]}[#{cap_vars.first[:rails_env].upcase}][#{body_hash[:repo_end]}] #{body_hash[:inferred_command]}#{config[:subject_append]}"
|
29
|
+
recipients config[:recipient_addresses]
|
30
|
+
from config[:sender_address]
|
31
|
+
content_type config[:email_content_type]
|
32
|
+
|
33
|
+
body body_hash
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def body_data_hash(cap_vars, release_data = {}, extra_information = {}, data = {})
|
39
|
+
date = Date.today.to_s
|
40
|
+
time = Time.now.strftime("%I:%M %p").to_s
|
41
|
+
inferred_command = "cap #{cap_vars.first[:rails_env]} #{cap_vars.first[:task_name]}"
|
42
|
+
repo = cap_vars.first[:repository]
|
43
|
+
x = repo.include?('/') ? repo.rindex('/') - 1 : repo.length
|
44
|
+
front = repo.slice(0..x)
|
45
|
+
back = repo.sub(front, '')
|
46
|
+
unless back == 'trunk'
|
47
|
+
x = front.include?('/') ? front.rindex('/') - 1 : front.length
|
48
|
+
front = front.slice(0..x)
|
49
|
+
end
|
50
|
+
repo_end = repo.sub(front, '')
|
51
|
+
task_name = cap_vars.first[:task_name] || "unknown"
|
52
|
+
|
53
|
+
return data.merge({
|
54
|
+
:section_data => section_data_hash(cap_vars, date, time, task_name, inferred_command, repo_end, release_data, extra_information),
|
55
|
+
:date => date,
|
56
|
+
:time => time,
|
57
|
+
:task_name => task_name,
|
58
|
+
:inferred_command => inferred_command,
|
59
|
+
:repo_end => repo_end,
|
60
|
+
:site_name => config[:site_name],
|
61
|
+
:application => cap_vars.first[:application],
|
62
|
+
:sections => config[:sections]
|
63
|
+
})
|
64
|
+
end
|
65
|
+
|
66
|
+
def section_data_hash(cap_vars, date, time, task_name, inferred_command, repo_end, release_data, extra_information)
|
67
|
+
{
|
68
|
+
:deployment => section_hash_deployment(cap_vars, date, time, task_name, inferred_command),
|
69
|
+
:source_control => section_hash_source_control(cap_vars, repo_end),
|
70
|
+
:latest_release => section_hash_latest_release(cap_vars),
|
71
|
+
:previous_release => section_hash_previous_release(cap_vars),
|
72
|
+
:other_deployment_info => section_hash_other_deployment_info(cap_vars),
|
73
|
+
:release_data => release_data,
|
74
|
+
:extra_information => extra_information
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
def section_hash_deployment(cap_vars, date, time, task_name, inferred_command)
|
79
|
+
{
|
80
|
+
:date => date,
|
81
|
+
:time => time,
|
82
|
+
:rails_env => cap_vars.first[:rails_env],
|
83
|
+
:task_name => task_name,
|
84
|
+
:inferred_command => inferred_command,
|
85
|
+
:host => cap_vars.first[:host],
|
86
|
+
:release_name => cap_vars.first[:release_name]
|
87
|
+
}
|
88
|
+
end
|
89
|
+
|
90
|
+
def section_hash_source_control(cap_vars, repo_end)
|
91
|
+
{
|
92
|
+
:revision => cap_vars.first[:revision],
|
93
|
+
:released => repo_end,
|
94
|
+
:repository => cap_vars.first[:repository],
|
95
|
+
:scm => cap_vars.first[:scm],
|
96
|
+
:deploy_via => cap_vars.first[:deploy_via],
|
97
|
+
:deploy_to => cap_vars.first[:deploy_to]
|
98
|
+
}
|
99
|
+
end
|
100
|
+
|
101
|
+
def section_hash_latest_release(cap_vars)
|
102
|
+
{
|
103
|
+
:latest_release => cap_vars.first[:latest_release],
|
104
|
+
:latest_revision => cap_vars.first[:latest_revision],
|
105
|
+
:release_path => cap_vars.first[:release_path],
|
106
|
+
:real_revision => cap_vars.first[:real_revision],
|
107
|
+
:current_path => cap_vars.first[:current_path]
|
108
|
+
}
|
109
|
+
end
|
110
|
+
|
111
|
+
def section_hash_previous_release(cap_vars)
|
112
|
+
{
|
113
|
+
:current_release => cap_vars.first[:current_release],
|
114
|
+
:current_revision => cap_vars.first[:current_revision],
|
115
|
+
:previous_release => cap_vars.first[:previous_release],
|
116
|
+
:previous_revision => cap_vars.first[:previous_revision],
|
117
|
+
:releases => cap_vars.first[:releases]
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
121
|
+
def section_hash_other_deployment_info(cap_vars)
|
122
|
+
{
|
123
|
+
:version_dir => cap_vars.first[:version_dir],
|
124
|
+
:shared_dir => cap_vars.first[:shared_dir],
|
125
|
+
:current_dir => cap_vars.first[:current_dir],
|
126
|
+
:releases_path => cap_vars.first[:releases_path],
|
127
|
+
:shared_path => cap_vars.first[:shared_path],
|
128
|
+
:run_method => cap_vars.first[:run_method],
|
129
|
+
:ip_address => cap_vars.first[:ip_address]
|
130
|
+
}
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems' unless defined?(Rubygems)
|
2
|
+
require 'capistrano' unless defined?(Capistrano)
|
3
|
+
|
4
|
+
unless Capistrano::Configuration.respond_to?(:instance)
|
5
|
+
abort "capistrano/mailer requires Capistrano 2"
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'action_mailer' unless defined?(ActionMailer)
|
9
|
+
|
10
|
+
require 'cap_mailer' unless defined?(CapMailer)
|
11
|
+
|
12
|
+
# ActionMailer configuration in the rails app
|
13
|
+
require 'config/cap_mailer_settings'
|
14
|
+
|
15
|
+
|
16
|
+
module Capistrano
|
17
|
+
class Configuration
|
18
|
+
module CapistranoMailer
|
19
|
+
def send_notification_email(cap_vars, extra = {}, data = {})
|
20
|
+
CapMailer.deliver_notification_email(cap_vars, extra, data)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
include CapistranoMailer
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Capistrano.plugin :mailer, Capistrano::Configuration::CapistranoMailer
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'yaml'
|
3
|
+
require 'rubygems/specification'
|
4
|
+
|
5
|
+
class BuildGemTest < Test::Unit::TestCase
|
6
|
+
def test_build_gem
|
7
|
+
data = File.read(File.join(File.dirname(__FILE__), '..', 'capistrano_mailer.gemspec'))
|
8
|
+
spec = nil
|
9
|
+
|
10
|
+
if data !~ %r{!ruby/object:Gem::Specification}
|
11
|
+
Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
|
12
|
+
else
|
13
|
+
spec = YAML.load(data)
|
14
|
+
end
|
15
|
+
|
16
|
+
assert spec.validate
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<div style="margin: 20px; padding: 0 0 20px 0;">
|
2
|
+
|
3
|
+
<h2 style="margin: 0px; padding: 10px 10px 5px 10px; background: #eee; border-left: 10px solid #ccc; color: #333;">
|
4
|
+
<%= section_title.titleize unless section_title.nil? -%>
|
5
|
+
</h2>
|
6
|
+
<% if data.is_a?(Array) then data = data[0] end -%>
|
7
|
+
<% arr = case section_title
|
8
|
+
when 'deployment'
|
9
|
+
[:date,:time,:rails_env,:task_name,:inferred_command,:host,:release_name]
|
10
|
+
when 'source_control'
|
11
|
+
[:scm,:released,:revision,:deploy_via,:deploy_to,:repository]
|
12
|
+
when 'latest_release'
|
13
|
+
[:latest_release,:latest_revision,:real_revision,:release_path,:current_path]
|
14
|
+
when 'previous_release'
|
15
|
+
[:current_release,:current_revision,:previous_release,:previous_revision,:releases]
|
16
|
+
when 'other_deployment_info'
|
17
|
+
[:ip_address,:run_method,:source,:strategy,:version_dir,:shared_dir,:current_dir,:releases_path,:shared_path]
|
18
|
+
end -%>
|
19
|
+
<% if !arr.nil? && arr.is_a?(Array) %>
|
20
|
+
<% arr.each do |key| -%>
|
21
|
+
<% if key.is_a?(Symbol) && !data[key].nil?-%>
|
22
|
+
<p style="margin: 10px; padding: 0px;">
|
23
|
+
<span style="float:left; width:150px; padding: 10px 10px 0;"><%= key.to_s.titleize %></span>
|
24
|
+
<span style="float:left; width:490px; padding: 10px 10px 0;"><%= data[key].is_a?(Array) ? data[key].to_sentence : data[key].is_a?(String) ? data[key] : data[key].inspect %></span>
|
25
|
+
</p>
|
26
|
+
<% end -%>
|
27
|
+
<% end -%>
|
28
|
+
<% end -%>
|
29
|
+
<p style="clear:both"></p>
|
30
|
+
|
31
|
+
</div>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%= section_title.titleize unless section_title.nil? -%>
|
2
|
+
===========================================================
|
3
|
+
|
4
|
+
<% if data.is_a?(Array) then data = data[0] end -%>
|
5
|
+
<% arr = case section_title
|
6
|
+
when 'deployment'
|
7
|
+
[:date,:time,:rails_env,:task,:inferred_command,:host,:release_name]
|
8
|
+
when 'source_control'
|
9
|
+
[:scm,:released,:revision,:deploy_via,:deploy_to,:repository]
|
10
|
+
when 'latest_release'
|
11
|
+
[:latest_release,:latest_revision,:real_revision,:release_path,:current_path]
|
12
|
+
when 'previous_release'
|
13
|
+
[:current_release,:current_revision,:previous_release,:previous_revision,:releases]
|
14
|
+
when 'other_deployment_info'
|
15
|
+
[:ip_address,:run_method,:source,:strategy,:version_dir,:shared_dir,:current_dir,:releases_path,:shared_path]
|
16
|
+
end -%>
|
17
|
+
<% if !arr.nil? && arr.is_a?(Array) %>
|
18
|
+
<% arr.each do |key| -%>
|
19
|
+
<% if key.is_a?(Symbol) && !data[key].nil?-%>
|
20
|
+
<%= key.to_s.titleize %> <%= data[key].is_a?(Array) ? data[key].to_sentence : data[key].is_a?(String) ? data[key] : data[key].inspect %>
|
21
|
+
<% end -%>
|
22
|
+
<% end -%>
|
23
|
+
<% end -%>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<div style="margin: 20px; padding: 0 0 20px 0;">
|
2
|
+
|
3
|
+
<h2 style="margin: 0px; padding: 10px 10px 5px 10px; background: #eee; border-left: 10px solid #ccc; color: #333;"><%= section_title.titleize unless section_title.nil? -%></h2>
|
4
|
+
<% if data.is_a?(Array) then data = data[0] end -%>
|
5
|
+
<% data.each do |key, value| -%>
|
6
|
+
<% if !key.nil? && !value.nil? -%>
|
7
|
+
<p style="margin: 10px; padding: 0px;">
|
8
|
+
<span style="float:left; width:150px; padding: 10px 10px 0;"><%= key %></span>
|
9
|
+
<span style="float:left; width:490px; padding: 10px 10px 0;"><%= value.is_a?(Array) ? value.to_sentence : value.is_a?(String) ? value : value.inspect%></span>
|
10
|
+
</p>
|
11
|
+
<% end -%>
|
12
|
+
<% end unless data.nil?-%>
|
13
|
+
<p style="clear:both"></p>
|
14
|
+
|
15
|
+
</div>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
5
|
+
<title><%= @site_name %> Notification </title>
|
6
|
+
</head>
|
7
|
+
<body style="font: 14px normal Helvetica, Arial, Sans; background: #999;">
|
8
|
+
|
9
|
+
<div style="width:800px; margin: 10px auto; background: #fff; border: 10px solid #aaa;">
|
10
|
+
|
11
|
+
<h1 style="clear: both; margin: 0; padding: 40px 20px 5px 20px; border-bottom: 1px dotted; background: #ccc;">
|
12
|
+
<%= @site_name %> <%=@task_name.titleize unless @task_name.nil? %>
|
13
|
+
</h1>
|
14
|
+
|
15
|
+
<p style="margin: 8px 0 20px 20px; padding: 0px; font-style: italic;" >
|
16
|
+
Brought to you by: <a href="http://github.com/pboling/capistrano_mailer/tree/master">Capistrano Mailer</a>
|
17
|
+
</p>
|
18
|
+
|
19
|
+
<p style="margin: 10px 20px; font-weight: bold;">Released: <%= @date %> at <%= @time %></p>
|
20
|
+
|
21
|
+
<%= @sections.map { |section|
|
22
|
+
data = @section_data[section.to_sym]
|
23
|
+
if !data.empty?
|
24
|
+
if %w(extra_information release_data).include?(section)
|
25
|
+
render :partial => 'section_custom.html.erb', :locals => {:section_title => section, :data => data}
|
26
|
+
else
|
27
|
+
render :partial => 'section.html.erb', :locals => {:section_title => section, :data => data}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
}.join unless @sections.nil? %>
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<div style="text-align:center;">
|
34
|
+
© 2009 <a href="http://www.9thbit.net">9thBit LLC</a>, MIT License<br/>
|
35
|
+
© 2007-8 <a href="http://www.sagebit.com">Sagebit LLC</a>, MIT License
|
36
|
+
</div>
|
37
|
+
</body>
|
38
|
+
</html>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<%= @site_name %> Notification
|
2
|
+
===========================================================
|
3
|
+
|
4
|
+
<%= @site_name %> <%=@task_name.titleize unless @task_name.nil? %>
|
5
|
+
===========================================================
|
6
|
+
Brought to you by: Capistrano Mailer - http://github.com/pboling/capistrano_mailer
|
7
|
+
Released: <%= @date %> at <%= @time %>
|
8
|
+
|
9
|
+
<%= @sections.map { |section|
|
10
|
+
data = @section_data[section.to_sym]
|
11
|
+
if !data.empty?
|
12
|
+
if %w(extra_information release_data).include?(section)
|
13
|
+
render :partial => 'section_custom.html.erb', :locals => {:section_title => section, :data => data}
|
14
|
+
else
|
15
|
+
render :partial => 'section.html.erb', :locals => {:section_title => section, :data => data}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
}.join unless @sections.nil? %>
|
19
|
+
|
20
|
+
===========================================================
|
21
|
+
Copyright 2009 9thBit LLC under MIT License
|
22
|
+
Copyright 2007-8 Sagebit LLC under MIT License
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano_mailer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.1.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Peter Boling
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-03 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: action_mailer
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description: Capistrano Deployment Email Notification. Keep the whole team informed of each release!
|
26
|
+
email: peter.boling@gmail.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.rdoc
|
33
|
+
files:
|
34
|
+
- README.rdoc
|
35
|
+
- Rakefile
|
36
|
+
- VERSION.yml
|
37
|
+
- about.yml
|
38
|
+
- capistrano_mailer.gemspec
|
39
|
+
- init.rb
|
40
|
+
- lib/cap_mailer.rb
|
41
|
+
- lib/capistrano/mailer.rb
|
42
|
+
- views/cap_mailer/_section.html.erb
|
43
|
+
- views/cap_mailer/_section.text.erb
|
44
|
+
- views/cap_mailer/_section_custom.html.erb
|
45
|
+
- views/cap_mailer/notification_email.text.html.erb
|
46
|
+
- views/cap_mailer/notification_email.text.plain.erb
|
47
|
+
has_rdoc: true
|
48
|
+
homepage: http://github.com/pboling/capistrano_mailer
|
49
|
+
licenses: []
|
50
|
+
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options:
|
53
|
+
- --charset=UTF-8
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
version:
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "0"
|
67
|
+
version:
|
68
|
+
requirements: []
|
69
|
+
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 1.3.5
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: Capistrano Deployment Email Notification
|
75
|
+
test_files:
|
76
|
+
- test/build_gem_test.rb
|