vin-validator 1.1.0.pre.rc.1 → 1.1.0

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: 6523c6bd1ad2fea7e124214d1373e350ad91651425e356895b27fa9e3e65345f
4
- data.tar.gz: 8f904a2603046eb4381f417300e0450b0f095aca1c43857de1b9c9753c47bff8
3
+ metadata.gz: 18079484ae913bfde0303a09c79d57a1218d3e2a98c9a08bb16d913327bb4cf8
4
+ data.tar.gz: 1a2564a4468edc52e278a458029dfb3ddf41694204fbb778b0319dc73d9fbb90
5
5
  SHA512:
6
- metadata.gz: a77c0325d479f4f263e1beb3354cafeb21d6eb7251cba6c7e48f64e735c559c0843fb4d50088c91d910c46002ea234589684b50e7e08edcbb52c4cf943d51a3c
7
- data.tar.gz: 90c38e20991bfd30dfc0df5b40eab5c56360d8e1a1e42933482c95af5bb87faacb0df0332b74dd7cd03649df81311393ca1db341aa0a91f901e9c832887a25ef
6
+ metadata.gz: 62479a95c57806373805006a4ac4d928f1702e8331ff127e4df2f0d47da26721aa9bf1fdc621f8484bfb171b95ff92dcb995f21f2397db3cd6a6d92423270f1f
7
+ data.tar.gz: 46e22fd11203835b2dfa6eb21976f23d0bd4fe7700802024e06edd9ddfedc634d3df36b934cbad0251f41d0fcab534a68f143fac3dc1f2c9d14afba2a0411d9f
data/CHANGELOG.adoc CHANGED
@@ -1,3 +1,8 @@
1
+ = 1.1.0
2
+
3
+ * Added ``VinValidator::Knowledge::validate``
4
+ ** Track revolving 30 years too
5
+
1
6
  = 1.0.0
2
7
 
3
8
  * Intial Release
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.split('')
36
+ vin_split = vin.chars
38
37
 
39
- vin_wmi = vin_split[0..2].join
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]).map { |gem_vin_wmi| { make: gem_vin_wmi.value } }
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.nil?,
65
- year: { letter: year.letter, year: year.year },
61
+ valid: !year.nil? && !possible_wmis.empty?,
62
+ year: year,
66
63
  errors: errors,
67
- wmi: possible_wmis.uniq { |wmi| wmi[:make] },
64
+ wmi: possible_wmis.uniq(&:value),
68
65
  infos: infos
69
66
  }]
70
67
  end
@@ -26,6 +26,8 @@ module VinValidator
26
26
 
27
27
  # :nodoc:
28
28
  def initialize(id:, name:)
29
+ super
30
+
29
31
  @id = id
30
32
  @name = name
31
33
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module VinValidator
4
- VERSION = '1.1.0-rc.1'
4
+ VERSION = '1.1.0'
5
5
  end
@@ -38,6 +38,8 @@ module VinValidator
38
38
 
39
39
  # :nodoc:
40
40
  def initialize(id:, wmi:, maker_id:, wmi_suffix: nil)
41
+ super
42
+
41
43
  @id = id
42
44
  @maker_id = maker_id
43
45
  @wmi = wmi
@@ -28,6 +28,8 @@ module VinValidator
28
28
 
29
29
  # :nodoc:
30
30
  def initialize(id:, year:, letter:)
31
+ super
32
+
31
33
  @id = id
32
34
  @year = year
33
35
  @letter = letter
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.pre.rc.1
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: 1.3.1
70
+ version: '0'
71
71
  requirements: []
72
72
  rubygems_version: 3.4.10
73
73
  signing_key: