vin-validator 1.0.0.pre.rc.1 → 1.0.0.pre.rc.3
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 +4 -4
- data/README.adoc +1 -1
- data/lib/vin_validator/knowledge.rb +7 -6
- data/lib/vin_validator/maker.rb +3 -1
- data/lib/vin_validator/version.rb +1 -1
- data/lib/vin_validator/wmi.rb +3 -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: 3741f814c141ef471f7ebcfda3251460cf7b0b3efa6c37533ed7f2f7c23e0b50
|
4
|
+
data.tar.gz: ea39c504029413cf2e1ea7c76a1204dd78a3740873c090a1528a3f55e6b95b15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10f26742ead7a64d80fe89441ca9c2551855f24a2cd073643ae92d2455ef93b4b2d5ec17c2addfe1fd698ce6a0950be26728c762ef6954ea27ebafaff000c061
|
7
|
+
data.tar.gz: dcd6eb8eca3cf5aebef2a6885f8c38e7702a43ea7dfbe632345b353856db73744abcb4f1862aea00b8ea4461fd735037589682153cc57c40a532e22a8ec4aec2
|
data/README.adoc
CHANGED
@@ -18,10 +18,7 @@ module VinValidator
|
|
18
18
|
def vin_info(vins, hit_nhtsa = false, &block)
|
19
19
|
results = hit_nhtsa ? VinValidator::Api.vin_info(vins, &block) : {}
|
20
20
|
|
21
|
-
Array(vins).
|
22
|
-
vin_results = results.fetch(vin, {})
|
23
|
-
[vin, build_results(vin, vin_results)]
|
24
|
-
end
|
21
|
+
Array(vins).map { |vin| [vin, build_results(vin, results.fetch(vin, {}))] }.to_h
|
25
22
|
end
|
26
23
|
|
27
24
|
private
|
@@ -79,7 +76,8 @@ module VinValidator
|
|
79
76
|
end
|
80
77
|
end
|
81
78
|
|
82
|
-
vin_errors << 'Check digit is incorrect.'
|
79
|
+
vin_errors << 'Check digit is incorrect.' if get_check_digit(vin) != vin[8]
|
80
|
+
|
83
81
|
vin_errors
|
84
82
|
end
|
85
83
|
|
@@ -103,13 +101,16 @@ module VinValidator
|
|
103
101
|
map = '0123456789X'
|
104
102
|
weights = '8765432X098765432'
|
105
103
|
sum = 0
|
104
|
+
|
106
105
|
17.times do |i|
|
107
106
|
value_weight = transliterate(vin[i])
|
107
|
+
|
108
108
|
return nil if value_weight.nil?
|
109
109
|
|
110
110
|
sum += value_weight * map.index(weights[i])
|
111
111
|
end
|
112
|
-
|
112
|
+
|
113
|
+
map[sum % 11]
|
113
114
|
end
|
114
115
|
|
115
116
|
# Combines T2 and NHTSA's results. Will attempt to create `VinValidator::Result`s
|
data/lib/vin_validator/maker.rb
CHANGED
@@ -10,9 +10,11 @@ module VinValidator
|
|
10
10
|
def all
|
11
11
|
return @all if defined?(@all)
|
12
12
|
|
13
|
-
|
13
|
+
all = JSON.parse(File.read(File.join(__dir__, 'makers.json')), { symbolize_names: true }).map do |id, v|
|
14
14
|
[id.to_s, new(**v)]
|
15
15
|
end
|
16
|
+
|
17
|
+
@all = all.to_h
|
16
18
|
end
|
17
19
|
|
18
20
|
# Finds the maker with the given `id`
|
data/lib/vin_validator/wmi.rb
CHANGED
@@ -10,9 +10,11 @@ module VinValidator
|
|
10
10
|
def all
|
11
11
|
return @all if defined?(@all)
|
12
12
|
|
13
|
-
|
13
|
+
all = JSON.parse(File.read(File.join(__dir__, 'wmis.json')), { symbolize_names: true }).map do |id, v|
|
14
14
|
[id.to_s, new(**v)]
|
15
15
|
end
|
16
|
+
|
17
|
+
@all = all.to_h
|
16
18
|
end
|
17
19
|
|
18
20
|
# Finds the wmi with the given `id`
|