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/README.md DELETED
@@ -1,268 +0,0 @@
1
- # CapistranoMailer
2
-
3
- A Gem For Capistrano Deployment Email Notification
4
-
5
- | Project | Capistrano Mailer |
6
- |------------------------ | ----------------- |
7
- | gem name | capistrano_mailer |
8
- | license | MIT |
9
- | moldiness | [![Maintainer Status](http://stillmaintained.com/pboling/capistrano_mailer.png)](http://stillmaintained.com/pboling/capistrano_mailer) |
10
- | version | [![Gem Version](https://badge.fury.io/rb/capistrano_mailer.png)](http://badge.fury.io/rb/capistrano_mailer) |
11
- | dependencies | [![Dependency Status](https://gemnasium.com/pboling/capistrano_mailer.png)](https://gemnasium.com/pboling/capistrano_mailer) |
12
- | code quality | [![Code Climate](https://codeclimate.com/github/pboling/capistrano_mailer.png)](https://codeclimate.com/github/pboling/capistrano_mailer) |
13
- | inline documenation | [![Inline docs](http://inch-pages.github.io/github/pboling/capistrano_mailer.png)](http://inch-pages.github.io/github/pboling/capistrano_mailer) |
14
- | continuous integration | [![Build Status](https://travis-ci.org/pboling/capistrano_mailer.png?branch=rails2)](https://travis-ci.org/pboling/capistrano_mailer) |
15
- | test coverage | [![Coverage Status](https://coveralls.io/repos/pboling/capistrano_mailer/badge.png)](https://coveralls.io/r/pboling/capistrano_mailer) |
16
- | homepage | [https://github.com/pboling/capistrano_mailer][homepage] |
17
- | documentation | [http://rdoc.info/github/pboling/capistrano_mailer/frames][documentation] |
18
- | author | [Peter Boling](https://coderbits.com/pboling) |
19
- | Spread ~♡ⓛⓞⓥⓔ♡~ | [![Endorse Me](https://api.coderwall.com/pboling/endorsecount.png)](http://coderwall.com/pboling) |
20
-
21
- ## Summary
22
-
23
- * It is a Capistrano Plugin / Ruby Gem that requires ActionMailer
24
- * It is MIT licensed
25
- * It is old, but still kicking; project started in 2007
26
- * rails2 branch (THIS BRANCH!), releases will be in 3.x range, requires Rails 2.X
27
- * master branch, releases will be in 4.x range, requires Rails 3.X
28
- * Requires at least Capistrano 2.4.3 (might work with capistrano as old as 2.1.0, but has not been tested)
29
- * Known to be compatible with SCMs as of version 3.1.2: Perforce, SVN, and Git
30
- * Known to be compatible with, but does not require, the deprec gem.
31
-
32
- ## About
33
-
34
- Ever wanted to be emailed whenever someone on the team does a cap deploy of trunk or some tag to some server.
35
- 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,
36
- and this plugin makes sure everyone on the need to know list is notified when something new is deployed.
37
-
38
- This plugin/gem is an extension to Capistrano.
39
-
40
- That means it registers itself with Capistrano as a plugin and is therefore available to call in your recipes.
41
-
42
- If you are looking to roll your own email integration into capistrano then try this pastie:
43
- http://pastie.org/146264 (thanks to Mislav Marohnić).
44
- But if you want to take the easy road to riches then keep reading ;)
45
- -- figurative "riches" of course, I promise nothing in return for your using this plugin
46
-
47
- ### Important Note:
48
-
49
- 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!
50
-
51
- ## Installation
52
-
53
- Add this line to your application's Gemfile:
54
-
55
- gem 'capistrano_mailer', '~> 3.3.0'
56
-
57
- And then execute:
58
-
59
- $ bundle
60
-
61
- Or install it yourself as:
62
-
63
- $ gem install capistrano_mailer
64
-
65
- ### With Rails <= 2.X (THIS BRANCH!)
66
-
67
- The 3.x+ versions of this gem require Rails 2.X
68
-
69
- ### With Rails >= 3.X (NOT THIS BRANCH!)
70
-
71
- Switch to the master branch (releases will be in 4+ range)
72
- The 4.x+ versions of this gem require at least Rails 3
73
-
74
- ## Upgrading
75
-
76
- From version 3.2.x to version 3.3.x
77
-
78
- 1. If you had customized mailer views you might need to update the name.
79
- The built-in views have been changed from with a `.text`:
80
-
81
- `notification_email.text.html.erb`
82
-
83
- to without
84
-
85
- `notification_email.html.erb`
86
-
87
- From version 3.1.x to version 3.2.x
88
-
89
- 1. Update the way CapistranoMailer is configured using the new method: CapMailer.configure (see Usage below).
90
- 2. require the cap mailer config file (see Usage below)
91
-
92
- From version 2.1.0 to version 3.1.x:
93
-
94
- 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).
95
- 2. Update the require statement at the top of deploy.rb, see below (note for plugin change from capistrano_mailer to capistrano/mailer).
96
- 3. Change the mailer.send to mailer.send_notification_email in your cap recipe.
97
-
98
- ## Usage
99
-
100
- 1) You need to have already setup capistrano in the project, including the 'capify .' command.
101
-
102
- 2) Load the Capistrano plugin: Add this line to the top of your config/deploy.rb:
103
-
104
- require 'capistrano/mailer'
105
-
106
- # configure capistrano_mailer
107
- # The configuration file can go anywhere, but in past versions of the gem it was required to be in the config/ dir.
108
- require 'config/cap_mailer_settings'
109
-
110
- 3) Configure Capistrano Mailer in the settings file required in step 2 (`config/cap_mailer_settings` or whatever you called it):
111
-
112
- ActionMailer::Base.delivery_method = :sendmail
113
- ActionMailer::Base.default_charset = "utf-8"
114
- ActionMailer::Base.sendmail_settings = {
115
- :location => '/usr/sbin/sendmail',
116
- :arguments => "-i -t -f deploy@example.com" # the address your deployment notification emails will come from
117
- }
118
-
119
- CapMailer.configure do |config|
120
- config[:recipient_addresses] = ["dev1@example.com"]
121
- config[:sender_address] = "deployment@example.com"
122
- config[:subject_prepend] = "[EMPTY-CAP-DEPLOY]"
123
- config[:site_name] = "Empty Example.com App"
124
- end
125
-
126
- 4) Setup the tasks.
127
-
128
- # load recipes for notification (or roll your own)
129
- require 'capistrano/mailer_recipes'
130
-
131
- OR: Roll your own! Add these two tasks to your deploy.rb:
132
-
133
- namespace :show do
134
- task :me do
135
- set :task_name, task_call_frames.first.task.fully_qualified_name
136
- end
137
- end
138
-
139
- namespace :deploy do
140
- desc "Send email notification of deployment"
141
- task :notify, :roles => :app do
142
- show.me # this sets the task_name variable
143
-
144
- # Set the release notes
145
- git_commits_range = "#{previous_revision.strip}..#{current_revision.strip}"
146
- git_log = `git log --pretty=oneline --abbrev-commit #{git_commits_range}` # executes in local shell
147
- set :release_notes, git_log.blank? ? "No Changes since last deploy." : "from git:\n" + git_log
148
-
149
- # These are overridden by settings from configure the block:
150
- # CapMailer.configure do |config|
151
- # config[:attach_log_on] = [:failure]
152
- # end
153
- mailer.send_notification_email(self, {
154
- #:attach_log_on => [:success, :failure],
155
- :release_notes => release_notes
156
- })
157
- end
158
- end
159
-
160
-
161
- 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!
162
-
163
- 6) The only parameter to mailer.send_notification_email that is *required* is the first, and it should always be `self`. _Minimally_ you need to define the capistrano variables:
164
-
165
- :rails_env
166
- :repository
167
- :task_name (provided by the show:me task included in this readme)
168
- :deploy_to
169
- :host
170
- :application
171
-
172
- 7) You can `set` any variable and send it to be rendered as a custom section in the notification email using the third parameter to `send_notification_email`:
173
-
174
- set :hot_slice_of_wonder, 'This is just so cool'
175
-
176
- mailer.send_notification_email(
177
- self, # will contain everything defined with set, but capistrano mailer will only know to pull some of them for rendering
178
- { :attach_log_on => [:success, :failure] }, # Custom configurations
179
- { :my_super_awesome_thing => hot_slice_of_wonder }
180
- )
181
-
182
- 8) Then add the hook somewhere in your deploy.rb (if you required `capistrano/mailer_recipes` this is already done):
183
-
184
- after "deploy", "deploy:notify"
185
-
186
- 9) Enjoy and Happy Capping!
187
-
188
- ## Customization
189
-
190
- If you want to use your own views you'll need to recreate the notification_email view:
191
- First you need to define where your templates are:
192
-
193
- CapMailer.configure_capistrano_mailer do |config|
194
- config[:template_root] = "app/views/capistrano_mailer/"
195
- end
196
-
197
- Then you'll need to create templates there called:
198
-
199
- `notification_email.html.erb`
200
-
201
- and / or
202
-
203
- `notification_email.plain.erb`
204
-
205
- Take a look at the templates that comes with the plugin to see how it is done (views/cap_mailer/...)
206
-
207
- ## Credit where Credit is Due
208
-
209
- [Peter Boling (pboling)](https://github.com/pboling) - Wrote original & maintainer
210
- [Dave Nolan (textgoeshere)](https://github.com/textgoeshere) - lots of refactoring for 3.2 release
211
- [Jason Rust (jrust)](https://github.com/jrust) - Updated for Rails 3 compatibility
212
-
213
- Thanks to [Dustin Deyoung (ddeyoung)](https://github.com/ddeyoung) for the beautiful HTML email templates.
214
- Thanks to mixonix and [Yoan Blanc (greut)](https://github.com/greut) for work on SCMs compatibility
215
-
216
- ## How you can help!
217
-
218
- Take a look at the `reek` list which is the file called `REEK` and stat fixing things. Once you complete a change, run the tests:
219
-
220
- ```
221
- bundle exec rake test:all
222
- ```
223
-
224
- If the tests pass refresh the `reek` list:
225
-
226
- ```
227
- bundle exec rake reek > REEK
228
- ```
229
-
230
- Follow the instructions for "Contributing" below.
231
-
232
- ## Contributing
233
-
234
- 1. Fork it
235
- 2. Create your feature branch (`git checkout -b my-new-feature`)
236
- 3. Commit your changes (`git commit -am 'Add some feature'`)
237
- 4. Push to the branch (`git push origin my-new-feature`)
238
- 5. Create new Pull Request
239
-
240
- ## Versioning
241
-
242
- This library aims to adhere to [Semantic Versioning 2.0.0][semver].
243
- Violations of this scheme should be reported as bugs. Specifically,
244
- if a minor or patch version is released that breaks backward
245
- compatibility, a new version should be immediately released that
246
- restores compatibility. Breaking changes to the public API will
247
- only be introduced with new major versions.
248
-
249
- As a result of this policy, you can (and should) specify a
250
- dependency on this gem using the [Pessimistic Version Constraint][pvc] with two digits of precision.
251
-
252
- For example:
253
-
254
- spec.add_dependency 'capistrano_mailer', '~> 0.5'
255
-
256
- ## License
257
-
258
- * MIT License - See LICENSE file in this project
259
- * Copyright (c) 2008-2014 [Peter H. Boling][peterboling] of [Rails Bling][railsbling]
260
- * Copyright (c) 2007-8 Peter Boling & Sagebit, LLC
261
-
262
- [semver]: http://semver.org/
263
- [pvc]: http://docs.rubygems.org/read/chapter/16#page74
264
- [railsbling]: http://www.railsbling.com
265
- [peterboling]: http://www.peterboling.com
266
- [documentation]: http://rdoc.info/github/pboling/capistrano_mailer/frames
267
- [homepage]: https://github.com/pboling/capistrano_mailer
268
-
@@ -1,43 +0,0 @@
1
- Capistrano::Configuration.instance(:must_exist).load do
2
-
3
- namespace :show do
4
- task :me do
5
- set :task_name, task_call_frames.first.task.fully_qualified_name
6
- end
7
- end
8
-
9
- namespace :deploy do
10
- desc "Send email notification of deployment"
11
- task :notify, :roles => :app do
12
- show.me # this sets the task_name variable
13
-
14
- # Set the release notes
15
- git_commits_range = "#{previous_revision.strip}..#{current_revision.strip}"
16
- git_log = `git log --pretty=oneline --abbrev-commit #{git_commits_range}` # executes in local shell
17
- set :release_notes, git_log.blank? ? "No Changes since last deploy." : "from git:\n" + git_log
18
-
19
- # These are overridden by the configuration in the block:
20
- # CapMailer.configure do |config|
21
- # config[:attach_log_on] = [:failure]
22
- # end
23
- mailer.send_notification_email(self, {
24
- #:attach_log_on => [:success, :failure],
25
- :release_notes => release_notes
26
- })
27
- end
28
-
29
- # This is to test hte cap mailer notification system.
30
- # Execute:
31
- # bundle exec cap staging deploy:nothing
32
- task :nothing, :roles => :app do
33
- puts "DOING NOTHING!"
34
- set :release_notes, "No Changes since last deploy."
35
- end
36
-
37
- end
38
-
39
- after "deploy", "deploy:notify"
40
-
41
- after "deploy:nothing", "deploy:notify"
42
-
43
- end
@@ -1,2 +0,0 @@
1
- # Just a shim
2
- require 'capistrano/mailer'
@@ -1,3 +0,0 @@
1
- module CapistranoMailer
2
- VERSION = "3.3.0"
3
- end
@@ -1,44 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "rvm:create_gemset task" do
4
- include_context "Capistrano::Configuration"
5
-
6
- before {
7
- @gemset = 'mygemset'
8
- @configuration.set :rvm_ruby_string, '2.0.0@' + @gemset
9
- @task = @configuration.find_task 'rvm:create_gemset'
10
- }
11
-
12
- it "should create a gemset in $HOME" do
13
- @configuration.trigger :load
14
- expected = "$HOME/.rvm/bin/rvm 2.0.0 do rvm gemset create #{@gemset}"
15
- @task.namespace.should_receive(:run_without_rvm).with(expected)
16
- @configuration.execute_task @task
17
- end
18
-
19
- it "should create a system-wide gemset" do
20
- @configuration.set :rvm_type, :system
21
- @configuration.trigger :load
22
- expected = <<-EOSHELL.gsub(/^ /, '')
23
- if id | grep ' groups=.*(rvm)' >/dev/null ;
24
- then /usr/local/rvm/bin/rvm 2.0.0 do rvm gemset create #{@gemset} ;
25
- else sudo -p 'sudo password: ' sg rvm -c '/usr/local/rvm/bin/rvm 2.0.0 do rvm gemset create #{@gemset}' ;
26
- fi
27
- EOSHELL
28
- @task.namespace.should_receive(:run_without_rvm).with(expected)
29
- @configuration.execute_task @task
30
- end
31
-
32
- it "should create a gemset in $HOME in mixed mode" do
33
- @configuration.set :rvm_ruby_string, '2.0.0@' + @gemset
34
- @configuration.set :rvm_type, :mixed
35
- @configuration.set :rvm_user, [ :gemsets ]
36
- @configuration.trigger :load
37
- task = @configuration.find_task 'rvm:create_gemset'
38
- expected = \
39
- "/usr/local/rvm/bin/rvm 2.0.0 do rvm user gemsets ; " +
40
- "/usr/local/rvm/bin/rvm 2.0.0 do rvm gemset create #{@gemset}"
41
- task.namespace.should_receive(:run_without_rvm).with(expected)
42
- @configuration.execute_task task
43
- end
44
- end
@@ -1,32 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "rvm:create_gemset task" do
4
- include_context "Capistrano::Configuration"
5
-
6
- before {
7
- @configuration.require 'rvm/capistrano/empty_gemset'
8
- @gemset = 'mygemset'
9
- @configuration.set :rvm_ruby_string, '2.0.0@' + @gemset
10
- @task = @configuration.find_task 'rvm:empty_gemset'
11
- }
12
-
13
- it "should empty a gemset in $HOME" do
14
- @configuration.trigger :load
15
- expected = "$HOME/.rvm/bin/rvm 2.0.0 do rvm --force gemset empty #{@gemset}"
16
- @task.namespace.should_receive(:run_without_rvm).with(expected)
17
- @configuration.execute_task @task
18
- end
19
-
20
- it "should empty a system-wide gemset" do
21
- @configuration.set :rvm_type, :system
22
- @configuration.trigger :load
23
- expected = <<-EOSHELL.gsub(/^ /, '')
24
- if id | grep ' groups=.*(rvm)' >/dev/null ;
25
- then /usr/local/rvm/bin/rvm 2.0.0 do rvm --force gemset empty #{@gemset} ;
26
- else sudo -p 'sudo password: ' sg rvm -c '/usr/local/rvm/bin/rvm 2.0.0 do rvm --force gemset empty #{@gemset}' ;
27
- fi
28
- EOSHELL
29
- @task.namespace.should_receive(:run_without_rvm).with(expected)
30
- @configuration.execute_task @task
31
- end
32
- end
@@ -1,120 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "rvm:install_ruby task" do
4
- include_context "Capistrano::Configuration"
5
-
6
- before {
7
- @gemset = 'mygemset'
8
- @configuration.set :rvm_ruby_string, '2.0.0@' + @gemset
9
- @task = @configuration.find_task 'rvm:install_ruby'
10
- }
11
-
12
- it "should install a ruby in $HOME" do
13
- @configuration.trigger :load
14
- expected = ' ' + <<-EOSHELL.gsub(/^\s+/, '').gsub("\n", ' ')
15
- __LAST_STATUS=0;
16
- export CURL_HOME=\"${TMPDIR:-${HOME}}/.rvm-curl-config.$$\";
17
- mkdir ${CURL_HOME}/;
18
- {
19
- [[ -r ${HOME}/.curlrc ]] && cat ${HOME}/.curlrc;
20
- echo \"silent\";
21
- echo \"show-error\";
22
- } > $CURL_HOME/.curlrc;
23
- $HOME/.rvm/bin/rvm --autolibs=2 install 2.0.0 ;
24
- $HOME/.rvm/bin/rvm 2.0.0 do rvm gemset create mygemset || __LAST_STATUS=$?;
25
- rm -rf $CURL_HOME;
26
- exit ${__LAST_STATUS}
27
- EOSHELL
28
- @configuration.should_receive(:run_without_rvm).with(expected)
29
- @configuration.execute_task @task
30
- end
31
-
32
- it "should install a ruby system-wide" do
33
- @configuration.set :rvm_type, :system
34
- @configuration.trigger :load
35
- expected = ' ' + <<-EOSHELL.gsub(/^\s+/, '').gsub("\n", ' ')
36
- __LAST_STATUS=0;
37
- export CURL_HOME=\"${TMPDIR:-${HOME}}/.rvm-curl-config.$$\";
38
- mkdir ${CURL_HOME}/;
39
- {
40
- [[ -r ${HOME}/.curlrc ]] && cat ${HOME}/.curlrc;
41
- echo \"silent\";
42
- echo \"show-error\";
43
- } > $CURL_HOME/.curlrc;
44
- if id | grep ' groups=.*(rvm)' >/dev/null ; then
45
- /usr/local/rvm/bin/rvm --autolibs=2 install 2.0.0 ;
46
- else
47
- sudo -p 'sudo password: ' sg rvm -c '/usr/local/rvm/bin/rvm --autolibs=2 install 2.0.0 ' ;
48
- fi ;
49
- if id | grep ' groups=.*(rvm)' >/dev/null ; then
50
- /usr/local/rvm/bin/rvm 2.0.0 do rvm gemset create mygemset ;
51
- else
52
- sudo -p 'sudo password: ' sg rvm -c '/usr/local/rvm/bin/rvm 2.0.0 do rvm gemset create mygemset' ;
53
- fi || __LAST_STATUS=$?;
54
- rm -rf $CURL_HOME;
55
- exit ${__LAST_STATUS}
56
- EOSHELL
57
- @configuration.should_receive(:run_without_rvm).with(expected)
58
- @configuration.execute_task @task
59
- end
60
-
61
- context "in mixed mode with user gemsets" do
62
- before do
63
- @configuration.set :rvm_type, :mixed
64
- @configuration.set :rvm_user, [ :gemsets ]
65
- @configuration.trigger :load
66
- end
67
-
68
- it "should install a ruby system-wide and create a user gemset" do
69
- expected = ' ' + <<-EOSHELL.gsub(/^\s+/, '').gsub("\n", ' ')
70
- __LAST_STATUS=0;
71
- export CURL_HOME=\"${TMPDIR:-${HOME}}/.rvm-curl-config.$$\";
72
- mkdir ${CURL_HOME}/;
73
- {
74
- [[ -r ${HOME}/.curlrc ]] && cat ${HOME}/.curlrc;
75
- echo \"silent\";
76
- echo \"show-error\";
77
- } > $CURL_HOME/.curlrc;
78
- /usr/local/rvm/bin/rvm 2.0.0 do rvm user gemsets ;
79
- if id | grep ' groups=.*(rvm)' >/dev/null ; then
80
- /usr/local/rvm/bin/rvm --autolibs=2 install 2.0.0 ;
81
- else
82
- sudo -p 'sudo password: ' sg rvm -c '/usr/local/rvm/bin/rvm --autolibs=2 install 2.0.0 ' ;
83
- fi ;
84
- /usr/local/rvm/bin/rvm 2.0.0 do rvm gemset create mygemset || __LAST_STATUS=$?;
85
- rm -rf $CURL_HOME;
86
- exit ${__LAST_STATUS}
87
- EOSHELL
88
- @configuration.should_receive(:run_without_rvm).with(expected)
89
- @configuration.execute_task @task
90
- end
91
- end
92
-
93
- context "in mixed mode with user rubies and gemsets" do
94
- before do
95
- @configuration.set :rvm_type, :mixed
96
- @configuration.set :rvm_user, [ :rubies, :gemsets ]
97
- @configuration.trigger :load
98
- end
99
-
100
- it "should install a ruby and create a gemset in $HOME" do
101
- expected = ' ' + <<-EOSHELL.gsub(/^\s+/, '').gsub("\n", ' ')
102
- __LAST_STATUS=0;
103
- export CURL_HOME=\"${TMPDIR:-${HOME}}/.rvm-curl-config.$$\";
104
- mkdir ${CURL_HOME}/;
105
- {
106
- [[ -r ${HOME}/.curlrc ]] && cat ${HOME}/.curlrc;
107
- echo \"silent\";
108
- echo \"show-error\";
109
- } > $CURL_HOME/.curlrc;
110
- /usr/local/rvm/bin/rvm 2.0.0 do rvm user rubies gemsets ;
111
- /usr/local/rvm/bin/rvm --autolibs=2 install 2.0.0 ;
112
- /usr/local/rvm/bin/rvm 2.0.0 do rvm gemset create mygemset || __LAST_STATUS=$?;
113
- rm -rf $CURL_HOME;
114
- exit ${__LAST_STATUS}
115
- EOSHELL
116
- @configuration.should_receive(:run_without_rvm).with(expected)
117
- @configuration.execute_task @task
118
- end
119
- end
120
- end