lib/gman/identifier.rb in gman-7.0.5 vs lib/gman/identifier.rb in gman-7.0.6

- old
+ new

@@ -24,11 +24,11 @@ end def_hash_delegator :dotgov_listing, :Agency def_hash_delegator :dotgov_listing, :Organization def_hash_delegator :dotgov_listing, :City - def_hash_delegator :dotgov_listing, :"Domain Type" + def_hash_delegator :dotgov_listing, :'Domain Type' private :domain_type def type %i[state district cog city federal county].each do |type| return type if send "#{type}?" @@ -58,11 +58,11 @@ end def federal? return false unless dotgov_listing - domain_type =~ /^Federal Agency/i + domain_type =~ /^Federal/i end def city? if matches %w[ci town vil].include?(matches[3]) @@ -85,11 +85,11 @@ def state? if matches matches[1] == 'state' elsif dotgov_listing - domain_type == 'State/Local Govt' + domain_type == 'State/Local Govt' || domain_type == 'State' else false end end @@ -106,17 +106,17 @@ end private def list_category - @list_category ||= begin - match = Gman.list.public_suffix_list.find(domain.to_s) - return unless match + return @list_category if defined?(@list_category) - regex = %r{// ([^\n]+)\n?[^/]*\n#{Regexp.escape(match.value)}\n}im - matches = Gman.list.contents.match(regex) - matches[1] if matches - end + match = Gman.list.public_suffix_list.find(domain.to_s) + return @list_category = nil unless match + + regex = %r{// ([^\n]+)\n?[^/]*\n#{Regexp.escape(match.value)}\n}im + matches = Gman.list.contents.match(regex) + @list_category = matches ? matches[1] : nil end def matches return @matches if defined? @matches