area_code_validator 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +10 -1
- data/lib/area_code_validator/version.rb +1 -1
- data/lib/area_code_validator.rb +5 -0
- data/test/test_area_code_validator.rb +20 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e9b9fd948d5048afec0f3eadf2024bbe38717aa
|
4
|
+
data.tar.gz: dd5c8bb29ec75407c01b1a03d02dde911d8bfd22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edc689205a0d6e6e401a376fcad4f18566b09508ffe048fb687277027875100bf92f9181fc666d5cebb166e7651e01a78c18f7c3a33b539a1be75ccb186a4163
|
7
|
+
data.tar.gz: 4fa5364406dbd30fa9cb6c7302b7f85cd16cd14e4a259ab1d06f8cafc1cfcf1e1859117878be04e57731317cde9ed1b53f56ebe370257864e24f8af86e67cbaf
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
Area Code Validator is a small gem that validates a phone numbers area code to a state.
|
4
4
|
|
5
|
+
Supports valid method from version >= 0.0.3
|
6
|
+
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
Add this line to your application's Gemfile:
|
@@ -18,11 +20,14 @@ Or install it yourself as:
|
|
18
20
|
|
19
21
|
## Usage
|
20
22
|
|
21
|
-
State can be either abbreviation or full state name
|
23
|
+
State can be either abbreviation or full state name.
|
22
24
|
|
23
25
|
```ruby
|
24
26
|
AreaCodeValidator.invalid?('123', 'FL') => true
|
25
27
|
AreaCodeValidator.invalid?('813', 'FL') => false
|
28
|
+
|
29
|
+
AreaCodeValidator.valid?('123', 'FL') => false
|
30
|
+
AreaCodeValidator.valid?('813', 'FL') => true
|
26
31
|
```
|
27
32
|
|
28
33
|
## Contributing
|
@@ -32,3 +37,7 @@ AreaCodeValidator.invalid?('813', 'FL') => false
|
|
32
37
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
38
|
4. Push to the branch (`git push origin my-new-feature`)
|
34
39
|
5. Create new Pull Request
|
40
|
+
|
41
|
+
## Future
|
42
|
+
|
43
|
+
Include an active model validation.
|
data/lib/area_code_validator.rb
CHANGED
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/test_helper')
|
|
2
2
|
|
3
3
|
class AreaCodeValidatorTest < Test::Unit::TestCase
|
4
4
|
context AreaCodeValidator do
|
5
|
-
context '
|
5
|
+
context '.invalid?' do
|
6
6
|
|
7
7
|
Helper::VALID_AREA_CODES.each do |state, area_codes_array|
|
8
8
|
area_codes_array.each_with_index do |area_code, index|
|
@@ -54,12 +54,30 @@ class AreaCodeValidatorTest < Test::Unit::TestCase
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
context '
|
57
|
+
context '.get_abbreviation_key' do
|
58
58
|
AreaCodeValidator::AreaCodeConfig::STATES.each do |state_abbreviation, state_name|
|
59
59
|
should "return the correct state abbreviation #{state_abbreviation}" do
|
60
60
|
assert_equal state_abbreviation, AreaCodeValidator.get_abbreviation_key(state_name)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
64
|
+
|
65
|
+
context '.invalid?' do
|
66
|
+
Helper::VALID_AREA_CODES.each do |state, area_codes_array|
|
67
|
+
area_codes_array.each_with_index do |area_code, index|
|
68
|
+
should "be a valid area code #{area_code} - #{state} index: #{index}" do
|
69
|
+
assert AreaCodeValidator.valid?(area_code, state), state.inspect + ' ' + area_code.inspect
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
Helper::VALID_AREA_CODES.each do |state, area_codes_array|
|
75
|
+
area_codes_array.each_with_index do |area_code, index|
|
76
|
+
should "not be a valid area_code #{area_code} - #{state} index: #{index}" do
|
77
|
+
refute AreaCodeValidator.valid?(area_code + '123', state), state.inspect + ' ' + area_code + '123'
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
64
82
|
end
|
65
83
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: area_code_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Medeiros
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|