pboling-capistrano_mailer 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/MIT-LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ # Copyright (c) 2009 Peter Boling
2
+ # Copyright (c) 2007-8 Sagebit, LLC (http://www.sagebit.com)
3
+ # Copyright (c) 2007 Peter Boling
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.rdoc ADDED
@@ -0,0 +1,221 @@
1
+ = Capistrano Mailer v3.0.1 (20090921)
2
+
3
+ * For Capistrano Deployment Email Notification
4
+ * It is a Capistrano Plugin / Rails Plugin / Ruby Gem
5
+
6
+ Ever wanted to be emailed whenever someone on the team does a cap deploy of trunk or some tag to some server.
7
+ 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,
8
+ and this plugin makes sure everyone on the need to know list is notified when something new is deployed.
9
+
10
+ This plugin/gem is an extension to Capistrano.
11
+
12
+ That means it registers itself with Capistrano as a plugin and is therefore available to call in your recipes.
13
+
14
+ It is compatible with, but does not require, the deprec gem.
15
+
16
+ If you are looking to roll your own email integration into capistrano then try this pastie:
17
+ http://pastie.org/146264 (thanks to Mislav Marohnić).
18
+ But if you want to take the easy road to riches then keep reading ;)
19
+ -- figurative "riches" of course, I promise nothing in return for your using this plugin
20
+
21
+ Important Note:
22
+ 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!
23
+
24
+ == Home Page
25
+
26
+ http://github.com/pboling/capistrano_mailer/tree/master
27
+
28
+
29
+ == Requirements
30
+
31
+ * at least Rails 1.2.6 (might work with older versions, but has not been tested)
32
+
33
+ * at least Capistrano 2.4.3 (might work with capistrano as old as 2.1.0, but has not been tested)
34
+
35
+
36
+ == Installation
37
+
38
+ Gem Using Git building from source:
39
+
40
+ mkdir -p ~/src
41
+ cd ~/src
42
+ git clone git://github.com/pboling/capistrano_mailer.git
43
+ cd capistrano_mailer
44
+ gem build capistrano_mailer.gemspec
45
+ sudo gem install capistrano_mailer-3.0.1.gem # (Or whatever version gets built)
46
+
47
+ Then cd to your rails app to optionally freeze the gem into your app:
48
+
49
+ rake gems:freeze GEM=capistrano_mailer
50
+ # You do NOT need to add a config.gem line to environment.rb for capistrano mailer.
51
+
52
+ Installing Gem from Github's Gem Server:
53
+
54
+ gem sources -a http://gems.github.com
55
+ sudo gem install pboling-capistrano_mailer
56
+ # You do NOT need to add a config.gem line to environment.rb for capistrano mailer.
57
+
58
+ Plugin using Git:
59
+
60
+ # Installation as plugin might work... I haven't tried it.
61
+ ./script/plugin install git://github.com/pboling/capistrano_mailer.git
62
+
63
+ Using SVN (deprecated, repository is no longer updated):
64
+
65
+ ./script/plugin install http://capistrano-mailer.googlecode.com/svn/trunk/capistrano_mailer
66
+
67
+
68
+ == Upgrading
69
+
70
+ From version 2.1.0 to version 3.0.1:
71
+
72
+ Update the way CapistranoMailer is configured using the new method: CapMailer.configure_capistrano_mailer, see below.
73
+ Update the require statement at the top of deploy.rb, see below (note for plugin change from capostrano_mailer to capistrano/mailer).
74
+
75
+
76
+ == Usage
77
+
78
+ 1. Install as gem or plugin.
79
+
80
+ 2. Add this line to the top of your deploy.rb:
81
+
82
+ # For gem:
83
+ require 'capistrano/mailer'
84
+
85
+ # For plugin:
86
+ require 'vendor/plugins/capistrano_mailer/lib/capistrano/mailer'
87
+
88
+ 3. Add a cap_mailer_settings.rb file to your config/ directory:
89
+
90
+ # If installed as a plugin might need the require here as well
91
+
92
+ ActionMailer::Base.delivery_method = :smtp
93
+ ActionMailer::Base.smtp_settings = {
94
+ :address => "mail.example.com",
95
+ :port => 25,
96
+ :domain => 'default.com',
97
+ :perform_deliveries => true,
98
+ :user_name => "releases@example.com",
99
+ :password => "mypassword",
100
+ :authentication => :login }
101
+ ActionMailer::Base.default_charset = "utf-8"# or "latin1" or whatever you are using
102
+
103
+ CapMailer.configure_capistrano_mailer do |config|
104
+ config[:recipient_addresses] = ["dev1@example.com"]
105
+ # 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.
106
+ # https://rails.lighthouseapp.com/projects/8994/tickets/2340
107
+ # Therefore %("Capistrano Deployment" <releases@example.com>) style addresses may not work in Rails 2.3.3
108
+ config[:sender_address] = "deployment@example.com"
109
+ config[:subject_prepend] = "[EMPTY-CAP-DEPLOY]"
110
+ config[:site_name] = "Empty Example.com App"
111
+ config[:email_content_type] = "text/html" # OR "text/plain" if you want the plain text version of the email
112
+ end
113
+
114
+ 4. Add these two tasks to your deploy.rb:
115
+
116
+ namespace :show do
117
+ desc "Show some internal Cap-Fu: What's mah NAYM?!?"
118
+ task :me do
119
+ set :task_name, task_call_frames.first.task.fully_qualified_name
120
+ #puts "Running #{task_name} task"
121
+ end
122
+ end
123
+
124
+ namespace :deploy do
125
+ ...
126
+
127
+ desc "Send email notification of deployment (only send variables you want to be in the email)"
128
+ task :notify, :roles => :app do
129
+ show.me # this sets the task_name variable
130
+ mailer.send_mail([
131
+ :rails_env => rails_env,
132
+ :host => host,
133
+ :task_name => task_name,
134
+ :application => application,
135
+ :repository => repository,
136
+ :scm => scm,
137
+ :deploy_via => deploy_via,
138
+ :deploy_to => deploy_to,
139
+ :revision => revision,
140
+ :real_revision => real_revision,
141
+ :release_name => release_name,
142
+ :version_dir => version_dir,
143
+ :shared_dir => shared_dir,
144
+ :current_dir => current_dir,
145
+ :releases_path => releases_path,
146
+ :shared_path => shared_path,
147
+ :current_path => current_path,
148
+ :release_path => release_path,
149
+ :releases => releases,
150
+ :current_release => current_release,
151
+ :previous_release => previous_release,
152
+ :current_revision => current_revision,
153
+ :latest_revision => latest_revision,
154
+ :previous_revision => previous_revision,
155
+ :run_method => run_method,
156
+ :latest_release => latest_release,
157
+ ],[ # Send some custom vars you've setup in your deploy.rb to be sent out with the notification email!
158
+ # will be rendered as a section of the email called 'Release Data'
159
+ #:some_other_var1 => some_other_var1,
160
+ #:some_other_var2 => some_other_var2,
161
+ #:some_other_var3 => some_other_var3
162
+ ],[ # Send some more custom vars you've setup in your deploy.rb to be sent out with the notification email!
163
+ # will be rendered as a section of the email called 'Extra Information'
164
+ #:some_other_var4 => some_other_var4,
165
+ #:some_other_var5 => some_other_var5,
166
+ #:some_other_var6 => some_other_var6
167
+ ],[ # and even more!!!
168
+ # these will not be rendered as a section, but will be passed to the email template in the @data hash,
169
+ # and be available there if you want to write your own template
170
+ ]
171
+ )
172
+ end
173
+
174
+ ...
175
+ end
176
+
177
+ Make _sure_ you've defined `rails_env`, `repository`, `deploy_to`, `host`, and `application`.
178
+ task_name is defined by the show:me task above, and the others are defined behind the scenes by Capistrano!
179
+
180
+ The only parameter to mailer.send that is *required* is the first array of hashes, and _minimally_ it needs the keys:
181
+ :rails_env
182
+ :repository
183
+ :task_name (provided by the show:me task included in this readme)
184
+ :deploy_to
185
+ :host
186
+ :application
187
+
188
+ If anyone has a cool way of recording the *output* into a capistrano accessible variable,
189
+ so that it can be shoved into the release email that would be an excellent contribution!
190
+
191
+ 5. Then add the hook somewhere in your deploy.rb:
192
+
193
+ after "deploy", "deploy:notify"
194
+
195
+ 6. Enjoy and Happy Capping!
196
+
197
+ 7. Customization
198
+
199
+ If you want to use your own views you'll need to recreate the notification_email view:
200
+ First you need to define where your templates are:
201
+
202
+ CapMailer.configure_capistrano_mailer do |config|
203
+ config[:template_root] = "app/views/capistrano_mailer/"
204
+ end
205
+
206
+ Then you'll need to create templates there called:
207
+ notification_email.text.html.erb
208
+ and / or
209
+ notification_email.text.plain.erb
210
+
211
+ Take a look at the templates that comes with the plugin to see how it is done (views/cap_mailer/...)
212
+
213
+
214
+ ----------------------------------------------------------------------------------
215
+ This plugin is a collaboration between Sagebit, LLC (http://www.sagebit.com) and Peter Boling (http://www.peterboling.com)
216
+
217
+ Author: Peter Boling, peter.boling at gmail dot com
218
+
219
+ Copyright (c) 2009 Peter Boling of 9thBit LLC, released under the MIT license
220
+ Copyright (c) 2007-8 Sagebit LLC, released under the MIT license
221
+ Copyright (c) 2007 Peter Boling under MIT License
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the capistrano_mailer gem.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.libs << 'test'
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ end
15
+
16
+ desc 'Generate documentation for the capistrano_mailer gem.'
17
+ Rake::RDocTask.new(:rdoc) do |rdoc|
18
+ rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.title = 'capistrano_mailer'
20
+ rdoc.options << '--line-numbers' << '--inline-source'
21
+ rdoc.rdoc_files.include('README.markdown')
22
+ rdoc.rdoc_files.include('lib/**/*.rb')
23
+ end
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 3
3
+ :minor: 0
4
+ :patch: 1
data/about.yml ADDED
@@ -0,0 +1,7 @@
1
+ author: Peter Boling
2
+ summary: Sends rails deployment notification emails from Capistrano
3
+ homepage: http://github.com/pboling/capistrano_mailer/tree/master
4
+ plugin: http://github.com/pboling/capistrano_mailer.git
5
+ license: MIT
6
+ version: 3.0.1
7
+ rails_version: 1.2.6+
@@ -0,0 +1,38 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'capistrano_mailer'
3
+ s.version = '3.0.1'
4
+ s.date = '2009-09-21'
5
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
+
7
+ s.summary = %q{Sends emails when Capistrano is used to do things!}
8
+ s.description = %q{Useful for tracking deployment of websites to staging and production servers by a team of developers!}
9
+
10
+ s.authors = ['Peter Boling']
11
+ s.email = 'peter.boling@gmail.com'
12
+ s.homepage = 'http://github.com/pboling/capistrano_mailer'
13
+ s.require_paths = ["lib"]
14
+
15
+ s.has_rdoc = true
16
+
17
+ s.add_dependency 'rails', ['>= 2.1']
18
+
19
+ s.files = ["MIT-LICENSE",
20
+ "README.rdoc",
21
+ "capistrano_mailer.gemspec",
22
+ "init.rb",
23
+ "about.yml",
24
+ "lib/cap_mailer.rb",
25
+ "lib/capistrano/mailer.rb",
26
+ "Rakefile",
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
+ "VERSION.yml"]
34
+
35
+
36
+ s.test_files = []
37
+
38
+ end
data/init.rb ADDED
@@ -0,0 +1,3 @@
1
+ #if you want it to load as a REAL rails plugin then we need this require.
2
+ #But you don't really want that ;)
3
+ #require 'capistrano/mailer'
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.rindex('/') - 1
44
+ front = repo.slice(0..x)
45
+ back = repo.sub(front, '')
46
+ unless back == 'trunk'
47
+ x = front.rindex('/') - 1
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,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,39 @@
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
+ &copy; 2009 <a href="http://www.peterboling.com">Peter Boling</a>, MIT License<br/>
35
+ &copy; 2007-8 <a href="http://www.sagebit.com">Sagebit LLC</a>, MIT License
36
+ &copy; 2007 <a href="http://www.peterboling.com">Peter Boling</a>, MIT License<br/>
37
+ </div>
38
+ </body>
39
+ </html>
@@ -0,0 +1,23 @@
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 Peter Boling under MIT License
22
+ Copyright 2007-8 Sagebit LLC under MIT License
23
+ Copyright 2007 Peter Boling under MIT License
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pboling-capistrano_mailer
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Peter Boling
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-21 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "2.1"
24
+ version:
25
+ description: Useful for tracking deployment of websites to staging and production servers by a team of developers!
26
+ email: peter.boling@gmail.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files: []
32
+
33
+ files:
34
+ - MIT-LICENSE
35
+ - README.rdoc
36
+ - capistrano_mailer.gemspec
37
+ - init.rb
38
+ - about.yml
39
+ - lib/cap_mailer.rb
40
+ - lib/capistrano/mailer.rb
41
+ - Rakefile
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
+ - VERSION.yml
48
+ has_rdoc: true
49
+ homepage: http://github.com/pboling/capistrano_mailer
50
+ licenses:
51
+ post_install_message:
52
+ rdoc_options: []
53
+
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: 2
74
+ summary: Sends emails when Capistrano is used to do things!
75
+ test_files: []
76
+