Class: SPF::Record::V1

Inherits:
SPF::Record show all
Defined in:
lib/spf/model.rb

Constant Summary collapse

MECH_CLASSES =
{
  :all      => SPF::Mech::All,
  :ip4      => SPF::Mech::IP4,
  :ip6      => SPF::Mech::IP6,
  :a        => SPF::Mech::A,
  :mx       => SPF::Mech::MX,
  :ptr      => SPF::Mech::PTR,
  :exists   => SPF::Mech::Exists,
  :include  => SPF::Mech::Include
}
MOD_CLASSES =
{
  :redirect => SPF::Mod::Redirect,
  :exp      => SPF::Mod::Exp
}

Constants inherited from SPF::Record

DEFAULT_QUALIFIER, RESULTS_BY_QUALIFIER

Instance Attribute Summary

Attributes inherited from SPF::Record

#errors, #terms, #text

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SPF::Record

#eval, #global_mod, #global_mods, #ip_netblocks, new_from_string, #parse, #parse_term, #parse_version_tag, #to_s

Constructor Details

#initialize(options = {}) ⇒ V1



964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
# File 'lib/spf/model.rb', line 964

def initialize(options = {})
  super(options)

  @scopes ||= options[:scopes]
  if @scopes and scopes.any?
    unless @scopes.length > 0
      raise SPF::InvalidScopeError.new('No scopes for v=spf1 record')
    end
    if @scopes.length == 2
      unless (
          @scopes[0] == :helo  and @scopes[1] == :mfrom or
          @scopes[0] == :mfrom and @scopes[1] == :helo)
        raise SPF::InvalidScope.new(
          "Invalid set of scopes " + @scopes.map{|x| "'#{x}'"}.join(', ') + "for v=spf1 record")
      end
    end
  end
end

Class Method Details

.version_tagObject



952
953
954
# File 'lib/spf/model.rb', line 952

def self.version_tag
  'v=spf1'
end

Instance Method Details

#mech_classesObject



960
961
962
# File 'lib/spf/model.rb', line 960

def mech_classes
  MECH_CLASSES
end

#scopesObject



944
945
946
# File 'lib/spf/model.rb', line 944

def scopes
  [:helo, :mfrom]
end

#version_tagObject



948
949
950
# File 'lib/spf/model.rb', line 948

def version_tag
  'v=spf1'
end

#version_tag_patternObject



956
957
958
# File 'lib/spf/model.rb', line 956

def version_tag_pattern
  " v=spf(1) (?= \\x20+ | $ ) "
end