Class: BriefMail::Mailer
- Inherits:
-
ActionMailer::Base
- Object
- ActionMailer::Base
- BriefMail::Mailer
- Defined in:
- lib/brief_mail/mailer.rb
Overview
Note mail is sent from the machine doing the deployment, not from the remote host.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.load_config(config) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/brief_mail/mailer.rb', line 8 def self.load_config(config) raise ArgumentError, %(:mailer config is required, and must behave like a Hash) unless config and config.respond_to?(:each_pair) config.each_pair do |k, v| assign = "#{k}=" if Mailer.respond_to?(assign) Mailer.send(assign, v) else raise ArgumentError, %("%s" is an invalid ActionMailer config option) % k end end end |
Instance Method Details
#deploy_notification(config) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/brief_mail/mailer.rb', line 21 def deploy_notification(config) @config = ConfigAdapters.adapter_for(config) @scm = SCMAdapters.adapter_for(@config.scm, @config) Mailer.load_config(@config.mailer) # Add lib directory for this gem to view path: view_paths << File.("../../", __FILE__) recipients = @config.recipients or raise %(One or more recipients are required.) subj = @config.subject || %([DEPLOY] %s deployed to %s) % [@config.application, @config.stage] template = @config.from_user[:template] || "brief_mail/views/deploy_notification.txt" mail( to: recipients, subject: subj ) do |format| format.text { render template } end puts %(Sent mail to %s.) % [recipients].join(", ") end |