class Coppertone::DomainSpec
A domain spec, as defined in the SPF specification.
Constants
- EXP_ONLY_MACRO_LETTERS
Public Class Methods
new(s)
click to toggle source
Calls superclass method
# File lib/coppertone/domain_spec.rb, line 7 def initialize(s) begin super rescue Coppertone::MacroStringParsingError raise Coppertone::DomainSpecParsingError end validate_domain_spec_restrictions end
Public Instance Methods
ends_in_allowed_term?()
click to toggle source
# File lib/coppertone/domain_spec.rb, line 28 def ends_in_allowed_term? lm = @macros.last return true unless lm return false if lm.is_a?(Coppertone::MacroString::MacroStaticExpand) return true if lm.is_a?(Coppertone::MacroString::MacroExpand) ends_with_top_label? end
ends_with_top_label?()
click to toggle source
# File lib/coppertone/domain_spec.rb, line 37 def ends_with_top_label? ends_with = @macros.last.to_s ends_with = ends_with[0..-2] if ends_with[-1] == '.' _, match, tail = ends_with.rpartition('.') return false if match.blank? hostname = Coppertone::Utils::DomainUtils.valid_tld?(tail) return false unless hostname true end
only_allowed_macros?()
click to toggle source
# File lib/coppertone/domain_spec.rb, line 23 def only_allowed_macros? @macros.select { |m| m.is_a?(Coppertone::MacroString::MacroExpand) } .none? { |m| EXP_ONLY_MACRO_LETTERS.include?(m.macro_letter) } end
validate_domain_spec_restrictions()
click to toggle source
# File lib/coppertone/domain_spec.rb, line 16 def validate_domain_spec_restrictions return if only_allowed_macros? && ends_in_allowed_term? raise Coppertone::DomainSpecParsingError end