vin-validator 1.1.0.pre.rc.1 → 1.1.0.pre.rc.2
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 +4 -5
- data/lib/vin_validator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8e5a52d479ddb4dd27dd04bd8f913aaaaea50fee21536ca8bed3062c1ef84b6
|
4
|
+
data.tar.gz: 728d00c37bfc36d52cb3d71e9e5ebdcac7fc37a15f704cabd175d095a51f426c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f89831b12d70327d1b8cc2b69dee43a09b1b0ae10453117021b45050bc0fdb7a35e7e935e875fccdff806c84f55b54dd56f7f1c138d8a53c1e7ba9fcaf17a78a
|
7
|
+
data.tar.gz: 940a7c613399ce02e4a2cd4e24f02ac069ce6869268326134267f86f76fa50b00bc848d9f536cadc265060edc021292b663348bfcbf5d2dc0dbe3d06eed1ec62
|
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,7 +29,6 @@ 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
|
@@ -40,7 +39,7 @@ module VinValidator
|
|
40
39
|
vin_year = vin_split[9].to_s
|
41
40
|
year = VinValidator::Year.find_by(letter: vin_year)
|
42
41
|
|
43
|
-
possible_wmis = Array(simple_check[:make])
|
42
|
+
possible_wmis = Array(simple_check[:make])
|
44
43
|
|
45
44
|
errors = []
|
46
45
|
|
@@ -61,10 +60,10 @@ module VinValidator
|
|
61
60
|
end
|
62
61
|
|
63
62
|
[vin, {
|
64
|
-
valid: !year.nil? && !possible_wmis.
|
65
|
-
year:
|
63
|
+
valid: !year.nil? && !possible_wmis.empty?,
|
64
|
+
year: year,
|
66
65
|
errors: errors,
|
67
|
-
wmi: possible_wmis.uniq
|
66
|
+
wmi: possible_wmis.uniq(&:value),
|
68
67
|
infos: infos
|
69
68
|
}]
|
70
69
|
end
|