Initial commit
This commit is contained in:
parent
1ca43ad462
commit
c250d18182
1
.rbenv-version
Normal file
1
.rbenv-version
Normal file
@ -0,0 +1 @@
|
||||
1.9.2-p290
|
||||
8
Gemfile
8
Gemfile
@ -1,14 +1,10 @@
|
||||
source "http://rubygems.org"
|
||||
# Add dependencies required to use your gem here.
|
||||
# Example:
|
||||
# gem "activesupport", ">= 2.3.5"
|
||||
|
||||
# Add dependencies to develop your gem here.
|
||||
# Include everything needed to run rake, tests, features, etc.
|
||||
gem 'public_suffix'
|
||||
|
||||
group :development do
|
||||
gem "shoulda", ">= 0"
|
||||
gem "rdoc", "~> 3.12"
|
||||
gem "bundler", "~> 1.0.0"
|
||||
gem "jeweler", "~> 1.8.3"
|
||||
gem "rcov", ">= 0"
|
||||
end
|
||||
|
||||
25
Gemfile.lock
Normal file
25
Gemfile.lock
Normal file
@ -0,0 +1,25 @@
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
git (1.2.5)
|
||||
jeweler (1.8.3)
|
||||
bundler (~> 1.0)
|
||||
git (>= 1.2.5)
|
||||
rake
|
||||
rdoc
|
||||
json (1.6.5)
|
||||
public_suffix (1.0.0)
|
||||
rake (0.9.2.2)
|
||||
rdoc (3.12)
|
||||
json (~> 1.4)
|
||||
shoulda (2.11.3)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
bundler (~> 1.0.0)
|
||||
jeweler (~> 1.8.3)
|
||||
public_suffix
|
||||
rdoc (~> 3.12)
|
||||
shoulda
|
||||
@ -1,9 +1,11 @@
|
||||
= email
|
||||
|
||||
Description goes here.
|
||||
Helpers for email addresses.
|
||||
|
||||
* is this email address from an academic institution?
|
||||
|
||||
== Contributing to email
|
||||
|
||||
|
||||
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
||||
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
||||
* Fork the project.
|
||||
|
||||
12
Rakefile
12
Rakefile
@ -17,8 +17,8 @@ Jeweler::Tasks.new do |gem|
|
||||
gem.name = "email"
|
||||
gem.homepage = "http://github.com/leereilly/email"
|
||||
gem.license = "MIT"
|
||||
gem.summary = %Q{TODO: one-line summary of your gem}
|
||||
gem.description = %Q{TODO: longer description of your gem}
|
||||
gem.summary = %Q{email helpers}
|
||||
gem.description = %Q{email helpers}
|
||||
gem.email = "lee@leereilly.net"
|
||||
gem.authors = ["Lee Reilly"]
|
||||
# dependencies defined in Gemfile
|
||||
@ -32,14 +32,6 @@ Rake::TestTask.new(:test) do |test|
|
||||
test.verbose = true
|
||||
end
|
||||
|
||||
require 'rcov/rcovtask'
|
||||
Rcov::RcovTask.new do |test|
|
||||
test.libs << 'test'
|
||||
test.pattern = 'test/**/test_*.rb'
|
||||
test.verbose = true
|
||||
test.rcov_opts << '--exclude "gems/*"'
|
||||
end
|
||||
|
||||
task :default => :test
|
||||
|
||||
require 'rdoc/task'
|
||||
|
||||
22
lib/email.rb
22
lib/email.rb
@ -0,0 +1,22 @@
|
||||
require 'public_suffix'
|
||||
|
||||
module Email
|
||||
VERSION = "0.0.1"
|
||||
|
||||
ACADEMIC_TLDS = %w(edu ac.uk)
|
||||
ACADEMIC_DOMAINS = %w(ugr.es uottawa.ca)
|
||||
|
||||
class << self
|
||||
def academic?(email)
|
||||
domain = PublicSuffix.parse(email.split("@")[1])
|
||||
|
||||
if ACADEMIC_TLDS.include?(domain.tld)
|
||||
true
|
||||
elsif ACADEMIC_DOMAINS.include? (domain.domain)
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,7 +1,16 @@
|
||||
require 'helper'
|
||||
|
||||
class TestEmail < Test::Unit::TestCase
|
||||
should "probably rename this file and start testing for real" do
|
||||
flunk "hey buddy, you should probably rename this file and start testing for real"
|
||||
should "know what a valid educational institution email address is" do
|
||||
assert_equal Email::academic?('lreilly@stanford.edu'), true
|
||||
assert_equal Email::academic?('lreilly@slac.stanford.edu'), true
|
||||
assert_equal Email::academic?('lreilly@strath.ac.uk'), true
|
||||
assert_equal Email::academic?('lreilly@soft-eng.strath.ac.uk'), true
|
||||
assert_equal Email::academic?('lee@ugr.es'), true
|
||||
assert_equal Email::academic?('lee@uottawa.ca'), true
|
||||
assert_equal Email::academic?('lee@leerilly.net'), false
|
||||
assert_equal Email::academic?('lee@gmail.com'), false
|
||||
assert_equal Email::academic?('lee@stanford.edu.com'), false
|
||||
assert_equal Email::academic?('lee@strath.ac.uk.com'), false
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user