class PeerReview
Constants
- VERSION
Public Class Methods
list()
click to toggle source
returns an instance of our custom public suffix list list behaves like PublicSuffix::List but is limited to our whitelisted domains
# File lib/peer_review.rb, line 10 def list @list ||= PublicSuffix::List::parse(File.new(list_path, "r:utf-8")) end
list_path()
click to toggle source
Returns the absolute path to the domain list
# File lib/peer_review.rb, line 15 def list_path File.join(config_path,"domains.txt") end
Private Class Methods
config_path()
click to toggle source
# File lib/peer_review.rb, line 21 def config_path File.join(File.dirname(__FILE__), "../config") end
list_contents()
click to toggle source
# File lib/peer_review.rb, line 25 def list_contents @list_contents ||= File.new(list_path, "r:utf-8").read end
Public Instance Methods
valid?()
click to toggle source
Checks if the input string represents a research domain
# File lib/peer_review.rb, line 31 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