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

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

Constructor Details

#initialize(options = {}) ⇒ V1

Returns a new instance of V1.



1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
# File 'lib/spf/model.rb', line 1051

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



1039
1040
1041
# File 'lib/spf/model.rb', line 1039

def self.version_tag
  'v=spf1'
end

Instance Method Details

#mech_classesObject



1047
1048
1049
# File 'lib/spf/model.rb', line 1047

def mech_classes
  MECH_CLASSES
end

#scopesObject



1031
1032
1033
# File 'lib/spf/model.rb', line 1031

def scopes
  [:helo, :mfrom]
end

#version_tagObject



1035
1036
1037
# File 'lib/spf/model.rb', line 1035

def version_tag
  'v=spf1'
end

#version_tag_patternObject



1043
1044
1045
# File 'lib/spf/model.rb', line 1043

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