Class: DMARC::Parser
- Inherits:
-
Parslet::Parser
- Object
- Parslet::Parser
- DMARC::Parser
- Defined in:
- lib/dmarc/parser.rb
Overview
DMARC parser.
Defined Under Namespace
Classes: Transform
Class Method Summary collapse
-
.parse(record) ⇒ Hash{Symbol => Object}
Parses a DMARC record.
- .tag_rule(name, tag, &block) ⇒ Object
Class Method Details
.parse(record) ⇒ Hash{Symbol => Object}
Parses a DMARC record.
216 217 218 219 220 221 222 223 |
# File 'lib/dmarc/parser.rb', line 216 def self.parse(record) = Transform.new.apply(new.parse(record)) hash = {} .each { |tag| hash.merge!(tag) } return hash end |
.tag_rule(name, tag, &block) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/dmarc/parser.rb', line 45 def self.tag_rule(name,tag,&block) rule(:"dmarc_#{name}") do str(tag) >> wsp? >> str('=') >> wsp? >> (instance_eval(&block).as(tag.to_sym) | unknown_value) end end |