Class: DMARC::Record
- Inherits:
-
Object
- Object
- DMARC::Record
- Defined in:
- lib/dmarc/record.rb
Instance Attribute Summary collapse
-
#p ⇒ :none, ...
readonly
p
field. -
#rua ⇒ Array<Uri>
readonly
rua
field. -
#ruf ⇒ Array<Uri>
readonly
rua
field. -
#sp ⇒ :none, ...
readonly
The
sp=
field. -
#v ⇒ :DMARC1
readonly
v
field.
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. -
#adkim? ⇒ Boolean
Determines whether the
adkim=
field was specified. -
#aspf ⇒ :r, :s
aspf
field. -
#aspf? ⇒ Boolean
Determines whether the
aspf=
field was specified. -
#fo ⇒ Array<'0', '1', 'd', 's'>
fo
field. -
#fo? ⇒ Boolean
Determines whether the
fo=
field was specified. -
#initialize(attributes = {}) ⇒ Record
constructor
Initializes the record.
-
#p? ⇒ Boolean
Determines if the
p=
field was specified?. -
#pct ⇒ Integer
pct
field. -
#pct? ⇒ Boolean
Determines whether the
pct=
field was specified. -
#rf ⇒ :afrf, :iodef
rf
field. -
#rf? ⇒ Boolean
Determines whether the
rf=
field was specified. -
#ri ⇒ Integer
ri
field. -
#ri? ⇒ Boolean
Determines whether the
ri=
field was specified. -
#rua? ⇒ Boolean
Determines if the
rua=
field was specified?. -
#ruf? ⇒ Boolean
Determines if the
ruf=
field was specified?. -
#sp? ⇒ Boolean
Determines if the
sp=
field was specified?. -
#to_h ⇒ Hash{Symbol => Object}
Converts the record to a Hash.
-
#to_s ⇒ String
Converts the record back to a DMARC String.
Constructor Details
#initialize(attributes = {}) ⇒ Record
Initializes the record.
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/dmarc/record.rb', line 63 def initialize(attributes={}) @v = attributes.fetch(:v) @adkim = attributes[:adkim] @aspf = attributes[:aspf] @fo = attributes[:fo] @p = attributes[:p] @pct = attributes[:pct] @rf = attributes[:rf] @ri = attributes[:ri] @rua = attributes[:rua] @ruf = attributes[:ruf] @sp = attributes[:sp] 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> (readonly)
rua
field.
18 19 20 |
# File 'lib/dmarc/record.rb', line 18 def rua @rua end |
#ruf ⇒ Array<Uri> (readonly)
rua
field.
23 24 25 |
# File 'lib/dmarc/record.rb', line 23 def ruf @ruf end |
#sp ⇒ :none, ... (readonly)
The 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
use parse instead.
282 283 284 |
# File 'lib/dmarc/record.rb', line 282 def self.from_txt(rec) parse(rec) end |
.parse(record) ⇒ Record
Parses a DMARC record.
273 274 275 276 277 |
# File 'lib/dmarc/record.rb', line 273 def self.parse(record) new(Parser.parse(record)) rescue Parslet::ParseFailed => error raise(InvalidRecord.new(error.,error.cause)) end |
Instance Method Details
#adkim ⇒ :r, :s
adkim=
field.
115 116 117 |
# File 'lib/dmarc/record.rb', line 115 def adkim @adkim || :r end |
#adkim? ⇒ Boolean
Determines whether the adkim=
field was specified.
105 106 107 |
# File 'lib/dmarc/record.rb', line 105 def adkim? !@adkim.nil? end |
#aspf ⇒ :r, :s
aspf
field.
136 137 138 |
# File 'lib/dmarc/record.rb', line 136 def aspf @aspf || :r end |
#aspf? ⇒ Boolean
Determines whether the aspf=
field was specified.
126 127 128 |
# File 'lib/dmarc/record.rb', line 126 def aspf? !@aspf.nil? end |
#fo ⇒ Array<'0', '1', 'd', 's'>
fo
field.
157 158 159 |
# File 'lib/dmarc/record.rb', line 157 def fo @fo || %w[0] end |
#fo? ⇒ Boolean
Determines whether the fo=
field was specified.
147 148 149 |
# File 'lib/dmarc/record.rb', line 147 def fo? !@fo.nil? end |
#p? ⇒ Boolean
Determines if the p=
field was specified?
168 169 170 |
# File 'lib/dmarc/record.rb', line 168 def p? !@p.nil? end |
#pct ⇒ Integer
pct
field.
189 190 191 |
# File 'lib/dmarc/record.rb', line 189 def pct @pct || 100 end |
#pct? ⇒ Boolean
Determines whether the pct=
field was specified.
179 180 181 |
# File 'lib/dmarc/record.rb', line 179 def pct? !@pct.nil? end |
#rf ⇒ :afrf, :iodef
rf
field.
210 211 212 |
# File 'lib/dmarc/record.rb', line 210 def rf @rf || :afrf end |
#rf? ⇒ Boolean
Determines whether the rf=
field was specified.
200 201 202 |
# File 'lib/dmarc/record.rb', line 200 def rf? !@rf.nil? end |
#ri ⇒ Integer
ri
field.
231 232 233 |
# File 'lib/dmarc/record.rb', line 231 def ri @ri || 86400 end |
#ri? ⇒ Boolean
Determines whether the ri=
field was specified.
221 222 223 |
# File 'lib/dmarc/record.rb', line 221 def ri? !@ri.nil? end |
#rua? ⇒ Boolean
Determines if the rua=
field was specified?
242 243 244 |
# File 'lib/dmarc/record.rb', line 242 def rua? !@rua.nil? end |
#ruf? ⇒ Boolean
Determines if the ruf=
field was specified?
253 254 255 |
# File 'lib/dmarc/record.rb', line 253 def ruf? !@ruf.nil? end |
#sp? ⇒ Boolean
Determines if the sp=
field was specified?
84 85 86 |
# File 'lib/dmarc/record.rb', line 84 def sp? !@sp.nil? end |
#to_h ⇒ Hash{Symbol => Object}
Converts the record to a Hash.
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'lib/dmarc/record.rb', line 319 def to_h hash = {} hash[:v] = @v if @v hash[:p] = @p if @p hash[:sp] = @sp if @sp hash[:rua] = @rua if @rua hash[:ruf] = @ruf if @ruf hash[:adkim] = @adkim if @adkim hash[:aspf] = @aspf if @aspf hash[:ri] = @ri if @ri hash[:fo] = @fo if @fo hash[:rf] = @rf if @rf hash[:pct] = @pct if @pct return hash end |
#to_s ⇒ String
Converts the record back to a DMARC String.
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
# File 'lib/dmarc/record.rb', line 342 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 |