myna_bird 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/lib/myna_bird.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  class MynaBird
2
2
 
3
+ class MalformedEmailException < Exception
4
+ end
5
+
3
6
  COMMON_LOCALS = %w(
4
7
  support info sales marketing admin webmaster help
5
8
  )
@@ -10,7 +13,7 @@ class MynaBird
10
13
  paracalls linkedin mynet interia.pl yandex.ru sina 126 lycos bol in me
11
14
  voila.fr mail comcast netcom roadrunner verizon 1and1 att adelphia
12
15
  bigpond bluebottle blueyonder btopenworld charter cox earthlink sbc telus
13
- mailinator charter rogers sympatico tiscali
16
+ mailinator charter rogers sympatico tiscali tmail
14
17
  ) + [
15
18
  /\.edu$/
16
19
  ]
@@ -20,8 +23,12 @@ class MynaBird
20
23
  end
21
24
 
22
25
  def initialize(email)
26
+ # email must be in a somewhat sane format
27
+ # i.e. have an @ sign and at least one letter or number on each side of it
28
+ raise MalformedEmailException unless email =~ /^[^@]*[a-z0-9][^@]*@[^@]*[a-z0-9][^@]*$/i
29
+
23
30
  @email = email.downcase
24
- @local, @domain = @email.split('@')
31
+ @local, @domain = @email.split('@')
25
32
  end
26
33
 
27
34
 
data/myna_bird.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{myna_bird}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brendan Schwartz"]
12
- s.date = %q{2010-10-21}
12
+ s.date = %q{2010-11-07}
13
13
  s.description = %q{Given an email address, MynaBird generates a name suitable for use in a host name}
14
14
  s.email = %q{bschwartz@wistia.com}
15
15
  s.extra_rdoc_files = [
@@ -1,16 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- module ShouldConvert
4
- def it_should_convert(from, to_hash)
5
- to = to_hash[:to]
6
- it "should convert '#{from}' to '#{to}'" do
7
- MynaBird.convert(from) == to
8
- end
9
- end
10
- end
11
-
12
3
  describe MynaBird do
13
- extend ShouldConvert
14
4
 
15
5
  it_should_convert 'brendan@wistia.com', :to => 'wistia'
16
6
  it_should_convert 'brendan.schwartz@gmail.com', :to => 'brendan-schwartz'
@@ -25,5 +15,13 @@ describe MynaBird do
25
15
  it_should_convert 'brendan+nospam@aol.com', :to => 'brendan'
26
16
  it_should_convert 'BRENDAN@aol.com', :to => 'brendan'
27
17
  it_should_convert 'brendan@WISTIA.COM', :to => 'wistia'
18
+ it_should_convert 'BRENDAN@WISTIA', :to => 'wistia'
19
+
20
+ # bad input
21
+ it_should_not_convert 'no.at.sign'
22
+ it_should_not_convert '@domain.only'
23
+ it_should_not_convert 'local.only@'
24
+ it_should_not_convert '@@@@'
25
+ it_should_not_convert '++@++'
28
26
 
29
27
  end
data/spec/spec_helper.rb CHANGED
@@ -4,6 +4,23 @@ require 'myna_bird'
4
4
  require 'spec'
5
5
  require 'spec/autorun'
6
6
 
7
- Spec::Runner.configure do |config|
7
+ module ShouldAndShouldNotConvert
8
+ def it_should_convert(from, to_hash)
9
+ to = to_hash[:to]
10
+ it "should convert '#{from}' to '#{to}'" do
11
+ MynaBird.convert(from) == to
12
+ end
13
+ end
8
14
 
15
+ def it_should_not_convert(from)
16
+ it "should raise MalformedEmailException when attempting to convert '#{from}'" do
17
+ lambda {
18
+ MynaBird.convert(from)
19
+ }.should raise_error(MynaBird::MalformedEmailException)
20
+ end
21
+ end
22
+ end
23
+
24
+ Spec::Runner.configure do |config|
25
+ config.extend(ShouldAndShouldNotConvert)
9
26
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myna_bird
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brendan Schwartz
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-21 00:00:00 -04:00
18
+ date: 2010-11-07 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency