From f99097d7284aaf167b78db85486135761d51f7ee Mon Sep 17 00:00:00 2001 From: Lee Reilly Date: Sat, 4 Feb 2012 15:02:11 -0800 Subject: [PATCH] Train-driven development :train: --- README.rdoc | 29 +++++++++++++++++++---------- test/test_email.rb | 29 ++++++++++++++++------------- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/README.rdoc b/README.rdoc index a520919b75..c37b99e3ab 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,17 +1,21 @@ Swot allows you to figure out whether a particular email address or domain is associated with an academic institution providing higher education in -tertiary, quaternary and post-secondary education. +tertiary, quaternary or post-secondary education in any country in the +world. -== Email addresses belonging to academic institutions +**What is a swot?** [UrbanDictionary will fill you in](http://www.urbandictionary.com/define.php?term=swot) ಠ_ಠ - Swot::academic?('lreilly@stanford.edu') # true - Swot::academic?('lreilly@slac.stanford.edu') # true - Swot::academic?('lreilly@strath.ac.uk') # true - Swot::academic?('lreilly@soft-eng.strath.ac.uk') # true - Swot::academic?('lee@ugr.es') # true - Swot::academic?('lee@uottawa.ca') # true +== Usage -== Email addresses not belonging to academic institutions + Swot::academic?('lreilly@stanford.edu') # true + Swot::academic?('lreilly@slac.stanford.edu') # true + Swot::academic?('lreilly@strath.ac.uk') # true + Swot::academic?('lreilly@soft-eng.strath.ac.uk') # true + Swot::academic?('lee@ugr.es') # true + Swot::academic?('lee@uottawa.ca') # true + Swot::academic?('harvard.edu') # true + Swot::academic?('www.harvard.edu') # true + Swot::academic?('http://www.harvard.edu') # true Swot::academic?('lee@leerilly.net') # false Swot::academic?('lee@gmail.com') # false @@ -30,7 +34,12 @@ tertiary, quaternary and post-secondary education. * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally. * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it. -== Known Issues / Bugs +== Known Issues / + +* You can search by email and domain names only. You cannot search by IP. +* Can't handle port numbers yet. + +![](https://a248.e.akamai.net/assets.github.com/img/e3700efc05ca611162b365367aadc8b112b4969d/687474703a2f2f692e696d6775722e636f6d2f4b387673772e676966) == Copyright diff --git a/test/test_email.rb b/test/test_email.rb index 69e602512e..b8d3279ff7 100644 --- a/test/test_email.rb +++ b/test/test_email.rb @@ -1,7 +1,7 @@ require 'helper' class TestEmail < Test::Unit::TestCase - should "know what a valid acadmic institution email address or domain is" do + should "work with all the things" do assert_equal Swot::is_academic?('lreilly@stanford.edu'), true assert_equal Swot::is_academic?('lreilly@slac.stanford.edu'), true assert_equal Swot::is_academic?('lreilly@strath.ac.uk'), true @@ -16,19 +16,22 @@ class TestEmail < Test::Unit::TestCase assert_equal Swot::is_academic?('lee@stanford.edu.com'), false assert_equal Swot::is_academic?('lee@strath.ac.uk.com'), false - assert_equal Swot::is_academic?('stanford.edu'), true - assert_equal Swot::is_academic?('slac.stanford.edu'), true - assert_equal Swot::is_academic?('strath.ac.uk'), true - assert_equal Swot::is_academic?('soft-eng.strath.ac.uk'), true - assert_equal Swot::is_academic?('ugr.es'), true - assert_equal Swot::is_academic?('uottawa.ca'), true - assert_equal Swot::is_academic?('mother.edu.ru'), true - assert_equal Swot::is_academic?('ucy.ac.cy'), true + assert_equal Swot::is_academic?('stanford.edu'), true + assert_equal Swot::is_academic?('slac.stanford.edu'), true + assert_equal Swot::is_academic?('www.stanford.edu'), true + assert_equal Swot::is_academic?('http://www.stanford.edu'), true + #assert_equal Swot::is_academic?('http://www.stanford.edu:9393'), true + assert_equal Swot::is_academic?('strath.ac.uk'), true + assert_equal Swot::is_academic?('soft-eng.strath.ac.uk'), true + assert_equal Swot::is_academic?('ugr.es'), true + assert_equal Swot::is_academic?('uottawa.ca'), true + assert_equal Swot::is_academic?('mother.edu.ru'), true + assert_equal Swot::is_academic?('ucy.ac.cy'), true - assert_equal Swot::is_academic?('leerilly.net'), false - assert_equal Swot::is_academic?('gmail.com'), false - assert_equal Swot::is_academic?('stanford.edu.com'), false - assert_equal Swot::is_academic?('strath.ac.uk.com'), false + assert_equal Swot::is_academic?('leerilly.net'), false + assert_equal Swot::is_academic?('gmail.com'), false + assert_equal Swot::is_academic?('stanford.edu.com'), false + assert_equal Swot::is_academic?('strath.ac.uk.com'), false end end