Sha256: b3be0336d38788f87d391b0b54f6b1faf31988e0696afb65c2484a2738935ee1
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
require 'naughty_or_nice' class PeerReview include NaughtyOrNice class << self # returns an instance of our custom public suffix list # list behaves like PublicSuffix::List but is limited to our whitelisted domains def list @list ||= PublicSuffix::List::parse(File.new(list_path, "r:utf-8")) end # Returns the absolute path to the domain list def list_path File.join(config_path,"domains.txt") end private def config_path File.join(File.dirname(__FILE__), "../config") end def list_contents @list_contents ||= File.new(list_path, "r:utf-8").read end end # Checks if the input string represents a research domain def valid? # Ensure it's a valid domain return false unless domain && domain.valid? # check using public suffix's standard logic rule = PeerReview.list.find(to_s) # domain is on the domain list and # domain is not explicitly blacklisted and # domain matches a standard public suffix list rule !rule.nil? && rule.type != :exception && rule.allow?(".#{domain}") end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
peer_review-1.0.0 | lib/peer_review.rb |