Class: PeerReview

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Class Method Details

.listObject

returns an instance of our custom public suffix list list behaves like PublicSuffix::List but is limited to our whitelisted domains

[View source]

10
11
12
# File 'lib/peer_review.rb', line 10

def list
  @list ||= PublicSuffix::List::parse(File.new(list_path, "r:utf-8"))
end

.list_pathObject

Returns the absolute path to the domain list

[View source]

15
16
17
# File 'lib/peer_review.rb', line 15

def list_path
  File.join(config_path,"domains.txt")
end

Instance Method Details

#valid?Boolean

Checks if the input string represents a research domain

Returns:

  • (Boolean)
[View source]

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