Class: CapMailer
- Inherits:
-
ActionMailer::Base
- Object
- ActionMailer::Base
- CapMailer
- Defined in:
- lib/cap_mailer.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#date ⇒ Object
Returns the value of attribute date.
-
#inferred_command ⇒ Object
Returns the value of attribute inferred_command.
-
#options ⇒ Object
Returns the value of attribute options.
-
#repo_end ⇒ Object
Returns the value of attribute repo_end.
-
#task_name ⇒ Object
Returns the value of attribute task_name.
-
#time ⇒ Object
Returns the value of attribute time.
Class Method Summary collapse
- .configure {|@@default_base_config| ... } ⇒ Object
- .configure_capistrano_mailer(&block) ⇒ Object
- .reloadable? ⇒ Boolean
Instance Method Summary collapse
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
18 19 20 |
# File 'lib/cap_mailer.rb', line 18 def config @config end |
#date ⇒ Object
Returns the value of attribute date.
19 20 21 |
# File 'lib/cap_mailer.rb', line 19 def date @date end |
#inferred_command ⇒ Object
Returns the value of attribute inferred_command.
19 20 21 |
# File 'lib/cap_mailer.rb', line 19 def inferred_command @inferred_command end |
#options ⇒ Object
Returns the value of attribute options.
18 19 20 |
# File 'lib/cap_mailer.rb', line 18 def @options end |
#repo_end ⇒ Object
Returns the value of attribute repo_end.
19 20 21 |
# File 'lib/cap_mailer.rb', line 19 def repo_end @repo_end end |
#task_name ⇒ Object
Returns the value of attribute task_name.
19 20 21 |
# File 'lib/cap_mailer.rb', line 19 def task_name @task_name end |
#time ⇒ Object
Returns the value of attribute time.
19 20 21 |
# File 'lib/cap_mailer.rb', line 19 def time @time end |
Class Method Details
.configure {|@@default_base_config| ... } ⇒ Object
21 22 23 |
# File 'lib/cap_mailer.rb', line 21 def self.configure(&block) yield @@default_base_config end |
.configure_capistrano_mailer(&block) ⇒ Object
25 26 27 |
# File 'lib/cap_mailer.rb', line 25 def self.configure_capistrano_mailer(&block) puts "Deprecated 'configure_capistrano_mailer'. Please update your capistrano_mailer configuration to use 'configure' instead of 'configure_capistrano_mailer'" end |
.reloadable? ⇒ Boolean
34 |
# File 'lib/cap_mailer.rb', line 34 def self.reloadable?() false end |
Instance Method Details
#notification_email(cap, config = {}, *args) ⇒ Object
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 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 |
# File 'lib/cap_mailer.rb', line 36 def notification_email(cap, config = {}, *args) @options = { :release_data => {}, :extra_information => {}, :data => {} }.merge(args.) @config = default_base_config.merge(config.reverse_merge({ :rails_env => cap.rails_env, :host => cap.host, :task_name => cap.task_name, :application => cap.application, :repository => cap.repository, :scm => cap.scm, :deploy_via => cap.deploy_via, :deploy_to => cap.deploy_to, :revision => cap.revision, :real_revision => cap.real_revision, :release_name => cap.release_name, :release_notes => cap.release_notes, :version_dir => cap.version_dir, :shared_dir => cap.shared_dir, :current_dir => cap.current_dir, :releases_path => cap.releases_path, :shared_path => cap.shared_path, :current_path => cap.current_path, :release_path => cap.release_path, :releases => cap.releases, :current_release => cap.current_release, :previous_release => cap.previous_release, :current_revision => cap.current_revision, :latest_revision => cap.latest_revision, :previous_revision => cap.previous_revision, :run_method => cap.run_method, :latest_release => cap.latest_release })) @date = Date.today.to_s @time = Time.now.strftime("%I:%M %p").to_s @inferred_command = "cap #{@config[:rails_env]} #{@config[:task_name]}" @task_name = @config[:task_name] || "unknown" repo = @config[:repository] x = repo.include?('/') ? repo.rindex('/') - 1 : repo.length front = repo.slice(0..x) back = repo.sub(front, '') unless back == 'trunk' x = front.include?('/') ? front.rindex('/') - 1 : front.length front = front.slice(0..x) end @repo_end = repo.sub(front, '') body_data_hash.each_pair do |k, v| self.instance_variable_set("@#{k}", v) end log = cap.fetch(:full_log) fail_pattern = /^failed|rolling back/i @job_status = (log =~ fail_pattern) ? :failure : cap.fetch(:mailer_status, :success) template_prefix = @config[:template_prefixes][@job_status] ? "#{@config[:template_prefixes][@job_status]}." : "" template_name = @config[:template_name] || "#{template_prefix}#{action_name}" attach_log = case @config[:attach_log_on] when Symbol, String @job_status == @config[:attach_log_on].to_sym when Array @config[:attach_log_on].collect(&:to_sym).include? @job_status else false end if attach_log log_file_name = "deploy-log-#{Time.now.strftime("%Y-%m-%d-%H%M%S")}.txt" [log_file_name] = { :content => log, :mime_type => "text/plain" } end self.config.assets_dir = "#{File.dirname(__FILE__)}/../assets" mail :subject => "#{@job_status.to_s.upcase}: #{subject_line}", :to => @config[:recipient_addresses], :from => @config[:sender_address], :template_name => template_name end |