Class: PeerReview
- Inherits:
-
Object
- Object
- PeerReview
- Includes:
- NaughtyOrNice
- Defined in:
- lib/peer_review.rb,
lib/peer_review/version.rb more...
Constant Summary collapse
- VERSION =
'1.0.0'
Class Method Summary collapse
-
.list ⇒ Object
returns an instance of our custom public suffix list list behaves like PublicSuffix::List but is limited to our whitelisted domains.
-
.list_path ⇒ Object
Returns the absolute path to the domain list.
Instance Method Summary collapse
-
#valid? ⇒ Boolean
Checks if the input string represents a research domain.
Class Method Details
permalink .list ⇒ Object
returns an instance of our custom public suffix list list behaves like PublicSuffix::List but is limited to our whitelisted domains
10 11 12 |
# File 'lib/peer_review.rb', line 10 def list @list ||= PublicSuffix::List::parse(File.new(list_path, "r:utf-8")) end |
permalink .list_path ⇒ Object
Returns the absolute path to the domain list
15 16 17 |
# File 'lib/peer_review.rb', line 15 def list_path File.join(config_path,"domains.txt") end |
Instance Method Details
permalink #valid? ⇒ Boolean
Checks if the input string represents a research domain
31 32 33 34 35 36 37 38 39 40 41 42 |
# 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 |