vin-validator 1.1.0.pre.rc.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +5 -0
- data/README.adoc +53 -0
- data/lib/vin_validator/knowledge.rb +6 -9
- data/lib/vin_validator/maker.rb +2 -0
- data/lib/vin_validator/version.rb +1 -1
- data/lib/vin_validator/wmi.rb +2 -0
- data/lib/vin_validator/year.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18079484ae913bfde0303a09c79d57a1218d3e2a98c9a08bb16d913327bb4cf8
|
4
|
+
data.tar.gz: 1a2564a4468edc52e278a458029dfb3ddf41694204fbb778b0319dc73d9fbb90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62479a95c57806373805006a4ac4d928f1702e8331ff127e4df2f0d47da26721aa9bf1fdc621f8484bfb171b95ff92dcb995f21f2397db3cd6a6d92423270f1f
|
7
|
+
data.tar.gz: 46e22fd11203835b2dfa6eb21976f23d0bd4fe7700802024e06edd9ddfedc634d3df36b934cbad0251f41d0fcab534a68f143fac3dc1f2c9d14afba2a0411d9f
|
data/CHANGELOG.adoc
CHANGED
data/README.adoc
CHANGED
@@ -21,6 +21,8 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
== Usage
|
23
23
|
|
24
|
+
=== ``vin_info``
|
25
|
+
|
24
26
|
[source,ruby]
|
25
27
|
----
|
26
28
|
just_a_vin = 'AA5325L1588827'
|
@@ -86,6 +88,57 @@ Value hash:
|
|
86
88
|
* ``type`` - The type of result (``error``, ``make``, ``year``, etc)
|
87
89
|
* ``value`` - The value of the result
|
88
90
|
|
91
|
+
=== ``validate``
|
92
|
+
|
93
|
+
[source,ruby]
|
94
|
+
----
|
95
|
+
just_a_vin = 'AA5325L1588827'
|
96
|
+
other_vins = %w[13N153201K1533942 1E9AA5325L1588827 1RND48A27GR039983 1RND53A33KR049282]
|
97
|
+
|
98
|
+
VinValidator::Knowledge.validate(just_a_vin).fetch(just_a_vin)
|
99
|
+
|
100
|
+
VinValidator::Knowledge.validate(just_a_vin, true).fetch(just_a_vin)
|
101
|
+
|
102
|
+
VinValidator::Knowledge.validate(other_vins)
|
103
|
+
|
104
|
+
VinValidator::Knowledge.validate(other_vins, true)
|
105
|
+
----
|
106
|
+
|
107
|
+
Every call to ``VinValidator::Knowledge::vin_info`` will return a hash.
|
108
|
+
Each key in the result is one of the VINs provided, and each value is another hash.
|
109
|
+
|
110
|
+
Value hash:
|
111
|
+
|
112
|
+
|===
|
113
|
+
|Key |Value |Description
|
114
|
+
|
115
|
+
|``:valid``
|
116
|
+
|``Boolean``
|
117
|
+
|``false`` if there are errors or year/wmi is blank
|
118
|
+
|
119
|
+
|``:year``
|
120
|
+
|``Hash``, ``Nil``
|
121
|
+
|``:letter``(``String``) and ``:year``(``Integer``)
|
122
|
+
|
123
|
+
|``:wmi``
|
124
|
+
|``Array<VinValidator::Result>``
|
125
|
+
|Possible makes the VIN can have
|
126
|
+
|
127
|
+
|``:infos``
|
128
|
+
|``Array<String>``
|
129
|
+
|The info messages
|
130
|
+
|
131
|
+
|``:errors``
|
132
|
+
|``Array<String>``
|
133
|
+
|The error messages
|
134
|
+
|===
|
135
|
+
|
136
|
+
``VinValidator::Result`` has 3 attributes: ``vin``, ``type``, and ``value``.
|
137
|
+
|
138
|
+
* ``vin`` - The vin the result belongs to
|
139
|
+
* ``type`` - The type of result (``error``, ``make``, ``year``, etc)
|
140
|
+
* ``value`` - The value of the result
|
141
|
+
|
89
142
|
== Changelog
|
90
143
|
|
91
144
|
See xref:./CHANGELOG.adoc[CHANGELOG] see changes
|
@@ -29,18 +29,15 @@ module VinValidator
|
|
29
29
|
next [vin, {
|
30
30
|
valid: false,
|
31
31
|
wmi: [],
|
32
|
-
year: {},
|
33
32
|
errors: simple_check.fetch(:errors).map(&:value)
|
34
33
|
}]
|
35
34
|
end
|
36
35
|
|
37
|
-
vin_split = vin.
|
36
|
+
vin_split = vin.chars
|
38
37
|
|
39
|
-
|
40
|
-
vin_year = vin_split[9].to_s
|
41
|
-
year = VinValidator::Year.find_by(letter: vin_year)
|
38
|
+
year = VinValidator::Year.find_by(letter: vin_split[9].to_s)
|
42
39
|
|
43
|
-
possible_wmis = Array(simple_check[:make])
|
40
|
+
possible_wmis = Array(simple_check[:make])
|
44
41
|
|
45
42
|
errors = []
|
46
43
|
|
@@ -61,10 +58,10 @@ module VinValidator
|
|
61
58
|
end
|
62
59
|
|
63
60
|
[vin, {
|
64
|
-
valid: !year.nil? && !possible_wmis.
|
65
|
-
year:
|
61
|
+
valid: !year.nil? && !possible_wmis.empty?,
|
62
|
+
year: year,
|
66
63
|
errors: errors,
|
67
|
-
wmi: possible_wmis.uniq
|
64
|
+
wmi: possible_wmis.uniq(&:value),
|
68
65
|
infos: infos
|
69
66
|
}]
|
70
67
|
end
|
data/lib/vin_validator/maker.rb
CHANGED
data/lib/vin_validator/wmi.rb
CHANGED
data/lib/vin_validator/year.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vin-validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brands Insurance
|
@@ -65,9 +65,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
65
|
version: 2.5.3
|
66
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- - "
|
68
|
+
- - ">="
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
70
|
+
version: '0'
|
71
71
|
requirements: []
|
72
72
|
rubygems_version: 3.4.10
|
73
73
|
signing_key:
|