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.



1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
# File 'lib/spf/model.rb', line 1005

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



993
994
995
# File 'lib/spf/model.rb', line 993

def self.version_tag
  'v=spf1'
end

Instance Method Details

#mech_classesObject



1001
1002
1003
# File 'lib/spf/model.rb', line 1001

def mech_classes
  MECH_CLASSES
end

#scopesObject



985
986
987
# File 'lib/spf/model.rb', line 985

def scopes
  [:helo, :mfrom]
end

#version_tagObject



989
990
991
# File 'lib/spf/model.rb', line 989

def version_tag
  'v=spf1'
end

#version_tag_patternObject



997
998
999
# File 'lib/spf/model.rb', line 997

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