lib/spf/model.rb in spf-0.0.12 vs lib/spf/model.rb in spf-0.0.13

- old
+ new

@@ -258,11 +258,11 @@ def parse_name if @parse_text.sub!(/^ (#{NAME_PATTERN}) (?: : (?=.) )? /x, '') @name = $1 else - raise SPF::InvalidMech.new("Unexpected mechanism encountered in '#{@text}'") + raise SPF::InvalidMechError.new("Unexpected mechanism encountered in '#{@text}'") end end def parse_params(required = true) # Parse generic string of parameters text (should be overridden in sub-classes): @@ -831,17 +831,17 @@ term = nil if @parse_text.sub!(regex, '') and $& # Looks like a mechanism: mech_text = $1 mech_name = $2.downcase - mech_class = self.mech_classes[mech_name.to_sym] - unless mech_class - raise SPF::InvalidMech.new("Unknown mechanism type '#{mech_name}' in '#{@version_tag}' record") - end + mech_class = self.mech_classes[mech_name.to_sym] || SPF::Mech term = mech = mech_class.new_from_string(mech_text) @ip_netblocks << mech.ip_netblocks @terms << mech + if mech_class == SPF::Mech + raise SPF::InvalidMechError.new("Unknown mechanism type '#{mech_name}' in '#{@version_tag}' record") + end elsif ( @parse_text.sub!(/ ^ ( (#{SPF::Mod::NAME_PATTERN}) = @@ -851,10 +851,10 @@ /x, '') and $& ) # Looks like a modifier: mod_text = $1 mod_name = $2.downcase - mod_class = self.class::MOD_CLASSES[mod_name.to_sym] + mod_class = self.class::MOD_CLASSES[mod_name.to_sym] || SPF::Mod if mod_class # Known modifier. term = mod = mod_class.new_from_string(mod_text) if SPF::GlobalMod === mod # Global modifier.