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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09b6a9a66a5d7d95da1f899f47c76dfce32dfe3c64b0ab9da1430c111ed9f41a'
4
- data.tar.gz: 1b6ab1b90068a41859ece6ce59a63441f519bf7fc9a0d52279a357a39c071927
3
+ metadata.gz: 3741f814c141ef471f7ebcfda3251460cf7b0b3efa6c37533ed7f2f7c23e0b50
4
+ data.tar.gz: ea39c504029413cf2e1ea7c76a1204dd78a3740873c090a1528a3f55e6b95b15
5
5
  SHA512:
6
- metadata.gz: c7dc4990ca5ef305e80aa301ac7e563e65873e2e96c5384768583e320bb27abfa030c3b3c6a7b09caa8ea850251f49b022a64ef7008631a237192a27b100a411
7
- data.tar.gz: d40e46f343c2cf9fbd1ead1daa5220fabe319ff8ca4352ed7556a9d5df028a81d9e539355a47e5984637f16c81b2c0656c02745396c9a6cc4c5ffd340cca9419
6
+ metadata.gz: 10f26742ead7a64d80fe89441ca9c2551855f24a2cd073643ae92d2455ef93b4b2d5ec17c2addfe1fd698ce6a0950be26728c762ef6954ea27ebafaff000c061
7
+ data.tar.gz: dcd6eb8eca3cf5aebef2a6885f8c38e7702a43ea7dfbe632345b353856db73744abcb4f1862aea00b8ea4461fd735037589682153cc57c40a532e22a8ec4aec2
data/README.adoc CHANGED
@@ -8,7 +8,7 @@ Add this line to your application's Gemfile:
8
8
 
9
9
  [source,ruby]
10
10
  ----
11
- gem 'vin-validator', require: false
11
+ gem 'vin-validator'
12
12
  ----
13
13
 
14
14
  And then execute:
@@ -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).to_h do |vin|
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.' unless get_check_digit(vin) == vin[8]
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
- return map[sum % 11]
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
@@ -10,9 +10,11 @@ module VinValidator
10
10
  def all
11
11
  return @all if defined?(@all)
12
12
 
13
- @all = JSON.parse(File.read(File.join(__dir__, 'makers.json')), { symbolize_names: true }).to_h do |id, v|
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`
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module VinValidator
4
- VERSION = '1.0.0-rc.1'
4
+ VERSION = '1.0.0-rc.3'
5
5
  end
@@ -10,9 +10,11 @@ module VinValidator
10
10
  def all
11
11
  return @all if defined?(@all)
12
12
 
13
- @all = JSON.parse(File.read(File.join(__dir__, 'wmis.json')), { symbolize_names: true }).to_h do |id, v|
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`
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.0.0.pre.rc.1
4
+ version: 1.0.0.pre.rc.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brands Insurance