Module: PostmasterGeneral
- Defined in:
- lib/postmaster_general.rb
Class Method Summary collapse
-
.log_deliveries(path, &block) ⇒ Object
logs mail deliveries performed within the specified block to the specified path the path is appended to the previously configured log_directory.
-
.log_directory ⇒ Object
returns the log directory configured previously.
-
.log_directory=(path) ⇒ Object
sets the log directory for actionmailer logging.
Class Method Details
.log_deliveries(path, &block) ⇒ Object
logs mail deliveries performed within the specified block to the specified path the path is appended to the previously configured log_directory
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/postmaster_general.rb', line 18 def self.log_deliveries(path, &block) before_index = ActionMailer::Base.deliveries.size - 1 before_index = 0 if before_index < 0 yield log_path = File.join(log_directory, path) FileUtils.mkdir_p(File.dirname(log_path)) FileUtils.rm_f(log_path) ActionMailer::Base.deliveries[before_index..-1].each do |mail| File.open(log_path, "w+") do |f| f << "==================\r\n" f << (mail.encoded.respond_to?(:force_encoding) ? mail.encoded.force_encoding("UTF-8") : mail.encoded) f << "\r\n==================\r\n" end end end |
.log_directory ⇒ Object
returns the log directory configured previously
12 13 14 |
# File 'lib/postmaster_general.rb', line 12 def self.log_directory configatron.postmaster_general.log_directory end |
.log_directory=(path) ⇒ Object
sets the log directory for actionmailer logging
7 8 9 |
# File 'lib/postmaster_general.rb', line 7 def self.log_directory=(path) configatron.postmaster_general.log_directory = path end |