fone 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +27 -0
- data/Rakefile +2 -0
- data/fone.gemspec +19 -0
- data/lib/fone.rb +6 -0
- data/lib/fone/area_code.rb +32 -0
- data/lib/fone/version.rb +3 -0
- data/spec/fone/area_code_spec.rb +43 -0
- data/spec/spec_helper.rb +7 -0
- metadata +70 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Austin Schneider
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Fone
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
gem 'fone'
|
8
|
+
|
9
|
+
And then execute:
|
10
|
+
|
11
|
+
$ bundle
|
12
|
+
|
13
|
+
Or install it yourself as:
|
14
|
+
|
15
|
+
$ gem install fone
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
## Contributing
|
22
|
+
|
23
|
+
1. Fork it
|
24
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
25
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
26
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
27
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/fone.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/fone/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.authors = ["Austin Schneider"]
|
6
|
+
spec.email = ["austinthecoder@gmail.com"]
|
7
|
+
spec.description = "Various phone number related methods and info"
|
8
|
+
spec.summary = "Various phone number related methods and info"
|
9
|
+
spec.homepage = "https://github.com/austinthecoder/fone"
|
10
|
+
|
11
|
+
spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
spec.files = `git ls-files`.split("\n")
|
13
|
+
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
spec.name = "fone"
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
spec.version = Fone::VERSION
|
17
|
+
|
18
|
+
spec.add_development_dependency "rspec", ">= 2.8.0"
|
19
|
+
end
|
data/lib/fone.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
module Fone
|
2
|
+
class AreaCode
|
3
|
+
|
4
|
+
DATA = [[201, "NJ"], [203, "CT"], [205, "AL"], [207, "ME"], [209, "CA"], [212, "NY"], [214, "TX"], [216, "OH"], [218, "MN"], [224, "IL"], [226, "ON"], [229, "GA"], [234, "OH"], [239, "FL"], [248, "MI"], [251, "AL"], [253, "WA"], [256, "AL"], [262, "WI"], [269, "MI"], [276, "VA"], [281, "TX"], [289, "ON"], [302, "DE"], [304, "WV"], [306, "SK"], [308, "NE"], [310, "CA"], [313, "MI"], [315, "NY"], [317, "IN"], [319, "IA"], [321, "FL"], [325, "TX"], [331, "IL"], [336, "NC"], [339, "MA"], [341, "CA"], [351, "MA"], [360, "WA"], [369, "CA"], [385, "UT"], [401, "RI"], [403, "AB"], [405, "OK"], [407, "FL"], [409, "TX"], [412, "PA"], [414, "WI"], [416, "ON"], [418, "QC"], [423, "TN"], [425, "WA"], [432, "TX"], [435, "UT"], [440, "OH"], [443, "MD"], [464, "IL"], [470, "GA"], [478, "GA"], [480, "AZ"], [501, "AR"], [503, "OR"], [505, "NM"], [507, "MN"], [509, "WA"], [512, "TX"], [514, "QC"], [516, "NY"], [518, "NY"], [520, "AZ"], [540, "VA"], [551, "NJ"], [559, "CA"], [562, "CA"], [564, "WA"], [570, "PA"], [573, "MO"], [575, "NM"], [585, "NY"], [601, "MS"], [603, "NH"], [605, "SD"], [607, "NY"], [609, "NJ"], [612, "MN"], [614, "OH"], [616, "MI"], [618, "IL"], [620, "KS"], [626, "CA"], [628, "CA"], [631, "NY"], [641, "IA"], [647, "ON"], [651, "MN"], [661, "CA"], [669, "CA"], [671, "GU"], [679, "MI"], [689, "FL"], [702, "NV"], [704, "NC"], [706, "GA"], [708, "IL"], [712, "IA"], [714, "CA"], [716, "NY"], [718, "NY"], [720, "CO"], [727, "FL"], [732, "NJ"], [737, "TX"], [747, "CA"], [757, "VA"], [762, "GA"], [764, "CA"], [769, "MS"], [772, "FL"], [774, "MA"], [778, "BC"], [780, "AB"], [785, "KS"], [787, "PR"], [802, "VT"], [804, "VA"], [806, "TX"], [808, "HI"], [812, "IN"], [814, "PA"], [816, "MO"], [818, "CA"], [828, "NC"], [831, "CA"], [835, "PA"], [845, "NY"], [848, "NJ"], [856, "NJ"], [858, "CA"], [860, "CT"], [863, "FL"], [865, "TN"], [870, "AR"], [878, "PA"], [902, "NS"], [904, "FL"], [906, "MI"], [908, "NJ"], [910, "NC"], [913, "KS"], [915, "TX"], [917, "NY"], [919, "NC"], [925, "CA"], [928, "AZ"], [935, "CA"], [937, "OH"], [940, "TX"], [947, "MI"], [951, "CA"], [954, "FL"], [957, "NM"], [970, "CO"], [972, "TX"], [975, "MO"], [979, "TX"], [984, "NC"], [989, "MI"]]
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def [](area_code)
|
8
|
+
if datum = DATA.detect { |a, s| a == area_code.to_i }
|
9
|
+
new *datum
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private :new
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(area_code, state_abbreviation)
|
17
|
+
@to_i = area_code.to_i
|
18
|
+
@state_abbreviation = state_abbreviation
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_reader :to_i, :state_abbreviation
|
22
|
+
|
23
|
+
def to_s
|
24
|
+
to_i.to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
def ==(other)
|
28
|
+
other.is_a?(AreaCode) && other.to_i == to_i
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
data/lib/fone/version.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
AREA_CODES_STATES = [[201, "NJ"], [203, "CT"], [205, "AL"], [207, "ME"], [209, "CA"], [212, "NY"], [214, "TX"], [216, "OH"], [218, "MN"], [224, "IL"], [226, "ON"], [229, "GA"], [234, "OH"], [239, "FL"], [248, "MI"], [251, "AL"], [253, "WA"], [256, "AL"], [262, "WI"], [269, "MI"], [276, "VA"], [281, "TX"], [289, "ON"], [302, "DE"], [304, "WV"], [306, "SK"], [308, "NE"], [310, "CA"], [313, "MI"], [315, "NY"], [317, "IN"], [319, "IA"], [321, "FL"], [325, "TX"], [331, "IL"], [336, "NC"], [339, "MA"], [341, "CA"], [351, "MA"], [360, "WA"], [369, "CA"], [385, "UT"], [401, "RI"], [403, "AB"], [405, "OK"], [407, "FL"], [409, "TX"], [412, "PA"], [414, "WI"], [416, "ON"], [418, "QC"], [423, "TN"], [425, "WA"], [432, "TX"], [435, "UT"], [440, "OH"], [443, "MD"], [464, "IL"], [470, "GA"], [478, "GA"], [480, "AZ"], [501, "AR"], [503, "OR"], [505, "NM"], [507, "MN"], [509, "WA"], [512, "TX"], [514, "QC"], [516, "NY"], [518, "NY"], [520, "AZ"], [540, "VA"], [551, "NJ"], [559, "CA"], [562, "CA"], [564, "WA"], [570, "PA"], [573, "MO"], [575, "NM"], [585, "NY"], [601, "MS"], [603, "NH"], [605, "SD"], [607, "NY"], [609, "NJ"], [612, "MN"], [614, "OH"], [616, "MI"], [618, "IL"], [620, "KS"], [626, "CA"], [628, "CA"], [631, "NY"], [641, "IA"], [647, "ON"], [651, "MN"], [661, "CA"], [669, "CA"], [671, "GU"], [679, "MI"], [689, "FL"], [702, "NV"], [704, "NC"], [706, "GA"], [708, "IL"], [712, "IA"], [714, "CA"], [716, "NY"], [718, "NY"], [720, "CO"], [727, "FL"], [732, "NJ"], [737, "TX"], [747, "CA"], [757, "VA"], [762, "GA"], [764, "CA"], [769, "MS"], [772, "FL"], [774, "MA"], [778, "BC"], [780, "AB"], [785, "KS"], [787, "PR"], [802, "VT"], [804, "VA"], [806, "TX"], [808, "HI"], [812, "IN"], [814, "PA"], [816, "MO"], [818, "CA"], [828, "NC"], [831, "CA"], [835, "PA"], [845, "NY"], [848, "NJ"], [856, "NJ"], [858, "CA"], [860, "CT"], [863, "FL"], [865, "TN"], [870, "AR"], [878, "PA"], [902, "NS"], [904, "FL"], [906, "MI"], [908, "NJ"], [910, "NC"], [913, "KS"], [915, "TX"], [917, "NY"], [919, "NC"], [925, "CA"], [928, "AZ"], [935, "CA"], [937, "OH"], [940, "TX"], [947, "MI"], [951, "CA"], [954, "FL"], [957, "NM"], [970, "CO"], [972, "TX"], [975, "MO"], [979, "TX"], [984, "NC"], [989, "MI"]]
|
4
|
+
|
5
|
+
describe Fone::AreaCode do
|
6
|
+
describe "class methods" do
|
7
|
+
subject { described_class }
|
8
|
+
|
9
|
+
describe "[]" do
|
10
|
+
AREA_CODES_STATES.map { |a, s| a }.each do |arg|
|
11
|
+
context "with #{arg.inspect}" do
|
12
|
+
it { subject[arg].should be_a(Fone::AreaCode) }
|
13
|
+
it { subject[arg].to_i.should == arg }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
AREA_CODES_STATES.map { |a, s| a.to_s }.each do |arg|
|
18
|
+
context "with #{arg.inspect}" do
|
19
|
+
it { subject[arg].should == subject[arg.to_i] }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "with an unknown area code"
|
24
|
+
it { subject[9999].should be_nil }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "instance methods" do
|
29
|
+
subject { described_class[@area_code] }
|
30
|
+
|
31
|
+
before { @area_code = 201 }
|
32
|
+
|
33
|
+
its(:to_i) { should == 201 }
|
34
|
+
its(:to_s) { should == "201" }
|
35
|
+
|
36
|
+
AREA_CODES_STATES.each do |area_code, state_abbreviation|
|
37
|
+
context "with #{area_code.inspect}" do
|
38
|
+
before { @area_code = area_code }
|
39
|
+
its(:state_abbreviation) { should == state_abbreviation }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fone
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Austin Schneider
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70138135772720 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.8.0
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70138135772720
|
25
|
+
description: Various phone number related methods and info
|
26
|
+
email:
|
27
|
+
- austinthecoder@gmail.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- .rspec
|
34
|
+
- Gemfile
|
35
|
+
- LICENSE
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- fone.gemspec
|
39
|
+
- lib/fone.rb
|
40
|
+
- lib/fone/area_code.rb
|
41
|
+
- lib/fone/version.rb
|
42
|
+
- spec/fone/area_code_spec.rb
|
43
|
+
- spec/spec_helper.rb
|
44
|
+
homepage: https://github.com/austinthecoder/fone
|
45
|
+
licenses: []
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 1.8.10
|
65
|
+
signing_key:
|
66
|
+
specification_version: 3
|
67
|
+
summary: Various phone number related methods and info
|
68
|
+
test_files:
|
69
|
+
- spec/fone/area_code_spec.rb
|
70
|
+
- spec/spec_helper.rb
|