aamva 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Guardfile +13 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +8 -0
- data/aamva.gemspec +36 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/exe/aamva +6 -0
- data/lib/aamva.rb +35 -0
- data/lib/aamva/card.rb +6 -0
- data/lib/aamva/cli.rb +19 -0
- data/lib/aamva/data_element.rb +9 -0
- data/lib/aamva/data_element/base.rb +8 -0
- data/lib/aamva/data_element/day.rb +17 -0
- data/lib/aamva/generator.rb +39 -0
- data/lib/aamva/validator.rb +67 -0
- data/lib/aamva/version.rb +5 -0
- metadata +192 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3af3f537099b16b1d96ab150d8823913fcd87e18
|
4
|
+
data.tar.gz: 7ce0e6fea0b14b4b9ae30dbbda0a3dd42c9b7eb3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 03af9e81adc73f281da2bb35d3e496e06bb4a88afe5aa7171debefcfa4cb78e3239dda1953197931eac31162b905ef228a887ecfb89454a648e5a561be4bbd71
|
7
|
+
data.tar.gz: 6cce0f716c0c9d2be90db8648f14c58a02af4af4998c3ebb7e000916dc94d36de2a1063b2ff89752847436a7339b98eb564f2b2ba646235ed82aef5840a56f8e
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
4
|
+
require 'guard/rspec/dsl'
|
5
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
6
|
+
|
7
|
+
rspec = dsl.rspec
|
8
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
9
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
10
|
+
watch(rspec.spec_files)
|
11
|
+
|
12
|
+
dsl.watch_spec_files_for(dsl.ruby.lib_files)
|
13
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Kyle Decot
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Aamva
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/aamva`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'aamva'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install aamva
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/aamva.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/aamva.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
lib = File.expand_path('../lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
require 'aamva/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = 'aamva'
|
10
|
+
spec.version = Aamva::VERSION
|
11
|
+
spec.authors = ['Kyle Decot']
|
12
|
+
spec.email = ['kyle@joinroot.com']
|
13
|
+
|
14
|
+
spec.summary = 'Write a short summary, because Rubygems requires one.'
|
15
|
+
spec.description = 'Write a longer description or delete this line.'
|
16
|
+
spec.homepage = 'https://github.com/kyledecot/aamva'
|
17
|
+
spec.license = 'MIT'
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
|
+
f.match(%r{^(test|spec|features)/})
|
21
|
+
end
|
22
|
+
spec.bindir = 'exe'
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ['lib']
|
25
|
+
|
26
|
+
spec.add_dependency 'gli', '~> 2.16'
|
27
|
+
spec.add_dependency 'faker'
|
28
|
+
|
29
|
+
spec.add_development_dependency 'bundler', '~> 1.14'
|
30
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.7.3'
|
31
|
+
spec.add_development_dependency 'pry', '~> 0.11.3'
|
32
|
+
spec.add_development_dependency 'rake', '~> 12.3.0'
|
33
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
34
|
+
spec.add_development_dependency 'rubocop', '~> 0.49'
|
35
|
+
spec.add_development_dependency 'simplecov', '~> 0.15.1'
|
36
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'aamva'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/aamva
ADDED
data/lib/aamva.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aamva/version'
|
4
|
+
require 'aamva/card'
|
5
|
+
require 'aamva/data_element'
|
6
|
+
require 'aamva/cli'
|
7
|
+
require 'aamva/generator'
|
8
|
+
require 'aamva/validator'
|
9
|
+
|
10
|
+
module Aamva
|
11
|
+
DAY_LENGTH = 3
|
12
|
+
MAX_DAC_LENGTH = 40
|
13
|
+
|
14
|
+
DCG_MAPPING = {
|
15
|
+
'USA' => 'USA',
|
16
|
+
'CAN' => 'CAN'
|
17
|
+
}
|
18
|
+
|
19
|
+
DBC_MAPPING = {
|
20
|
+
"1" => "Male",
|
21
|
+
"2" => "Female",
|
22
|
+
"9" => "Not Specified"
|
23
|
+
}
|
24
|
+
|
25
|
+
DAY_MAPPING = {
|
26
|
+
'BLK' => 'Black',
|
27
|
+
'BLU' => 'Blue',
|
28
|
+
'BRO' => 'Brown',
|
29
|
+
'GRY' => 'Gray',
|
30
|
+
'GRN' => 'Green',
|
31
|
+
'HAZ' => 'Hazel',
|
32
|
+
'MAR' => 'Maroon PNK Pink',
|
33
|
+
'DIC' => 'Dichromatic UNK Unknown',
|
34
|
+
}
|
35
|
+
end
|
data/lib/aamva/card.rb
ADDED
data/lib/aamva/cli.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'gli'
|
4
|
+
require 'aamva/version'
|
5
|
+
|
6
|
+
module Aamva
|
7
|
+
class CLI
|
8
|
+
extend GLI::App
|
9
|
+
|
10
|
+
version Aamva::VERSION
|
11
|
+
|
12
|
+
command ["generate:day"] do |c|
|
13
|
+
c.action do |_global, _options, _args|
|
14
|
+
|
15
|
+
puts Aamva::Generator.day
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'faker'
|
2
|
+
|
3
|
+
module Aamva
|
4
|
+
class Generator
|
5
|
+
def self.dcg
|
6
|
+
DCG_MAPPING.keys.sample
|
7
|
+
end
|
8
|
+
|
9
|
+
# Customer ID Number
|
10
|
+
|
11
|
+
def self.daq
|
12
|
+
chars = ('A'..'Z').to_a + (('0'..'9').to_a)
|
13
|
+
|
14
|
+
chars.sample(25).join("")
|
15
|
+
end
|
16
|
+
|
17
|
+
# Physical Description – Eye Color
|
18
|
+
|
19
|
+
def self.day
|
20
|
+
DAY_MAPPING.keys.sample
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.dac
|
24
|
+
Faker::Name.first_name[0..MAX_DAC_LENGTH]
|
25
|
+
end
|
26
|
+
|
27
|
+
# Date of Birth
|
28
|
+
|
29
|
+
def self.dbb
|
30
|
+
Faker::Date.birthday.strftime("%Y%m%d")
|
31
|
+
end
|
32
|
+
|
33
|
+
# Document Issue Date
|
34
|
+
|
35
|
+
def self.dbd
|
36
|
+
Faker::Date.backward.strftime("%Y%m%d")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Aamva
|
2
|
+
class Validator
|
3
|
+
|
4
|
+
# Physical Description – Eye Color
|
5
|
+
|
6
|
+
def self.day(day)
|
7
|
+
return false unless length(day, min: DAY_LENGTH, max: DAY_LENGTH)
|
8
|
+
return false unless DAY_MAPPING.keys.include?(day)
|
9
|
+
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
# Document Expiration Date
|
14
|
+
|
15
|
+
def self.dba(dbd)
|
16
|
+
dbd.match?(/\A[\d+]{8,8}\z/)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Customer ID Number
|
20
|
+
|
21
|
+
def self.daq(daq)
|
22
|
+
daq.match?(/\A[\d\w]{1,25}\z/)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Document Issue Date
|
26
|
+
|
27
|
+
def self.dbd(dbd)
|
28
|
+
dbd.match?(/\A[\d+]{8,8}\z/)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Date of Birth
|
32
|
+
|
33
|
+
def self.dbb(dbb)
|
34
|
+
dbb.match?(/\A[\d+]{8,8}\z/)
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.dbc(dbc)
|
38
|
+
return false unless length(dbc, min: 1, max: 1)
|
39
|
+
return false unless DBC_MAPPING.keys.include?(dbc)
|
40
|
+
|
41
|
+
true
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.dcg(dcg)
|
45
|
+
return false unless length(dcg, min: 3, max: 3)
|
46
|
+
return false unless DCG_MAPPING.keys.include?(dcg)
|
47
|
+
|
48
|
+
true
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.dai(dai)
|
52
|
+
return false unless length(dai, min: 1, max: 20)
|
53
|
+
|
54
|
+
true
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.dac(dac)
|
58
|
+
return false unless length(dac, min: 1, max: MAX_DAC_LENGTH)
|
59
|
+
|
60
|
+
true
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.length(value, min:, max:)
|
64
|
+
value.length >= min && value.length <= max
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
metadata
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aamva
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kyle Decot
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gli
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.16'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faker
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.14'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard-rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 4.7.3
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 4.7.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.11.3
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.11.3
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 12.3.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 12.3.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.49'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.49'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.15.1
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.15.1
|
139
|
+
description: Write a longer description or delete this line.
|
140
|
+
email:
|
141
|
+
- kyle@joinroot.com
|
142
|
+
executables:
|
143
|
+
- aamva
|
144
|
+
extensions: []
|
145
|
+
extra_rdoc_files: []
|
146
|
+
files:
|
147
|
+
- ".gitignore"
|
148
|
+
- ".rspec"
|
149
|
+
- ".travis.yml"
|
150
|
+
- Gemfile
|
151
|
+
- Guardfile
|
152
|
+
- LICENSE.txt
|
153
|
+
- README.md
|
154
|
+
- Rakefile
|
155
|
+
- aamva.gemspec
|
156
|
+
- bin/console
|
157
|
+
- bin/setup
|
158
|
+
- exe/aamva
|
159
|
+
- lib/aamva.rb
|
160
|
+
- lib/aamva/card.rb
|
161
|
+
- lib/aamva/cli.rb
|
162
|
+
- lib/aamva/data_element.rb
|
163
|
+
- lib/aamva/data_element/base.rb
|
164
|
+
- lib/aamva/data_element/day.rb
|
165
|
+
- lib/aamva/generator.rb
|
166
|
+
- lib/aamva/validator.rb
|
167
|
+
- lib/aamva/version.rb
|
168
|
+
homepage: https://github.com/kyledecot/aamva
|
169
|
+
licenses:
|
170
|
+
- MIT
|
171
|
+
metadata: {}
|
172
|
+
post_install_message:
|
173
|
+
rdoc_options: []
|
174
|
+
require_paths:
|
175
|
+
- lib
|
176
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '0'
|
186
|
+
requirements: []
|
187
|
+
rubyforge_project:
|
188
|
+
rubygems_version: 2.6.11
|
189
|
+
signing_key:
|
190
|
+
specification_version: 4
|
191
|
+
summary: Write a short summary, because Rubygems requires one.
|
192
|
+
test_files: []
|