Class: DMARC::Record
- Inherits:
-
Object
- Object
- DMARC::Record
- Defined in:
- lib/dmarc/record.rb
Instance Attribute Summary collapse
-
#p ⇒ :none, ...
readonly
pfield. -
#rua ⇒ Array<URI::MailTo>
readonly
ruafield. -
#ruf ⇒ Array<URI::MailTo>
readonly
ruafield. -
#sp ⇒ :none, ...
readonly
spfield. -
#v ⇒ :DMARC1
readonly
vfield.
Class Method Summary collapse
-
.from_txt(rec) ⇒ Object
deprecated
Deprecated.
use Record.parse instead.
-
.parse(record) ⇒ Record
Parses a DMARC record.
-
.query(domain, resolver = Resolv::DNS.new) ⇒ Record?
Queries and parses the DMARC record for a domain.
Instance Method Summary collapse
-
#adkim ⇒ :r, :s
adkim=field. -
#aspf ⇒ :r, :s
aspffield. -
#fo ⇒ Array<'0', '1', 'd', 's'>
fofield. -
#initialize(attributes = {}) ⇒ Record
constructor
Initializes the record.
-
#pct ⇒ Integer
pctfield. -
#rf ⇒ :afrf, :iodef
rffield. -
#ri ⇒ Integer
rifield. -
#to_s ⇒ String
Converts the record back to a DMARC String.
Constructor Details
#initialize(attributes = {}) ⇒ Record
Initializes the record.
63 64 65 |
# File 'lib/dmarc/record.rb', line 63 def initialize(attributes={}) @adkim, @aspf, @fo, @p, @pct, @rf, @ri, @rua, @ruf, @sp, @v = attributes.values_at(:adkim, :aspf, :fo, :p, :pct, :rf, :ri, :rua, :ruf, :sp, :v) end |
Instance Attribute Details
#p ⇒ :none, ... (readonly)
p field.
13 14 15 |
# File 'lib/dmarc/record.rb', line 13 def p @p end |
#rua ⇒ Array<URI::MailTo> (readonly)
rua field.
18 19 20 |
# File 'lib/dmarc/record.rb', line 18 def rua @rua end |
#ruf ⇒ Array<URI::MailTo> (readonly)
rua field.
23 24 25 |
# File 'lib/dmarc/record.rb', line 23 def ruf @ruf end |
#sp ⇒ :none, ... (readonly)
sp field.
28 29 30 |
# File 'lib/dmarc/record.rb', line 28 def sp @sp end |
#v ⇒ :DMARC1 (readonly)
v field.
33 34 35 |
# File 'lib/dmarc/record.rb', line 33 def v @v end |
Class Method Details
.from_txt(rec) ⇒ Object
Deprecated.
use parse instead.
150 151 152 |
# File 'lib/dmarc/record.rb', line 150 def self.from_txt(rec) parse(rec) end |
.parse(record) ⇒ Record
Parses a DMARC record.
141 142 143 144 145 |
# File 'lib/dmarc/record.rb', line 141 def self.parse(record) new(Parser.parse(record)) rescue Parslet::ParseFailed => error raise(InvalidRecord.new(error.,error.cause)) end |
.query(domain, resolver = Resolv::DNS.new) ⇒ Record?
Queries and parses the DMARC record for a domain.
174 175 176 177 178 |
# File 'lib/dmarc/record.rb', line 174 def self.query(domain,resolver=Resolv::DNS.new) if (dmarc = DMARC.query(domain,resolver)) parse(dmarc) end end |
Instance Method Details
#adkim ⇒ :r, :s
adkim= field.
76 77 78 |
# File 'lib/dmarc/record.rb', line 76 def adkim @adkim || :r end |
#aspf ⇒ :r, :s
aspf field.
85 86 87 |
# File 'lib/dmarc/record.rb', line 85 def aspf @aspf || :r end |
#fo ⇒ Array<'0', '1', 'd', 's'>
fo field.
94 95 96 |
# File 'lib/dmarc/record.rb', line 94 def fo @fo || %w[0] end |
#pct ⇒ Integer
pct field.
103 104 105 |
# File 'lib/dmarc/record.rb', line 103 def pct @pct || 100 end |
#rf ⇒ :afrf, :iodef
rf field.
112 113 114 |
# File 'lib/dmarc/record.rb', line 112 def rf @rf || :afrf end |
#ri ⇒ Integer
ri field.
121 122 123 |
# File 'lib/dmarc/record.rb', line 121 def ri @ri || 86400 end |
#to_s ⇒ String
Converts the record back to a DMARC String.
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/dmarc/record.rb', line 185 def to_s = [] << "v=#{@v}" if @v << "p=#{@p}" if @p << "sp=#{@sp}" if @sp << "rua=#{@rua.join(',')}" if @rua << "ruf=#{@ruf.join(',')}" if @ruf << "adkim=#{@adkim}" if @adkim << "aspf=#{@aspf}" if @aspf << "ri=#{@ri}" if @ri << "fo=#{@fo.join(':')}" if @fo << "rf=#{@rf}" if @rf << "pct=#{@pct}" if @pct return .join('; ') end |