Module: QmailLog::Analyze::Helper

Included in:
QmailLog::Analyzer
Defined in:
lib/qmail_log/analyze/helper.rb

Instance Method Summary collapse

Instance Method Details

#delivery(content) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/qmail_log/analyze/helper.rb', line 33

def delivery content
  _, delivery_id, *status = content.split
  {
    delivery_id: delivery_id.gsub(':', ''),
    status:      status.join(' ')
  }
end

#info(content) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/qmail_log/analyze/helper.rb', line 14

def info content
  _, _, _, _, bytes, _, from, _, qp, _, uid = content.split
  {
    bytes: bytes,
    from:  from.gsub(/<(.*)>/, '\1'),
    qp:    qp,
    uid:   uid
  }
end

#queue_id(content, qid_from_did) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/qmail_log/analyze/helper.rb', line 4

def queue_id content, qid_from_did
  case content
  when /new/      then content.split[2]
  when /info/     then content.split[2].gsub(':', '')
  when /starting/ then content.split[4]
  when /delivery/ then qid_from_did[ content.split[1].gsub(':', '') ]
  when /end/      then content.split[2]
  end
end

#starting(content) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/qmail_log/analyze/helper.rb', line 24

def starting content
  _, _, delivery_id, _, _, _, region, to = content.split
  {
    delivery_id: delivery_id.gsub(':', ''),
    region:      region,
    to:          to
  }
end