capistrano_mailer 4.0.1 → 4.0.2

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.
@@ -1,25 +1,41 @@
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
-
13
- module Capistrano
14
- class Configuration
15
- module CapistranoMailer
16
- def send_notification_email(cap, config = {}, *args)
17
- CapMailer.notification_email(cap, config, *args).deliver
18
- end
19
- end
20
-
21
- include CapistranoMailer
22
- end
23
- end
24
-
25
- Capistrano.plugin :mailer, Capistrano::Configuration::CapistranoMailer
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 'capistrano/log_with_awesome'
9
+ require 'inline-style'
10
+ require 'action_mailer' unless defined?(ActionMailer)
11
+ require 'cap_mailer' unless defined?(CapMailer)
12
+
13
+ module Capistrano
14
+ class Configuration
15
+ module CapistranoMailer
16
+ def send_notification_email(cap, config = {}, *args)
17
+ CapMailer.notification_email(cap, config, *args).deliver
18
+ end
19
+ end
20
+
21
+ include CapistranoMailer
22
+
23
+ module Execution
24
+ protected
25
+ def __rollback_with_mailer!
26
+ set :mailer_status, :failure
27
+ find_and_execute_task "deploy:notify"
28
+ __rollback_without_mailer!
29
+ end
30
+
31
+ alias_method :__rollback_without_mailer!, :rollback!
32
+ alias_method :rollback!, :__rollback_with_mailer!
33
+ end
34
+ end
35
+ end
36
+
37
+ Capistrano.plugin :mailer, Capistrano::Configuration::CapistranoMailer
38
+
39
+ if cap = Capistrano::Configuration.instance
40
+ cap.load("#{File.expand_path(File.dirname(__FILE__))}/mailer_recipes.rb")
41
+ end
@@ -0,0 +1,21 @@
1
+ namespace :show do
2
+ task :me do
3
+ set :task_name, task_call_frames.first.task.fully_qualified_name
4
+ end
5
+ end
6
+
7
+ namespace :deploy do
8
+ desc "Send email notification of deployment (only send variables you want to be in the email)"
9
+ task :notify, :roles => :app do
10
+ show.me # this sets the task_name variable
11
+
12
+ # Set the release notes
13
+ git_commits_range = "#{previous_revision.strip}..#{current_revision.strip}"
14
+ git_log = `git log --pretty=oneline --abbrev-commit #{git_commits_range}` # executes in local shell
15
+ set :release_notes, git_log.blank? ? "No Changes since last deploy." : "from git:\n" + git_log
16
+
17
+ mailer.send_notification_email(self)
18
+ end
19
+ end
20
+
21
+ after "deploy", "deploy:notify"
@@ -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,37 @@
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
+ <%= stylesheet_link_tag @job_status.to_s %>
7
+ </head>
8
+ <body>
9
+
10
+ <div class="mail-content">
11
+ <h1><%= @site_name %> <%=@task_name.titleize unless @task_name.nil? %></h1>
12
+
13
+ <% unless @site_url.nil? %>
14
+ <p class="view-site">
15
+ View site: <a href="<%= @site_url.html_safe -%>"><%= @site_url.html_safe -%></a>
16
+ </p>
17
+ <% end %>
18
+
19
+ <p class="released">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 'section_custom', {:section_title => section, :data => data}
26
+ else
27
+ render 'section', {:section_title => section, :data => data}
28
+ end
29
+ end
30
+ }.join.html_safe unless @sections.nil? %>
31
+ </div>
32
+
33
+ <p class="mail-footer" >
34
+ Brought to you by: <a href="http://github.com/pboling/capistrano_mailer">Capistrano Mailer</a>
35
+ </p>
36
+ </body>
37
+ </html>
@@ -0,0 +1,24 @@
1
+ <%= @site_name %> Notification
2
+ ===========================================================
3
+
4
+ <%= @site_name %> <%=@task_name.titleize unless @task_name.nil? %>
5
+ Job status: <%= @job_status.to_s %>
6
+ ===========================================================
7
+ Brought to you by: Capistrano Mailer - http://github.com/pboling/capistrano_mailer
8
+ Released: <%= @date %> at <%= @time %>
9
+
10
+ <%= @sections.map { |section|
11
+ data = @section_data[section.to_sym]
12
+ if !data.empty?
13
+ if %w(extra_information release_data).include?(section)
14
+ render 'section_custom', {:section_title => section, :data => data}
15
+ else
16
+ render 'section', {:section_title => section, :data => data}
17
+ end
18
+ end
19
+ }.join.html_safe unless @sections.nil? %>
20
+
21
+ ===========================================================
22
+ Copyright 2009 9thBit LLC under MIT License
23
+ Copyright 2007-8 Sagebit LLC under MIT License
24
+
@@ -1,31 +1,29 @@
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,:release_notes]
10
- when 'source_control'
11
- [:scm,:released,:branch,: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].gsub(/\n/, '<br>').gsub(/\n/, '<br>').html_safe : data[key].inspect.html_safe %></span>
25
- </p>
26
- <% end -%>
27
- <% end -%>
28
- <% end -%>
29
- <p style="clear:both"></p>
30
-
31
- </div>
1
+ <div class="section">
2
+ <h2><%= section_title.titleize unless section_title.nil? -%></h2>
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_name,:inferred_command,:host,:release_name,:release_notes]
8
+ when 'source_control'
9
+ [:scm,:released,:branch,: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
+ <p class="data-item">
21
+ <span class="key"><%= key.to_s.titleize %></span>
22
+ <span class="value"><%= data[key].is_a?(Array) ? data[key].to_sentence : data[key].is_a?(String) ? data[key].gsub(/\n/, '<br>').gsub(/\n/, '<br>').html_safe : data[key].inspect.html_safe %></span>
23
+ </p>
24
+ <% end -%>
25
+ <% end -%>
26
+ <% end -%>
27
+ <p style="clear:both"></p>
28
+
29
+ </div>
@@ -1,23 +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,:release_notes]
8
- when 'source_control'
9
- [:scm,:released,:branch,: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 -%>
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,:release_notes]
8
+ when 'source_control'
9
+ [:scm,:released,:branch,: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 -%>
@@ -1,15 +1,15 @@
1
1
  <div style="margin: 20px; padding: 0 0 20px 0;">
2
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? -%>
3
+ <h2 style="margin: 0px; padding: 10px 10px 5px 10px; background: #f3f3f3; color: #333;"><%= section_title.titleize unless section_title.nil? -%></h2>
4
+ <% data.each do |_data| -%>
5
+ <% _data.each do |key, value| %>
7
6
  <p style="margin: 10px; padding: 0px;">
8
7
  <span style="float:left; width:150px; padding: 10px 10px 0;"><%= key %></span>
9
8
  <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>
9
+ <span style="clear: both;"></span>
10
10
  </p>
11
- <% end -%>
11
+ <% end %>
12
12
  <% end unless data.nil?-%>
13
13
  <p style="clear:both"></p>
14
-
14
+
15
15
  </div>
@@ -0,0 +1 @@
1
+ <%= render "message_body" %>
@@ -0,0 +1 @@
1
+ <%= render "message_body" %>
@@ -1,39 +1 @@
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
- <% unless @site_url.nil? %>
16
- <p style="margin: 8px 0 20px 20px; padding: 0px; font-style: italic;" >
17
- View site: <a href="<%= @site_url.html_safe -%>"><%= @site_url.html_safe -%></a>
18
- </p>
19
- <% end %>
20
-
21
- <p style="margin: 10px 20px; font-weight: bold;">Released: <%= @date %> at <%= @time %></p>
22
-
23
- <%= @sections.map { |section|
24
- data = @section_data[section.to_sym]
25
- if !data.empty?
26
- if %w(extra_information release_data).include?(section)
27
- render :partial => 'section_custom.html.erb', :locals => {:section_title => section, :data => data}
28
- else
29
- render :partial => 'section.html.erb', :locals => {:section_title => section, :data => data}
30
- end
31
- end
32
- }.join.html_safe unless @sections.nil? %>
33
- </div>
34
-
35
- <p style="margin: 8px 0 20px 20px; padding: 0px; font-style: italic;" >
36
- Brought to you by: <a href="http://github.com/textgoeshere/capistrano_mailer">Capistrano Mailer</a>
37
- </p>
38
- </body>
39
- </html>
1
+ <%= render "message_body" %>
@@ -1,22 +1 @@
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.text.erb', :locals => {:section_title => section, :data => data}
14
- else
15
- render :partial => 'section.text.erb', :locals => {:section_title => section, :data => data}
16
- end
17
- end
18
- }.join.html_safe unless @sections.nil? %>
19
-
20
- ===========================================================
21
- Copyright 2009 9thBit LLC under MIT License
22
- Copyright 2007-8 Sagebit LLC under MIT License
1
+ <%= render "message_body" %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano_mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,43 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-12-11 00:00:00.000000000Z
14
+ date: 2013-01-22 00:00:00.000000000 Z
15
15
  dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: capistrano-log_with_awesome
18
+ requirement: !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
23
+ version: '0'
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ! '>='
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
32
+ - !ruby/object:Gem::Dependency
33
+ name: inline-style
34
+ requirement: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
16
48
  - !ruby/object:Gem::Dependency
17
49
  name: actionmailer
18
- requirement: &70226373536920 !ruby/object:Gem::Requirement
50
+ requirement: !ruby/object:Gem::Requirement
19
51
  none: false
20
52
  requirements:
21
53
  - - ! '>='
@@ -23,7 +55,12 @@ dependencies:
23
55
  version: '0'
24
56
  type: :runtime
25
57
  prerelease: false
26
- version_requirements: *70226373536920
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
27
64
  description: Capistrano Deployment Email Notification. Keep the whole team informed
28
65
  of each release!
29
66
  email:
@@ -35,17 +72,29 @@ extensions: []
35
72
  extra_rdoc_files:
36
73
  - README.rdoc
37
74
  files:
75
+ - .gitignore
76
+ - CHANGELOG
77
+ - Gemfile
78
+ - Gemfile.lock
38
79
  - MIT-LICENSE
39
80
  - README.rdoc
40
81
  - Rakefile
41
82
  - VERSION.yml
83
+ - assets/stylesheets/failure.css
84
+ - assets/stylesheets/success.css
42
85
  - capistrano_mailer.gemspec
43
86
  - lib/cap_mailer.rb
44
87
  - lib/capistrano/mailer.rb
88
+ - lib/capistrano/mailer_recipes.rb
89
+ - test/build_gem_test.rb
90
+ - views/cap_mailer/_message_body.html.erb
91
+ - views/cap_mailer/_message_body.text.erb
45
92
  - views/cap_mailer/_section.html.erb
46
93
  - views/cap_mailer/_section.text.erb
47
94
  - views/cap_mailer/_section_custom.html.erb
48
95
  - views/cap_mailer/_section_custom.text.erb
96
+ - views/cap_mailer/failed.notification_email.html.erb
97
+ - views/cap_mailer/failed.notification_email.text.erb
49
98
  - views/cap_mailer/notification_email.html.erb
50
99
  - views/cap_mailer/notification_email.text.erb
51
100
  homepage: http://github.com/pboling/capistrano_mailer
@@ -60,6 +109,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
109
  - - ! '>='
61
110
  - !ruby/object:Gem::Version
62
111
  version: '0'
112
+ segments:
113
+ - 0
114
+ hash: -676042409470164499
63
115
  required_rubygems_version: !ruby/object:Gem::Requirement
64
116
  none: false
65
117
  requirements:
@@ -68,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
120
  version: '0'
69
121
  requirements: []
70
122
  rubyforge_project:
71
- rubygems_version: 1.8.10
123
+ rubygems_version: 1.8.24
72
124
  signing_key:
73
125
  specification_version: 3
74
126
  summary: Capistrano Deployment Email Notification