spike out THE BLACKLIST

This commit is contained in:
Ben Balter 2013-12-06 13:12:19 -05:00
parent d6fff16968
commit f03894d2f2
5 changed files with 19 additions and 3 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
.DS_Store
Gemfile.lock
*.gem

1
.ruby-version Normal file
View File

@ -0,0 +1 @@
2.0.0

View File

@ -123,6 +123,13 @@ module Swot
'vic.edu.au' => 1,
}
# These are domains that snuck into the edu registry,
# but don't pass the education sniff test
# Note: domain must be a direct match
BLACKLIST = [
'si.edu',
]
class << self
# Figure out if an email or domain belongs to academic institution.
@ -135,7 +142,9 @@ module Swot
domain = get_domain(text)
return false if domain.nil?
if ACADEMIC_TLDS[domain.tld]
if BLACKLIST.include? domain.name
false
elsif ACADEMIC_TLDS[domain.tld]
true
elsif match_academic_domain?(domain)
true

View File

@ -18,7 +18,7 @@ Gem::Specification.new do |s|
]
s.files = [
".document",
".rbenv-version",
".ruby-version",
"CONTRIBUTING.md",
"Gemfile",
"LICENSE.txt",
@ -7725,4 +7725,3 @@ Gem::Specification.new do |s|
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
end
end

View File

@ -58,4 +58,10 @@ class TestEmail < Test::Unit::TestCase
assert_equal Swot::academic?('stanford.edu'), true
assert_equal Swot::school_name('lreilly@cs.strath.ac.uk'), "University of Strathclyde"
end
should "fail blacklisted domains" do
["si.edu", " si.edu ", "imposter@si.edu"].each do |domain|
assert_equal false, Swot::is_academic?(domain), "#{domain} should be denied"
end
end
end