lib/myna_bird.rb in myna_bird-0.1.0 vs lib/myna_bird.rb in myna_bird-0.2.0
- old
+ new
@@ -1,28 +1,35 @@
class MynaBird
+ class MalformedEmailException < Exception
+ end
+
COMMON_LOCALS = %w(
support info sales marketing admin webmaster help
)
COMMON_DOMAINS = %w(
hotmail msn live yahoo yahoo.co.uk ymail rocketmail gmail googlemail aol
fastmail.fm web mail.ru rediff indiatimes lycos libero.it rambler.ru mac
paracalls linkedin mynet interia.pl yandex.ru sina 126 lycos bol in me
voila.fr mail comcast netcom roadrunner verizon 1and1 att adelphia
bigpond bluebottle blueyonder btopenworld charter cox earthlink sbc telus
- mailinator charter rogers sympatico tiscali
+ mailinator charter rogers sympatico tiscali tmail
) + [
/\.edu$/
]
def self.convert(email)
new(email).name
end
def initialize(email)
+ # email must be in a somewhat sane format
+ # i.e. have an @ sign and at least one letter or number on each side of it
+ raise MalformedEmailException unless email =~ /^[^@]*[a-z0-9][^@]*@[^@]*[a-z0-9][^@]*$/i
+
@email = email.downcase
- @local, @domain = @email.split('@')
+ @local, @domain = @email.split('@')
end
# extract the name
def name
\ No newline at end of file