Module: Capistrano::Notifier::Helpers::Mail
- Defined in:
- lib/capistrano/notifier/helpers/mail.rb
Instance Method Summary collapse
- #application ⇒ Object
- #branch ⇒ Object
- #content_type_for_format(format = nil) ⇒ Object
- #delivery_method ⇒ Object
- #email_format ⇒ Object
- #email_from ⇒ Object
- #email_subject ⇒ Object
- #email_template ⇒ Object
- #email_text ⇒ Object
- #email_to ⇒ Object
- #git_commit_prefix ⇒ Object
- #git_compare_prefix ⇒ Object
- #git_current_revision ⇒ Object
- #git_log ⇒ Object
- #git_log_command ⇒ Object
- #git_prefix ⇒ Object
- #git_previous_revision ⇒ Object
- #git_range(ranger = "..") ⇒ Object
- #github ⇒ Object
- #github_range ⇒ Object
- #giturl ⇒ Object
- #notifier_mail_options ⇒ Object
- #notifier_smtp_settings ⇒ Object
- #now ⇒ Object
- #render_template(template_name) ⇒ Object
- #stage ⇒ Object
- #system_call(command) ⇒ Object
- #templates_path ⇒ Object
- #user_name ⇒ Object
Instance Method Details
#application ⇒ Object
5 6 7 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 5 def application fetch :application end |
#branch ⇒ Object
9 10 11 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 9 def branch fetch(:branch, "master") end |
#content_type_for_format(format = nil) ⇒ Object
125 126 127 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 125 def content_type_for_format(format = nil) format == :html ? 'text/html' : 'text/plain' end |
#delivery_method ⇒ Object
90 91 92 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 90 def delivery_method [:method] end |
#email_format ⇒ Object
58 59 60 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 58 def email_format [:format] || :text end |
#email_from ⇒ Object
66 67 68 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 66 def email_from [:from] end |
#email_subject ⇒ Object
98 99 100 101 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 98 def email_subject [:subject] || "#{application} branch #{branch} deployed to #{stage}" end |
#email_template ⇒ Object
62 63 64 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 62 def email_template [:template] || "mail.#{email_format.to_s}.erb" end |
#email_text ⇒ Object
117 118 119 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 117 def email_text render_template(email_template) end |
#email_to ⇒ Object
121 122 123 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 121 def email_to [:to] end |
#git_commit_prefix ⇒ Object
82 83 84 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 82 def git_commit_prefix "#{git_prefix}/commit" end |
#git_compare_prefix ⇒ Object
86 87 88 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 86 def git_compare_prefix "#{git_prefix}/compare" end |
#git_current_revision ⇒ Object
13 14 15 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 13 def git_current_revision fetch :current_revision end |
#git_log ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 34 def git_log return unless git_range command = git_log_command || 'git log #{git_range} --no-merges --format=format:"%h %s (%an)"' system_call(command) end |
#git_log_command ⇒ Object
30 31 32 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 30 def git_log_command [:log_command] end |
#git_prefix ⇒ Object
78 79 80 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 78 def git_prefix giturl ? giturl : "https://github.com/#{github}" end |
#git_previous_revision ⇒ Object
17 18 19 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 17 def git_previous_revision fetch :previous_revision end |
#git_range(ranger = "..") ⇒ Object
21 22 23 24 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 21 def git_range(ranger = "..") return unless git_previous_revision && git_current_revision "#{git_previous_revision}#{ranger}#{git_current_revision}" end |
#github ⇒ Object
70 71 72 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 70 def github [:github] end |
#github_range ⇒ Object
26 27 28 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 26 def github_range git_range("...") end |
#giturl ⇒ Object
74 75 76 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 74 def giturl [:giturl] end |
#notifier_mail_options ⇒ Object
54 55 56 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 54 def @notifier_mail_options ||= fetch :notifier_mail_options end |
#notifier_smtp_settings ⇒ Object
94 95 96 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 94 def notifier_smtp_settings [:smtp_settings] end |
#now ⇒ Object
42 43 44 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 42 def now @now ||= Time.now end |
#render_template(template_name) ⇒ Object
103 104 105 106 107 108 109 110 111 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 103 def render_template(template_name) config_file = "#{templates_path}/#{template_name}" unless File.exists?(config_file) config_file = File.join(File.dirname(__FILE__),'..', "templates/#{template_name}") end ERB.new(File.read(config_file), nil, '-').result(binding) end |
#stage ⇒ Object
46 47 48 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 46 def stage fetch :stage end |
#system_call(command) ⇒ Object
129 130 131 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 129 def system_call(command) `#{command}` end |
#templates_path ⇒ Object
113 114 115 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 113 def templates_path [:templates_path] || 'config/deploy/templates' end |
#user_name ⇒ Object
50 51 52 |
# File 'lib/capistrano/notifier/helpers/mail.rb', line 50 def user_name ENV['DEPLOYER'] || system_call("git config --get user.name").strip end |