dl_validator 0.0.4 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88ea58e3122404e367b73b90f595caa4d0fe52ab
4
- data.tar.gz: daa0003e8411f712b5120ea42e86bb0608fce865
3
+ metadata.gz: d842ca8ae1d8e0f2744ee451eb65c78378ec9d2d
4
+ data.tar.gz: 2818a638b67f8f4fc45c9e88935014fe124cd38f
5
5
  SHA512:
6
- metadata.gz: e076ea59cd8b8488a1e43dbbda76f863906a10373e01ca593e5d22958d594fceb579948bf553c78cc860eae7168455cdee53e20784eef84ca783a55871a8f359
7
- data.tar.gz: eb0967b17080dc9aa375aa053075ba8748ee75c3a475740983d8db3b45b89e3e9b7e35e350fa8cd77c41932b38c613b6117ca550c6656dde222675d510b282b3
6
+ metadata.gz: d2ab27d739aa15de609f74df9a88237cde4f0a2a5afa41e65e63a08590a33c709f60f2065a0e6cadf29b47699d8fb61f57c0fcebd4301f83b977839d8b6fa3f4
7
+ data.tar.gz: 7f7009fefb7f0210d372543d3da82f61ffb4ed8c231799e1958f6b3b683a360a3914a79a64b7256881e58099772fe7ef17fe61afba9a57ab19fab79fdc0ff5ff
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dl_validator (0.0.2)
4
+ dl_validator (0.0.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  DlValidator is a small gem that performs soft checks against a drivers license number and state. This is used only to flag a drivers license as being invalid, and is not intended to be considered true denial on a drivers license number.
4
4
 
5
+ The valid method is supported in version >= 0.0.5
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -22,7 +24,10 @@ With a drivers license number and drivers license state
22
24
 
23
25
  ```ruby
24
26
  DlValidator.invalid?('F123456789012', 'FL') => false
25
- DlValidator.invalid?('F7834', 'FL') => true
27
+ DlValidator.invalid?('F7834', 'FL') => true
28
+
29
+ DlValidator.valid?('F123456789012', 'FL') => true
30
+ DlValidator.valid?('F7834', 'FL') => false
26
31
  ```
27
32
 
28
33
  Inside your rails model. Dependent on fields :drivers_license_number and :drivers_license_state
@@ -41,3 +46,7 @@ end
41
46
  3. Commit your changes (`git commit -am 'Add some feature'`)
42
47
  4. Push to the branch (`git push origin my-new-feature`)
43
48
  5. Create new Pull Request
49
+
50
+ ## Future
51
+
52
+ Update active model validation to be more flexible with field names.
@@ -35,4 +35,9 @@ module DlValidator
35
35
  end
36
36
  key
37
37
  end
38
+
39
+ # Inverse of invalid?
40
+ def self.valid?(dl_number, dl_state)
41
+ !invalid?(dl_number, dl_state)
42
+ end
38
43
  end
@@ -1,3 +1,3 @@
1
1
  module DlValidator
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -2,20 +2,20 @@ require File.expand_path(File.dirname(__FILE__) + '/test_helper')
2
2
 
3
3
  class DlValidatorTest < Test::Unit::TestCase
4
4
  context DlValidator do
5
- context '#invalid?' do
5
+ context '.invalid?' do
6
6
 
7
- Helper::VALID_DRIVERS_LICENSES.each do |key, licenses_array|
7
+ Helper::VALID_DRIVERS_LICENSES.each do |state, licenses_array|
8
8
  licenses_array.each_with_index do |license, index|
9
- should "be a valid drivers license #{license} - #{key} index: #{index}" do
10
- assert !DlValidator.invalid?(license, key), key.inspect + ' ' + license.inspect
9
+ should "be a valid drivers license #{license} - #{state} index: #{index}" do
10
+ assert !DlValidator.invalid?(license, state), state.inspect + ' ' + license.inspect
11
11
  end
12
12
  end
13
13
  end
14
14
 
15
- Helper::VALID_DRIVERS_LICENSES.each do |key, licenses_array|
15
+ Helper::VALID_DRIVERS_LICENSES.each do |state, licenses_array|
16
16
  licenses_array.each_with_index do |license, index|
17
- should "not be a valid drivers license #{license} - #{key} index: #{index}" do
18
- assert DlValidator.invalid?(license + '123ABC', key), key.inspect + ' ' + license + '123ABC'
17
+ should "not be a valid drivers license #{license} - #{state} index: #{index}" do
18
+ assert DlValidator.invalid?(license + '123ABC', state), state.inspect + ' ' + license + '123ABC'
19
19
  end
20
20
  end
21
21
  end
@@ -54,12 +54,30 @@ class DlValidatorTest < 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
  DlValidator::DlConfig::STATES.each do |state_abbreviation, state_name|
59
59
  should "return the correct state abbreviation #{state_abbreviation}" do
60
60
  assert_equal state_abbreviation, DlValidator.get_abbreviation_key(state_name)
61
61
  end
62
62
  end
63
63
  end
64
+
65
+ context '.valid' do
66
+ Helper::VALID_DRIVERS_LICENSES.each do |state, licenses_array|
67
+ licenses_array.each_with_index do |license, index|
68
+ should "be a valid drivers license #{license} - #{state} index: #{index}" do
69
+ assert DlValidator.valid?(license, state), state.inspect + ' ' + license.inspect
70
+ end
71
+ end
72
+ end
73
+
74
+ Helper::VALID_DRIVERS_LICENSES.each do |state, licenses_array|
75
+ licenses_array.each_with_index do |license, index|
76
+ should "not be a valid drivers license #{license} - #{state} index: #{index}" do
77
+ refute DlValidator.valid?(license + '123ABC', state), state.inspect + ' ' + license + '123ABC'
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: dl_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
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-09-16 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