class SPF::Record::SPF::Record::V2

Constants

MECH_CLASSES
MOD_CLASSES
VALID_SCOPE

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method
# File lib/spf/model.rb, line 1123
def initialize(options = {})
  super(options)
  unless @parse_text
    scopes = @scopes || {}
    raise SPF::InvalidScopeError.new('No scopes for spf2.0 record') if scopes.empty?
    scopes.each do |scope|
      if scope !~ VALID_SCOPE
        raise SPF::InvalidScopeError.new("Invalid scope '#{scope}' for spf2.0 record")
      end
    end
  end
end

Public Instance Methods

mech_classes() click to toggle source
# File lib/spf/model.rb, line 1119
def mech_classes
  MECH_CLASSES
end
parse_version_tag() click to toggle source
# File lib/spf/model.rb, line 1141
def parse_version_tag

  @parse_text.sub!(/#{version_tag_pattern}(?:\x20+|$)/ix, '')
  if $1
    scopes = @scopes = "#{$2}".split(/,/)
    if scopes.empty?
      raise SPF::InvalidScopeError.new('No scopes for spf2.0 record')
    end
    scopes.each do |scope|
      if scope !~ VALID_SCOPE
        raise SPF::InvalidScopeError.new("Invalid scope '#{scope}' for spf2.0 record")
      end
    end
  else
    raise SPF::InvalidRecordVersionError.new(
      "Not a 'spf2.0' record: '#{@text}'")
  end
end
scopes() click to toggle source
# File lib/spf/model.rb, line 1106
def scopes
  [:mfrom, :pra]
end
version_tag() click to toggle source
# File lib/spf/model.rb, line 1102
def version_tag
  'v=spf2.0'
end
version_tag_pattern() click to toggle source
# File lib/spf/model.rb, line 1110
def version_tag_pattern
"
  spf(2\.0)
  \/
  ( (?: mfrom | pra ) (?: , (?: mfrom | pra ) )* )
  (?= \\x20 | $ )
"
end