area_code_validator 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57fe582d083784329e37ea9dcbabd74387dc10ab
4
- data.tar.gz: 24d85ff4d861f1a84a18fb5824d2ab650f5feb1f
3
+ metadata.gz: 4e9b9fd948d5048afec0f3eadf2024bbe38717aa
4
+ data.tar.gz: dd5c8bb29ec75407c01b1a03d02dde911d8bfd22
5
5
  SHA512:
6
- metadata.gz: e5eec02a1fd6a3966c0a9527f594a911028a046e65c6c7afdbb46a4ab9ddf5d52a6660d1f2c6cb85244a27c534ffab4131bec525ae5b6a5cf98c9da8b4a2c8ef
7
- data.tar.gz: 1130a83dea93c8447dbd01ef34b51f91e429efa09ffa179c1011ac83c3533e08b9fc318cdd3967e8b38a73913d52da726c1fd21975d331464ca7b8c628d5d5e3
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.
@@ -1,3 +1,3 @@
1
1
  module AreaCodeValidator
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -38,4 +38,9 @@ module AreaCodeValidator
38
38
  end
39
39
  key
40
40
  end
41
+
42
+ # inverse of invalid?
43
+ def self.valid?(area_code, area_code_state)
44
+ !invalid?(area_code, area_code_state)
45
+ end
41
46
  end
@@ -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 '#invalid?' do
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 '#get_abbreviation_key' do
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.2
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-08-26 00:00:00.000000000 Z
11
+ date: 2013-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler