diff options
author | Matthew Landauer <matthew@openaustralia.org> | 2012-10-10 14:07:05 +1100 |
---|---|---|
committer | Matthew Landauer <matthew@openaustralia.org> | 2012-10-10 14:07:05 +1100 |
commit | 79c26d3b5fa7d77ca22f77b6c70d42212bd7a578 (patch) | |
tree | 71c4dbd1187b4a468cb60ec48f2bac5cd08e769b | |
parent | 6ea0e665066b7075e61f9e65ea109e6a2a468c4a (diff) |
Extract method
-rw-r--r-- | app/models/exim_log.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/models/exim_log.rb b/app/models/exim_log.rb index ef9afe317..cbe2277c5 100644 --- a/app/models/exim_log.rb +++ b/app/models/exim_log.rb @@ -77,14 +77,18 @@ class EximLog < ActiveRecord::Base result = {} f.each do |line| emails = email_addresses_on_line(line) - # Assume the log file was written using syslog and parse accordingly - queue_id = SyslogProtocol.parse("<13>" + line).content.match(/^\S+: (\S+):/)[1] + queue_id = extract_queue_id_from_syslog_line(line) result[queue_id] = [] unless result.has_key?(queue_id) result[queue_id] = (result[queue_id] + emails).uniq end result end + def EximLog.extract_queue_id_from_syslog_line(line) + # Assume the log file was written using syslog and parse accordingly + SyslogProtocol.parse("<13>" + line).content.match(/^\S+: (\S+):/)[1] + end + def EximLog.email_addresses_on_line(line) line.scan(/request-[^\s]+@#{Configuration::incoming_email_domain}/).sort.uniq end |