Class: SPF::Record::V2
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
}
- VALID_SCOPE =
/^(?: mfrom | pra )$/x
Constants inherited
from SPF::Record
DEFAULT_QUALIFIER, RESULTS_BY_QUALIFIER
Instance Attribute Summary
Attributes inherited from SPF::Record
#errors, #terms, #text
Instance Method Summary
collapse
Methods inherited from SPF::Record
#error, #eval, #global_mod, #global_mods, #ip_netblocks, new_from_string, #parse, #parse_term, #to_s
Constructor Details
#initialize(options = {}) ⇒ V2
Returns a new instance of V2.
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
|
# File 'lib/spf/model.rb', line 1111
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
|
Instance Method Details
#mech_classes ⇒ Object
1107
1108
1109
|
# File 'lib/spf/model.rb', line 1107
def mech_classes
MECH_CLASSES
end
|
#parse_version_tag ⇒ Object
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
|
# File 'lib/spf/model.rb', line 1129
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 ⇒ Object
1094
1095
1096
|
# File 'lib/spf/model.rb', line 1094
def scopes
[:mfrom, :pra]
end
|
#version_tag ⇒ Object
1090
1091
1092
|
# File 'lib/spf/model.rb', line 1090
def version_tag
'v=spf2.0'
end
|
#version_tag_pattern ⇒ Object
1098
1099
1100
1101
1102
1103
1104
1105
|
# File 'lib/spf/model.rb', line 1098
def version_tag_pattern
"
spf(2\.0)
\/
( (?: mfrom | pra ) (?: , (?: mfrom | pra ) )* )
(?= \\x20 | $ )
"
end
|