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.
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
|
# 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
|
Instance Method Details
#mech_classes ⇒ Object
1119
1120
1121
|
# File 'lib/spf/model.rb', line 1119
def mech_classes
MECH_CLASSES
end
|
#parse_version_tag ⇒ Object
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
|
# 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 ⇒ Object
1106
1107
1108
|
# File 'lib/spf/model.rb', line 1106
def scopes
[:mfrom, :pra]
end
|
#version_tag ⇒ Object
1102
1103
1104
|
# File 'lib/spf/model.rb', line 1102
def version_tag
'v=spf2.0'
end
|
#version_tag_pattern ⇒ Object
1110
1111
1112
1113
1114
1115
1116
1117
|
# File 'lib/spf/model.rb', line 1110
def version_tag_pattern
"
spf(2\.0)
\/
( (?: mfrom | pra ) (?: , (?: mfrom | pra ) )* )
(?= \\x20 | $ )
"
end
|