Skip to content

Commit

Permalink
Merge pull request JetBrains#39 from benbalter/edu-rejects
Browse files Browse the repository at this point in the history
THE BLACKLIST
  • Loading branch information
leereilly committed Feb 27, 2014
2 parents fc198b8 + 3dc4c96 commit d6689b2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
Gemfile.lock
*.gem
1 change: 0 additions & 1 deletion .rbenv-version

This file was deleted.

1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.0.0
11 changes: 10 additions & 1 deletion lib/swot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -135,7 +142,9 @@ def is_academic?(text)
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
Expand Down
3 changes: 1 addition & 2 deletions swot.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |s|
]
s.files = [
".document",
".rbenv-version",
".ruby-version",
"CONTRIBUTING.md",
"Gemfile",
"LICENSE.txt",
Expand Down Expand Up @@ -7725,4 +7725,3 @@ Gem::Specification.new do |s|
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
end
end

6 changes: 6 additions & 0 deletions test/test_swot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,10 @@ class TestEmail < Test::Unit::TestCase
assert_equal Swot::academic?('stanford.edu'), true
assert_equal Swot::school_name('[email protected]'), "University of Strathclyde"
end

should "fail blacklisted domains" do
["si.edu", " si.edu ", "[email protected]"].each do |domain|
assert_equal false, Swot::is_academic?(domain), "#{domain} should be denied"
end
end
end

0 comments on commit d6689b2

Please sign in to comment.