capistrano_mailer 3.3.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +21 -0
- data/README.rdoc +206 -0
- data/Rakefile +31 -3
- data/VERSION.yml +5 -0
- data/capistrano_mailer.gemspec +50 -0
- data/lib/cap_mailer.rb +46 -88
- data/lib/capistrano/mailer.rb +6 -26
- data/views/cap_mailer/_section.html.erb +2 -2
- data/views/cap_mailer/_section_custom.html.erb +1 -2
- data/views/cap_mailer/notification_email.html.erb +39 -1
- data/views/cap_mailer/notification_email.text.erb +22 -0
- metadata +41 -102
- data/CHANGELOG.md +0 -116
- data/LICENSE.txt +0 -23
- data/README.md +0 -268
- data/lib/capistrano/mailer_recipes.rb +0 -43
- data/lib/capistrano_mailer.rb +0 -2
- data/lib/capistrano_mailer/version.rb +0 -3
- data/spec/create_gemset_spec.rb +0 -44
- data/spec/empty_gemset_spec.rb +0 -32
- data/spec/install_ruby_spec.rb +0 -120
- data/spec/rvm_paths_spec.rb +0 -93
- data/spec/spec_helper.rb +0 -3
- data/spec/support/abort_matcher.rb +0 -42
- data/spec/support/capistrano.rb +0 -24
- data/test/build_gem_test.rb +0 -18
- data/views/cap_mailer/_message_body.html.erb +0 -39
- data/views/cap_mailer/_message_body.text.erb +0 -22
- data/views/cap_mailer/failed.notification_email.html.erb +0 -1
- data/views/cap_mailer/failed.notification_email.plain.erb +0 -1
- data/views/cap_mailer/notification_email.plain.erb +0 -1
data/MIT-LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Copyright (c) 2009 9thBit LLC (http://www.9thbit.net)
|
2
|
+
# Copyright (c) 2007-8 Sagebit, LLC (http://www.sagebit.com)
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,206 @@
|
|
1
|
+
= Capistrano Mailer
|
2
|
+
|
3
|
+
* For Capistrano Deployment Email Notification
|
4
|
+
* It is a Capistrano Plugin / Ruby Gem that requires ActionMailer
|
5
|
+
* It is MIT-LICENSE
|
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
|
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
|
+
== Usage with Rails >= 3.x.x
|
45
|
+
|
46
|
+
The > 4.x versions of this gem require at least Rails 3
|
47
|
+
|
48
|
+
=== Installation
|
49
|
+
|
50
|
+
Install as a gem:
|
51
|
+
|
52
|
+
[sudo] gem install capistrano_mailer
|
53
|
+
|
54
|
+
== Usage with Rails <= 2.3.x
|
55
|
+
|
56
|
+
=== Installation
|
57
|
+
|
58
|
+
Install the latest Rails 2 compatible version of the gem:
|
59
|
+
|
60
|
+
[sudo] gem install capistrano_mailer -v 3.2.5
|
61
|
+
|
62
|
+
=== Upgrading
|
63
|
+
|
64
|
+
The 3.x versions of the gem will remain compatible with Rails 2.x
|
65
|
+
|
66
|
+
From version 3.1.x to version 3.2.x
|
67
|
+
|
68
|
+
1. Update the way CapistranoMailer is configured using the new method: CapMailer.configure (see Usage below).
|
69
|
+
2. require the cap mailer config file (see Usage below)
|
70
|
+
|
71
|
+
From version 2.1.0 to version 3.1.x:
|
72
|
+
|
73
|
+
1. Update the way CapistranoMailer is configured using the new method: CapMailer.configure_capistrano_mailer (changed in later versions to just 'configure') (see Usage below).
|
74
|
+
2. Update the require statement at the top of deploy.rb, see below (note for plugin change from capistrano_mailer to capistrano/mailer).
|
75
|
+
3. Change the mailer.send to mailer.send_notification_email in your cap recipe.
|
76
|
+
|
77
|
+
== Setup
|
78
|
+
|
79
|
+
1. You need to have already setup capistrano in the project, including the 'capify .' command.
|
80
|
+
|
81
|
+
2. Add this line to the top of your config/deploy.rb:
|
82
|
+
|
83
|
+
# For plugin:
|
84
|
+
# You must make capistrano_mailer's libraries available in Ruby's load path. This is one way to do that:
|
85
|
+
# Add to the top of your config/deploy.rb file:
|
86
|
+
$:.unshift 'vendor/plugins/capistrano_mailer/lib'
|
87
|
+
|
88
|
+
# For frozen gem:
|
89
|
+
# You must make capistrano_mailer's libraries available in Ruby's load path. This is one way to do that:
|
90
|
+
# Add to the top of your config/deploy.rb file:
|
91
|
+
$:.unshift 'vendor/gems/capistrano_mailer-x.x.x/lib'
|
92
|
+
|
93
|
+
# then for gem or plugin:
|
94
|
+
####################################
|
95
|
+
# Capistrano Plugins go here
|
96
|
+
require 'capistrano/mailer'
|
97
|
+
#configure capistrano_mailer:
|
98
|
+
# The configuration file can go anywhere, but in past versions of the gem it was required to be in the config/ dir.
|
99
|
+
require 'config/cap_mailer_settings'
|
100
|
+
####################################
|
101
|
+
|
102
|
+
3. Configure Caistrano Mailer in the settings file required in step 2:
|
103
|
+
|
104
|
+
# If installed as a plugin might need the require here as well
|
105
|
+
|
106
|
+
ActionMailer::Base.delivery_method = :smtp # or :sendmail, or whatever
|
107
|
+
ActionMailer::Base.smtp_settings = { # if using :smtp
|
108
|
+
:address => "mail.example.com",
|
109
|
+
:port => 25,
|
110
|
+
:domain => 'default.com',
|
111
|
+
:perform_deliveries => true,
|
112
|
+
:user_name => "releases@example.com",
|
113
|
+
:password => "mypassword",
|
114
|
+
:authentication => :login }
|
115
|
+
ActionMailer::Base.default_charset = "utf-8"# or "latin1" or whatever you are using
|
116
|
+
|
117
|
+
CapMailer.configure do |config|
|
118
|
+
config[:recipient_addresses] = ["dev1@example.com"]
|
119
|
+
# 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.
|
120
|
+
# https://rails.lighthouseapp.com/projects/8994/tickets/2340
|
121
|
+
# Therefore %("Capistrano Deployment" <releases@example.com>) style addresses may not work in Rails 2.3.3
|
122
|
+
config[:sender_address] = "deployment@example.com"
|
123
|
+
config[:subject_prepend] = "[EMPTY-CAP-DEPLOY]"
|
124
|
+
config[:site_name] = "Empty Example.com App"
|
125
|
+
end
|
126
|
+
|
127
|
+
4. Add these two tasks to your deploy.rb:
|
128
|
+
|
129
|
+
namespace :show do
|
130
|
+
desc "Show some internal Cap-Fu: What's mah NAYM?!?"
|
131
|
+
task :me do
|
132
|
+
set :task_name, task_call_frames.first.task.fully_qualified_name
|
133
|
+
#puts "Running #{task_name} task"
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
namespace :deploy do
|
138
|
+
...
|
139
|
+
|
140
|
+
desc "Send email notification of deployment (only send variables you want to be in the email)"
|
141
|
+
task :notify, :roles => :app do
|
142
|
+
show.me # this sets the task_name variable
|
143
|
+
mailer.send_notification_email(self)
|
144
|
+
end
|
145
|
+
|
146
|
+
...
|
147
|
+
end
|
148
|
+
|
149
|
+
5. Make _sure_ you've defined `rails_env`, `repository`, `deploy_to`, `host`, and `application`. `task_name` is defined by the show:me task above, and the others are defined behind the scenes by Capistrano!
|
150
|
+
|
151
|
+
6. The only parameter to mailer.send_notification_email that is *required* is the first. _Minimally_ you need to define the capistrano variables:
|
152
|
+
|
153
|
+
:rails_env
|
154
|
+
:repository
|
155
|
+
:task_name (provided by the show:me task included in this readme)
|
156
|
+
:deploy_to
|
157
|
+
:host
|
158
|
+
:application
|
159
|
+
|
160
|
+
But there are tons of others - just take a look at lib/mailer/cap_mailer.rb.
|
161
|
+
|
162
|
+
If anyone has a cool way of recording the *output* into a capistrano accessible variable,
|
163
|
+
so that it can be shoved into the release email that would be an excellent contribution!
|
164
|
+
|
165
|
+
7. Then add the hook somewhere in your deploy.rb:
|
166
|
+
|
167
|
+
after "deploy", "deploy:notify"
|
168
|
+
|
169
|
+
8. Enjoy and Happy Capping!
|
170
|
+
|
171
|
+
9. Customization
|
172
|
+
|
173
|
+
If you want to use your own views you'll need to recreate the notification_email view:
|
174
|
+
First you need to define where your templates are:
|
175
|
+
|
176
|
+
CapMailer.configure_capistrano_mailer do |config|
|
177
|
+
config[:template_root] = "app/views/capistrano_mailer/"
|
178
|
+
end
|
179
|
+
|
180
|
+
Then you'll need to create templates there called:
|
181
|
+
`notification_email.text.html.erb`
|
182
|
+
and / or
|
183
|
+
`notification_email.text.plain.erb`
|
184
|
+
|
185
|
+
Take a look at the templates that comes with the plugin to see how it is done (views/cap_mailer/...)
|
186
|
+
|
187
|
+
== Authors
|
188
|
+
|
189
|
+
Peter Boling (pboling) - Wrote original & maintainer
|
190
|
+
Dave Nolan (textgoeshere) - lots of refactoring merged into 3.2 release
|
191
|
+
Jason Rust (jrust) - Updated for Rails 3 compatibility
|
192
|
+
|
193
|
+
== Contributors
|
194
|
+
|
195
|
+
Dustin Deyoung - HTML Email Templates
|
196
|
+
mixonix - SCMs compatibility
|
197
|
+
greut - SCMs compatibility
|
198
|
+
|
199
|
+
----------------------------------------------------------------------------------
|
200
|
+
This plugin started out as a collaboration between Sagebit, LLC (http://www.sagebit.com) and Peter Boling (http://www.peterboling.com).
|
201
|
+
Written initially while Peter Boling was working at Sagebit for use in various projects.
|
202
|
+
|
203
|
+
Author: Peter Boling, peter.boling at gmail dot com
|
204
|
+
|
205
|
+
Copyright (c) 2009-2011 Peter Boling of 9thBit LLC, released under the MIT license
|
206
|
+
Copyright (c) 2007-2008 Sagebit LLC, released under the MIT license
|
data/Rakefile
CHANGED
@@ -1,5 +1,35 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/testtask'
|
3
|
+
require 'rdoc/task'
|
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", "dave@textgoeshere.org.uk", "jason@rustedcode.com"]
|
12
|
+
gemspec.homepage = "http://github.com/pboling/capistrano_mailer"
|
13
|
+
gemspec.authors = ["Peter Boling", "Dave Nolan", "Jason Rust"]
|
14
|
+
gemspec.add_dependency 'actionmailer'
|
15
|
+
gemspec.files = ["README.rdoc",
|
16
|
+
"capistrano_mailer.gemspec",
|
17
|
+
"lib/cap_mailer.rb",
|
18
|
+
"lib/capistrano/mailer.rb",
|
19
|
+
"Rakefile",
|
20
|
+
"MIT-LICENSE",
|
21
|
+
"views/cap_mailer/_section.html.erb",
|
22
|
+
"views/cap_mailer/_section.text.erb",
|
23
|
+
"views/cap_mailer/_section_custom.html.erb",
|
24
|
+
"views/cap_mailer/_section_custom.text.erb",
|
25
|
+
"views/cap_mailer/notification_email.html.erb",
|
26
|
+
"views/cap_mailer/notification_email.text.erb",
|
27
|
+
"VERSION.yml"]
|
28
|
+
end
|
29
|
+
Jeweler::GemcutterTasks.new
|
30
|
+
rescue LoadError
|
31
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler"
|
32
|
+
end
|
3
33
|
|
4
34
|
desc 'Default: run unit tests.'
|
5
35
|
task :default => :test
|
@@ -13,9 +43,7 @@ Rake::TestTask.new(:test) do |t|
|
|
13
43
|
end
|
14
44
|
|
15
45
|
desc 'Generate documentation for the capistrano_mailer gem.'
|
16
|
-
|
17
|
-
require 'rdoc/task'
|
18
|
-
RDoc::Task.new do |rdoc|
|
46
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
19
47
|
rdoc.rdoc_dir = 'rdoc'
|
20
48
|
rdoc.title = 'capistrano_mailer'
|
21
49
|
rdoc.options << '--line-numbers' << '--inline-source'
|
data/VERSION.yml
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "capistrano_mailer"
|
8
|
+
s.version = "4.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Peter Boling", "Dave Nolan", "Jason Rust"]
|
12
|
+
s.date = "2011-12-11"
|
13
|
+
s.description = "Capistrano Deployment Email Notification. Keep the whole team informed of each release!"
|
14
|
+
s.email = ["peter.boling@gmail.com", "dave@textgoeshere.org.uk", "jason@rustedcode.com"]
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"MIT-LICENSE",
|
20
|
+
"README.rdoc",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION.yml",
|
23
|
+
"capistrano_mailer.gemspec",
|
24
|
+
"lib/cap_mailer.rb",
|
25
|
+
"lib/capistrano/mailer.rb",
|
26
|
+
"views/cap_mailer/_section.html.erb",
|
27
|
+
"views/cap_mailer/_section.text.erb",
|
28
|
+
"views/cap_mailer/_section_custom.html.erb",
|
29
|
+
"views/cap_mailer/_section_custom.text.erb",
|
30
|
+
"views/cap_mailer/notification_email.html.erb",
|
31
|
+
"views/cap_mailer/notification_email.text.erb"
|
32
|
+
]
|
33
|
+
s.homepage = "http://github.com/pboling/capistrano_mailer"
|
34
|
+
s.require_paths = ["lib"]
|
35
|
+
s.rubygems_version = "1.8.10"
|
36
|
+
s.summary = "Capistrano Deployment Email Notification"
|
37
|
+
|
38
|
+
if s.respond_to? :specification_version then
|
39
|
+
s.specification_version = 3
|
40
|
+
|
41
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
42
|
+
s.add_runtime_dependency(%q<actionmailer>, [">= 0"])
|
43
|
+
else
|
44
|
+
s.add_dependency(%q<actionmailer>, [">= 0"])
|
45
|
+
end
|
46
|
+
else
|
47
|
+
s.add_dependency(%q<actionmailer>, [">= 0"])
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
data/lib/cap_mailer.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
class CapMailer < ActionMailer::Base
|
2
2
|
|
3
|
-
# In capistrano_mailer 4+ this uses ActiveSupport::InheritableOptions from Rails 3+
|
4
3
|
@@default_base_config ||= {
|
5
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>),
|
6
5
|
:recipient_addresses => [],
|
@@ -11,71 +10,66 @@ class CapMailer < ActionMailer::Base
|
|
11
10
|
:sections => %w(deployment release_data source_control latest_release previous_release other_deployment_info extra_information),
|
12
11
|
:site_name => "",
|
13
12
|
:email_content_type => "text/html",
|
14
|
-
|
15
|
-
:template_root => "#{File.dirname(__FILE__)}/../views",
|
16
|
-
:template_prefixes => { :success => nil, :failure => "failed" },
|
17
|
-
:attach_log_on => :failure
|
13
|
+
:template_root => "#{File.dirname(__FILE__)}/../views"
|
18
14
|
}
|
19
15
|
|
20
16
|
cattr_accessor :default_base_config
|
21
17
|
attr_accessor :config, :options
|
22
18
|
attr_accessor :date, :time, :inferred_command, :task_name, :repo_end
|
23
|
-
|
19
|
+
|
24
20
|
def self.configure(&block)
|
25
21
|
yield @@default_base_config
|
26
22
|
end
|
27
23
|
|
28
24
|
def self.configure_capistrano_mailer(&block)
|
29
|
-
|
25
|
+
puts "Deprecated 'configure_capistrano_mailer'. Please update your capistrano_mailer configuration to use 'configure' instead of 'configure_capistrano_mailer'"
|
30
26
|
end
|
31
27
|
|
32
|
-
self.
|
28
|
+
self.prepend_view_path default_base_config[:template_root]
|
33
29
|
|
34
30
|
def self.reloadable?() false end
|
35
|
-
|
36
|
-
def config_from_cap_hash(cap, config = {})
|
37
|
-
default_base_config.dup.merge(config.reverse_merge({
|
38
|
-
:rails_env => cap[:rails_env],
|
39
|
-
:host => cap[:host],
|
40
|
-
:task_name => cap[:task_name],
|
41
|
-
:application => cap[:application],
|
42
|
-
:repository => cap[:repository],
|
43
|
-
:scm => cap[:scm],
|
44
|
-
:deploy_via => cap[:deploy_via],
|
45
|
-
:deploy_to => cap[:deploy_to],
|
46
|
-
:revision => cap[:revision],
|
47
|
-
:real_revision => cap[:real_revision],
|
48
|
-
:release_name => cap[:release_name],
|
49
|
-
:version_dir => cap[:version_dir],
|
50
|
-
:shared_dir => cap[:shared_dir],
|
51
|
-
:current_dir => cap[:current_dir],
|
52
|
-
:releases_path => cap[:releases_path],
|
53
|
-
:shared_path => cap[:shared_path],
|
54
|
-
:current_path => cap[:current_path],
|
55
|
-
:release_path => cap[:release_path],
|
56
|
-
:releases => cap[:releases],
|
57
|
-
:current_release => cap[:current_release],
|
58
|
-
:previous_release => cap[:previous_release],
|
59
|
-
:current_revision => cap[:current_revision],
|
60
|
-
:latest_revision => cap[:latest_revision],
|
61
|
-
:previous_revision => cap[:previous_revision],
|
62
|
-
:run_method => cap[:run_method],
|
63
|
-
:latest_release => cap[:latest_release]
|
64
|
-
|
65
|
-
#This does not appear to be a capistrano variable:
|
66
|
-
#:site_url => cap[:site_url]
|
67
|
-
}))
|
68
|
-
end
|
69
|
-
|
31
|
+
|
70
32
|
def notification_email(cap, config = {}, *args)
|
71
|
-
@config = config_from_cap_hash(cap.is_a?(Array) ? cap.first : cap, config)
|
72
33
|
@options = { :release_data => {}, :extra_information => {}, :data => {} }.merge(args.extract_options!)
|
73
|
-
|
34
|
+
@config = default_base_config.merge(config.reverse_merge({
|
35
|
+
:rails_env => cap.rails_env,
|
36
|
+
:host => cap.host,
|
37
|
+
:task_name => cap.task_name,
|
38
|
+
:application => cap.application,
|
39
|
+
:repository => cap.repository,
|
40
|
+
:scm => cap.scm,
|
41
|
+
:deploy_via => cap.deploy_via,
|
42
|
+
:deploy_to => cap.deploy_to,
|
43
|
+
:revision => cap.revision,
|
44
|
+
:real_revision => cap.real_revision,
|
45
|
+
:release_name => cap.release_name,
|
46
|
+
#This does not appear to be a capistrano variable:
|
47
|
+
#:release_notes => cap.release_notes,
|
48
|
+
:version_dir => cap.version_dir,
|
49
|
+
:shared_dir => cap.shared_dir,
|
50
|
+
:current_dir => cap.current_dir,
|
51
|
+
:releases_path => cap.releases_path,
|
52
|
+
:shared_path => cap.shared_path,
|
53
|
+
:current_path => cap.current_path,
|
54
|
+
:release_path => cap.release_path,
|
55
|
+
:releases => cap.releases,
|
56
|
+
:current_release => cap.current_release,
|
57
|
+
:previous_release => cap.previous_release,
|
58
|
+
:current_revision => cap.current_revision,
|
59
|
+
:latest_revision => cap.latest_revision,
|
60
|
+
:previous_revision => cap.previous_revision,
|
61
|
+
:run_method => cap.run_method,
|
62
|
+
:latest_release => cap.latest_release
|
63
|
+
|
64
|
+
#This does not appear to be a capistrano variable:
|
65
|
+
#:site_url => cap.site_url
|
66
|
+
}))
|
67
|
+
|
74
68
|
@date = Date.today.to_s
|
75
69
|
@time = Time.now.strftime("%I:%M %p").to_s
|
76
70
|
@inferred_command = "cap #{@config[:rails_env]} #{@config[:task_name]}"
|
77
71
|
@task_name = @config[:task_name] || "unknown"
|
78
|
-
|
72
|
+
|
79
73
|
repo = @config[:repository]
|
80
74
|
x = repo.include?('/') ? repo.rindex('/') - 1 : repo.length
|
81
75
|
front = repo.slice(0..x)
|
@@ -86,53 +80,17 @@ class CapMailer < ActionMailer::Base
|
|
86
80
|
end
|
87
81
|
@repo_end = repo.sub(front, '')
|
88
82
|
|
89
|
-
|
90
|
-
|
91
|
-
@job_status = (log =~ fail_pattern) ? :failure : cap.fetch(:mailer_status, :success)
|
92
|
-
template_prefix = @config[:template_prefixes][@job_status] ? "#{@config[:template_prefixes][@job_status]}." : ""
|
93
|
-
template_name = @config[:template_name] || "#{template_prefix}#{action_name}"
|
94
|
-
|
95
|
-
attach_log = case @config[:attach_log_on]
|
96
|
-
when Symbol, String
|
97
|
-
@job_status == @config[:attach_log_on].to_sym
|
98
|
-
when Array
|
99
|
-
@config[:attach_log_on].collect(&:to_sym).include? @job_status
|
100
|
-
else
|
101
|
-
false
|
83
|
+
body_data_hash.each_pair do |k, v|
|
84
|
+
self.instance_variable_set("@#{k}", v)
|
102
85
|
end
|
103
86
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
part "multipart/alternative" do |alternative|
|
109
|
-
|
110
|
-
alternative.part "text/html" do |html|
|
111
|
-
html.body = render_message("#{template_name}.html", body_data_hash)
|
112
|
-
end if @config[:email_content_type] == "text/html"
|
113
|
-
|
114
|
-
alternative.part "text/plain" do |plain|
|
115
|
-
plain.body = render_message("#{template_name}.plain", body_data_hash)
|
116
|
-
end if @config[:email_content_type] == "text/plain"
|
117
|
-
|
118
|
-
end
|
119
|
-
|
120
|
-
attachment :content_type => "text/plain",
|
121
|
-
:body => log,
|
122
|
-
:filename => "deploy-log-#{Time.now.strftime("%Y-%m-%d-%H%M%S")}.txt"
|
123
|
-
else
|
124
|
-
content_type @config[:email_content_type]
|
125
|
-
body body_data_hash
|
126
|
-
end
|
127
|
-
|
128
|
-
subject "#{@job_status.to_s.upcase}: #{subject_line}"
|
129
|
-
recipients @config[:recipient_addresses]
|
130
|
-
from @config[:sender_address]
|
131
|
-
|
87
|
+
mail :subject => subject_line,
|
88
|
+
:to => @config[:recipient_addresses],
|
89
|
+
:from => @config[:sender_address]
|
132
90
|
end
|
133
91
|
|
134
92
|
private
|
135
|
-
|
93
|
+
|
136
94
|
def subject_line
|
137
95
|
#The subject prepend and append are useful for people to setup filters in mail clients.
|
138
96
|
user = config[:user] ? " by #{config[:user]}" : ""
|