capistrano_mailer 4.0.1 → 4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/CHANGELOG +107 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +46 -0
- data/README.rdoc +204 -187
- data/Rakefile +40 -52
- data/VERSION.yml +2 -2
- data/assets/stylesheets/failure.css +60 -0
- data/assets/stylesheets/success.css +60 -0
- data/capistrano_mailer.gemspec +21 -3
- data/lib/cap_mailer.rb +207 -184
- data/lib/capistrano/mailer.rb +41 -25
- data/lib/capistrano/mailer_recipes.rb +21 -0
- data/test/build_gem_test.rb +18 -0
- data/views/cap_mailer/_message_body.html.erb +37 -0
- data/views/cap_mailer/_message_body.text.erb +24 -0
- data/views/cap_mailer/_section.html.erb +29 -31
- data/views/cap_mailer/_section.text.erb +23 -23
- data/views/cap_mailer/_section_custom.html.erb +6 -6
- data/views/cap_mailer/failed.notification_email.html.erb +1 -0
- data/views/cap_mailer/failed.notification_email.text.erb +1 -0
- data/views/cap_mailer/notification_email.html.erb +1 -39
- data/views/cap_mailer/notification_email.text.erb +1 -22
- metadata +57 -5
data/Rakefile
CHANGED
@@ -1,52 +1,40 @@
|
|
1
|
-
require 'rake'
|
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 =
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
t.pattern = 'test/**/*_test.rb'
|
42
|
-
t.verbose = true
|
43
|
-
end
|
44
|
-
|
45
|
-
desc 'Generate documentation for the capistrano_mailer gem.'
|
46
|
-
Rake::RDocTask.new(:rdoc) do |rdoc|
|
47
|
-
rdoc.rdoc_dir = 'rdoc'
|
48
|
-
rdoc.title = 'capistrano_mailer'
|
49
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
50
|
-
rdoc.rdoc_files.include('README.markdown')
|
51
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
52
|
-
end
|
1
|
+
require 'rake'
|
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 = `git ls-files`.split("\n")
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
desc 'Default: run unit tests.'
|
23
|
+
task :default => :test
|
24
|
+
|
25
|
+
desc 'Test the capistrano_mailer gem.'
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = true
|
31
|
+
end
|
32
|
+
|
33
|
+
desc 'Generate documentation for the capistrano_mailer gem.'
|
34
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
35
|
+
rdoc.rdoc_dir = 'rdoc'
|
36
|
+
rdoc.title = 'capistrano_mailer'
|
37
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
38
|
+
rdoc.rdoc_files.include('README.markdown')
|
39
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
40
|
+
end
|
data/VERSION.yml
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
body {
|
2
|
+
font: 14px normal Helvetica, Arial, Sans;
|
3
|
+
background: #966;
|
4
|
+
}
|
5
|
+
|
6
|
+
div.mail-content {
|
7
|
+
width: 800px;
|
8
|
+
margin: 10px auto;
|
9
|
+
background: #fdd;
|
10
|
+
border: 10px solid #a66;
|
11
|
+
}
|
12
|
+
|
13
|
+
h1 {
|
14
|
+
clear: both;
|
15
|
+
margin: 0;
|
16
|
+
padding: 40px 20px 5px 20px;
|
17
|
+
border-bottom: 1px dotted;
|
18
|
+
background: #c88;
|
19
|
+
}
|
20
|
+
|
21
|
+
p.view-site, p.mail-footer {
|
22
|
+
margin: 8px 0 20px 20px;
|
23
|
+
padding: 0;
|
24
|
+
font-style: italic;
|
25
|
+
}
|
26
|
+
|
27
|
+
p.released {
|
28
|
+
margin: 10px 20px;
|
29
|
+
font-weight: bold;
|
30
|
+
}
|
31
|
+
|
32
|
+
div.section {
|
33
|
+
margin: 20px;
|
34
|
+
padding: 0 0 20px 0;
|
35
|
+
}
|
36
|
+
|
37
|
+
div.section h2 {
|
38
|
+
margin: 0;
|
39
|
+
padding: 10px 10px 5px 10px;
|
40
|
+
background: #fcc;
|
41
|
+
border-left: 10px solid #a66;
|
42
|
+
color: #333;
|
43
|
+
}
|
44
|
+
|
45
|
+
div.section p.data-item {
|
46
|
+
margin: 10px; padding: 0;
|
47
|
+
}
|
48
|
+
|
49
|
+
div.section p.data-item p.key {
|
50
|
+
float: left;
|
51
|
+
width: 150px;
|
52
|
+
padding: 10px 10px 0;
|
53
|
+
}
|
54
|
+
|
55
|
+
div.section p.data-item p.value {
|
56
|
+
float: left;
|
57
|
+
width: 490px;
|
58
|
+
padding: 10px 10px 0;
|
59
|
+
}
|
60
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
body {
|
2
|
+
font: 14px normal Helvetica, Arial, Sans;
|
3
|
+
background: #666;
|
4
|
+
}
|
5
|
+
|
6
|
+
div.mail-content {
|
7
|
+
width: 800px;
|
8
|
+
margin: 10px auto;
|
9
|
+
background: #dfd;
|
10
|
+
border: 10px solid #6a6;
|
11
|
+
}
|
12
|
+
|
13
|
+
h1 {
|
14
|
+
clear: both;
|
15
|
+
margin: 0;
|
16
|
+
padding: 40px 20px 5px 20px;
|
17
|
+
border-bottom: 1px dotted;
|
18
|
+
background: #8c8;
|
19
|
+
}
|
20
|
+
|
21
|
+
p.view-site, p.mail-footer {
|
22
|
+
margin: 8px 0 20px 20px;
|
23
|
+
padding: 0;
|
24
|
+
font-style: italic;
|
25
|
+
}
|
26
|
+
|
27
|
+
p.released {
|
28
|
+
margin: 10px 20px;
|
29
|
+
font-weight: bold;
|
30
|
+
}
|
31
|
+
|
32
|
+
div.section {
|
33
|
+
margin: 20px;
|
34
|
+
padding: 0 0 20px 0;
|
35
|
+
}
|
36
|
+
|
37
|
+
div.section h2 {
|
38
|
+
margin: 0;
|
39
|
+
padding: 10px 10px 5px 10px;
|
40
|
+
background: #cfc;
|
41
|
+
border-left: 10px solid #6a6;
|
42
|
+
color: #333;
|
43
|
+
}
|
44
|
+
|
45
|
+
div.section p.data-item {
|
46
|
+
margin: 10px; padding: 0;
|
47
|
+
}
|
48
|
+
|
49
|
+
div.section p.data-item p.key {
|
50
|
+
float: left;
|
51
|
+
width: 150px;
|
52
|
+
padding: 10px 10px 0;
|
53
|
+
}
|
54
|
+
|
55
|
+
div.section p.data-item p.value {
|
56
|
+
float: left;
|
57
|
+
width: 490px;
|
58
|
+
padding: 10px 10px 0;
|
59
|
+
}
|
60
|
+
|
data/capistrano_mailer.gemspec
CHANGED
@@ -5,45 +5,63 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "capistrano_mailer"
|
8
|
-
s.version = "4.0.
|
8
|
+
s.version = "4.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Peter Boling", "Dave Nolan", "Jason Rust"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2013-01-22"
|
13
13
|
s.description = "Capistrano Deployment Email Notification. Keep the whole team informed of each release!"
|
14
14
|
s.email = ["peter.boling@gmail.com", "dave@textgoeshere.org.uk", "jason@rustedcode.com"]
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.rdoc"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
+
".gitignore",
|
20
|
+
"CHANGELOG",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
19
23
|
"MIT-LICENSE",
|
20
24
|
"README.rdoc",
|
21
25
|
"Rakefile",
|
22
26
|
"VERSION.yml",
|
27
|
+
"assets/stylesheets/failure.css",
|
28
|
+
"assets/stylesheets/success.css",
|
23
29
|
"capistrano_mailer.gemspec",
|
24
30
|
"lib/cap_mailer.rb",
|
25
31
|
"lib/capistrano/mailer.rb",
|
32
|
+
"lib/capistrano/mailer_recipes.rb",
|
33
|
+
"test/build_gem_test.rb",
|
34
|
+
"views/cap_mailer/_message_body.html.erb",
|
35
|
+
"views/cap_mailer/_message_body.text.erb",
|
26
36
|
"views/cap_mailer/_section.html.erb",
|
27
37
|
"views/cap_mailer/_section.text.erb",
|
28
38
|
"views/cap_mailer/_section_custom.html.erb",
|
29
39
|
"views/cap_mailer/_section_custom.text.erb",
|
40
|
+
"views/cap_mailer/failed.notification_email.html.erb",
|
41
|
+
"views/cap_mailer/failed.notification_email.text.erb",
|
30
42
|
"views/cap_mailer/notification_email.html.erb",
|
31
43
|
"views/cap_mailer/notification_email.text.erb"
|
32
44
|
]
|
33
45
|
s.homepage = "http://github.com/pboling/capistrano_mailer"
|
34
46
|
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = "1.8.
|
47
|
+
s.rubygems_version = "1.8.24"
|
36
48
|
s.summary = "Capistrano Deployment Email Notification"
|
37
49
|
|
38
50
|
if s.respond_to? :specification_version then
|
39
51
|
s.specification_version = 3
|
40
52
|
|
41
53
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
54
|
+
s.add_runtime_dependency(%q<capistrano-log_with_awesome>, [">= 0"])
|
55
|
+
s.add_runtime_dependency(%q<inline-style>, [">= 0"])
|
42
56
|
s.add_runtime_dependency(%q<actionmailer>, [">= 0"])
|
43
57
|
else
|
58
|
+
s.add_dependency(%q<capistrano-log_with_awesome>, [">= 0"])
|
59
|
+
s.add_dependency(%q<inline-style>, [">= 0"])
|
44
60
|
s.add_dependency(%q<actionmailer>, [">= 0"])
|
45
61
|
end
|
46
62
|
else
|
63
|
+
s.add_dependency(%q<capistrano-log_with_awesome>, [">= 0"])
|
64
|
+
s.add_dependency(%q<inline-style>, [">= 0"])
|
47
65
|
s.add_dependency(%q<actionmailer>, [">= 0"])
|
48
66
|
end
|
49
67
|
end
|
data/lib/cap_mailer.rb
CHANGED
@@ -1,184 +1,207 @@
|
|
1
|
-
class CapMailer < ActionMailer::Base
|
2
|
-
|
3
|
-
@@default_base_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
|
-
:
|
13
|
-
:
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
attr_accessor :
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
|
47
|
-
|
48
|
-
:
|
49
|
-
:
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:
|
55
|
-
:
|
56
|
-
:
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
}))
|
67
|
-
|
68
|
-
@date = Date.today.to_s
|
69
|
-
@time = Time.now.strftime("%I:%M %p").to_s
|
70
|
-
@inferred_command = "cap #{@config[:rails_env]} #{@config[:task_name]}"
|
71
|
-
@task_name = @config[:task_name] || "unknown"
|
72
|
-
|
73
|
-
repo = @config[:repository]
|
74
|
-
x = repo.include?('/') ? repo.rindex('/') - 1 : repo.length
|
75
|
-
front = repo.slice(0..x)
|
76
|
-
back = repo.sub(front, '')
|
77
|
-
unless back == 'trunk'
|
78
|
-
x = front.include?('/') ? front.rindex('/') - 1 : front.length
|
79
|
-
front = front.slice(0..x)
|
80
|
-
end
|
81
|
-
@repo_end = repo.sub(front, '')
|
82
|
-
|
83
|
-
body_data_hash.each_pair do |k, v|
|
84
|
-
self.instance_variable_set("@#{k}", v)
|
85
|
-
end
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
:
|
131
|
-
:
|
132
|
-
:
|
133
|
-
:
|
134
|
-
:
|
135
|
-
:
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
:
|
144
|
-
:
|
145
|
-
:
|
146
|
-
:
|
147
|
-
:
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
:
|
156
|
-
:
|
157
|
-
:
|
158
|
-
:
|
159
|
-
:
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
:
|
167
|
-
:
|
168
|
-
:
|
169
|
-
:
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
:
|
179
|
-
:
|
180
|
-
:
|
181
|
-
:
|
182
|
-
|
183
|
-
|
184
|
-
end
|
1
|
+
class CapMailer < ActionMailer::Base
|
2
|
+
|
3
|
+
@@default_base_config ||= ActiveSupport::InheritableOptions.new({
|
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
|
+
:template_prefixes => { :success => nil, :failure => "failed" },
|
13
|
+
:template_path => "#{File.dirname(__FILE__)}/../views",
|
14
|
+
:attach_log_on => :failure
|
15
|
+
})
|
16
|
+
|
17
|
+
cattr_accessor :default_base_config
|
18
|
+
attr_accessor :config, :options
|
19
|
+
attr_accessor :date, :time, :inferred_command, :task_name, :repo_end
|
20
|
+
|
21
|
+
def self.configure(&block)
|
22
|
+
yield @@default_base_config
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.configure_capistrano_mailer(&block)
|
26
|
+
puts "Deprecated 'configure_capistrano_mailer'. Please update your capistrano_mailer configuration to use 'configure' instead of 'configure_capistrano_mailer'"
|
27
|
+
end
|
28
|
+
|
29
|
+
self.prepend_view_path default_base_config[:template_path]
|
30
|
+
self.register_interceptor InlineStyle::Mail::Interceptor.new(:stylesheets_path =>
|
31
|
+
(default_base_config[:stylesheets_path] || "#{File.dirname(__FILE__)}/../assets")
|
32
|
+
)
|
33
|
+
|
34
|
+
def self.reloadable?() false end
|
35
|
+
|
36
|
+
def notification_email(cap, config = {}, *args)
|
37
|
+
@options = { :release_data => {}, :extra_information => {}, :data => {} }.merge(args.extract_options!)
|
38
|
+
@config = default_base_config.merge(config.reverse_merge({
|
39
|
+
:rails_env => cap.rails_env,
|
40
|
+
:host => cap.host,
|
41
|
+
:task_name => cap.task_name,
|
42
|
+
:application => cap.application,
|
43
|
+
:repository => cap.repository,
|
44
|
+
:scm => cap.scm,
|
45
|
+
:deploy_via => cap.deploy_via,
|
46
|
+
:deploy_to => cap.deploy_to,
|
47
|
+
:revision => cap.revision,
|
48
|
+
:real_revision => cap.real_revision,
|
49
|
+
:release_name => cap.release_name,
|
50
|
+
:release_notes => cap.release_notes,
|
51
|
+
:version_dir => cap.version_dir,
|
52
|
+
:shared_dir => cap.shared_dir,
|
53
|
+
:current_dir => cap.current_dir,
|
54
|
+
:releases_path => cap.releases_path,
|
55
|
+
:shared_path => cap.shared_path,
|
56
|
+
:current_path => cap.current_path,
|
57
|
+
:release_path => cap.release_path,
|
58
|
+
:releases => cap.releases,
|
59
|
+
:current_release => cap.current_release,
|
60
|
+
:previous_release => cap.previous_release,
|
61
|
+
:current_revision => cap.current_revision,
|
62
|
+
:latest_revision => cap.latest_revision,
|
63
|
+
:previous_revision => cap.previous_revision,
|
64
|
+
:run_method => cap.run_method,
|
65
|
+
:latest_release => cap.latest_release
|
66
|
+
}))
|
67
|
+
|
68
|
+
@date = Date.today.to_s
|
69
|
+
@time = Time.now.strftime("%I:%M %p").to_s
|
70
|
+
@inferred_command = "cap #{@config[:rails_env]} #{@config[:task_name]}"
|
71
|
+
@task_name = @config[:task_name] || "unknown"
|
72
|
+
|
73
|
+
repo = @config[:repository]
|
74
|
+
x = repo.include?('/') ? repo.rindex('/') - 1 : repo.length
|
75
|
+
front = repo.slice(0..x)
|
76
|
+
back = repo.sub(front, '')
|
77
|
+
unless back == 'trunk'
|
78
|
+
x = front.include?('/') ? front.rindex('/') - 1 : front.length
|
79
|
+
front = front.slice(0..x)
|
80
|
+
end
|
81
|
+
@repo_end = repo.sub(front, '')
|
82
|
+
|
83
|
+
body_data_hash.each_pair do |k, v|
|
84
|
+
self.instance_variable_set("@#{k}", v)
|
85
|
+
end
|
86
|
+
|
87
|
+
log = cap.fetch(:full_log)
|
88
|
+
fail_pattern = /^failed|rolling back/i
|
89
|
+
@job_status = (log =~ fail_pattern) ? :failure : cap.fetch(:mailer_status, :success)
|
90
|
+
template_prefix = @config[:template_prefixes][@job_status] ? "#{@config[:template_prefixes][@job_status]}." : ""
|
91
|
+
template_name = @config[:template_name] || "#{template_prefix}#{action_name}"
|
92
|
+
|
93
|
+
attach_log = case @config[:attach_log_on]
|
94
|
+
when Symbol, String
|
95
|
+
@job_status == @config[:attach_log_on].to_sym
|
96
|
+
when Array
|
97
|
+
@config[:attach_log_on].collect(&:to_sym).include? @job_status
|
98
|
+
else
|
99
|
+
false
|
100
|
+
end
|
101
|
+
|
102
|
+
if attach_log
|
103
|
+
log_file_name = "deploy-log-#{Time.now.strftime("%Y-%m-%d-%H%M%S")}.txt"
|
104
|
+
attachments[log_file_name] = { :content => log, :mime_type => "text/plain" }
|
105
|
+
end
|
106
|
+
|
107
|
+
self.config.assets_dir = "#{File.dirname(__FILE__)}/../assets"
|
108
|
+
|
109
|
+
mail :subject => "#{@job_status.to_s.upcase}: #{subject_line}",
|
110
|
+
:to => @config[:recipient_addresses],
|
111
|
+
:from => @config[:sender_address],
|
112
|
+
:template_name => template_name
|
113
|
+
end
|
114
|
+
|
115
|
+
private
|
116
|
+
|
117
|
+
def subject_line
|
118
|
+
#The subject prepend and append are useful for people to setup filters in mail clients.
|
119
|
+
user = config[:user] ? " by #{config[:user]}" : ""
|
120
|
+
middle = config[:subject] ? config[:subject] : "[#{config[:rails_env].upcase}][#{repo_end}] #{inferred_command}#{user}"
|
121
|
+
"#{config[:subject_prepend]}#{middle}#{config[:subject_append]}"
|
122
|
+
end
|
123
|
+
|
124
|
+
def body_data_hash
|
125
|
+
options[:data].merge({
|
126
|
+
:section_data => section_data_hash,
|
127
|
+
:date => date,
|
128
|
+
:time => time,
|
129
|
+
:task_name => task_name,
|
130
|
+
:inferred_command => inferred_command,
|
131
|
+
:repo_end => repo_end,
|
132
|
+
:site_name => config[:site_name],
|
133
|
+
:site_url => config[:site_url],
|
134
|
+
:application => config[:application],
|
135
|
+
:sections => config[:sections]
|
136
|
+
})
|
137
|
+
end
|
138
|
+
|
139
|
+
def section_data_hash
|
140
|
+
{
|
141
|
+
:deployment => section_hash_deployment,
|
142
|
+
:source_control => section_hash_source_control,
|
143
|
+
:latest_release => section_hash_latest_release,
|
144
|
+
:previous_release => section_hash_previous_release,
|
145
|
+
:other_deployment_info => section_hash_other_deployment_info,
|
146
|
+
:release_data => options[:release_data],
|
147
|
+
:extra_information => options[:extra_information]
|
148
|
+
}
|
149
|
+
end
|
150
|
+
|
151
|
+
def section_hash_deployment
|
152
|
+
{
|
153
|
+
:date => date,
|
154
|
+
:time => time,
|
155
|
+
:rails_env => config[:rails_env],
|
156
|
+
:task_name => task_name,
|
157
|
+
:inferred_command => inferred_command,
|
158
|
+
:host => config[:host],
|
159
|
+
:release_name => config[:release_name],
|
160
|
+
:release_notes => config[:release_notes]
|
161
|
+
}
|
162
|
+
end
|
163
|
+
|
164
|
+
def section_hash_source_control
|
165
|
+
{
|
166
|
+
:revision => config[:revision],
|
167
|
+
:released => repo_end,
|
168
|
+
:repository => config[:repository],
|
169
|
+
:branch => config[:branch],
|
170
|
+
:scm => config[:scm],
|
171
|
+
:deploy_via => config[:deploy_via],
|
172
|
+
:deploy_to => config[:deploy_to]
|
173
|
+
}
|
174
|
+
end
|
175
|
+
|
176
|
+
def section_hash_latest_release
|
177
|
+
{
|
178
|
+
:latest_release => config[:latest_release],
|
179
|
+
:latest_revision => config[:latest_revision],
|
180
|
+
:release_path => config[:release_path],
|
181
|
+
:real_revision => config[:real_revision],
|
182
|
+
:current_path => config[:current_path]
|
183
|
+
}
|
184
|
+
end
|
185
|
+
|
186
|
+
def section_hash_previous_release
|
187
|
+
{
|
188
|
+
:current_release => config[:current_release],
|
189
|
+
:current_revision => config[:current_revision],
|
190
|
+
:previous_release => config[:previous_release],
|
191
|
+
:previous_revision => config[:previous_revision],
|
192
|
+
:releases => config[:releases]
|
193
|
+
}
|
194
|
+
end
|
195
|
+
|
196
|
+
def section_hash_other_deployment_info
|
197
|
+
{
|
198
|
+
:version_dir => config[:version_dir],
|
199
|
+
:shared_dir => config[:shared_dir],
|
200
|
+
:current_dir => config[:current_dir],
|
201
|
+
:releases_path => config[:releases_path],
|
202
|
+
:shared_path => config[:shared_path],
|
203
|
+
:run_method => config[:run_method],
|
204
|
+
:ip_address => config[:ip_address]
|
205
|
+
}
|
206
|
+
end
|
207
|
+
end
|