vindsl 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 168344f7d069efc67d9d3029b23145b5c8c8f387
4
- data.tar.gz: 828a35672e933b98c98543a8a8244b47e2e6fe09
3
+ metadata.gz: 4cc312880a05dd0cdfd8a5402dfe5dc303b2fe28
4
+ data.tar.gz: 55e899decae068421aae38eaa5b8c0977c36edaf
5
5
  SHA512:
6
- metadata.gz: 77d7de356b4b0bdb9257437a0ff820c0214fd6ce89bfdca4751c80d7c7feef44f3e1063719acfe669d3ac5ae8b495241a89d3e1e1161ec12df2bdfc1f5d897fc
7
- data.tar.gz: ebc8bbc9d7c47db9663c5502297221d047f2282fbcd46a0243e1d0b51c25712749f0bf5d52d2bcb759f260f75ca24556a2900f2946df3767ee53ff2c737421af
6
+ metadata.gz: a04cbd00686bd821517240d2ff744508903551888837d70ab3af76b917abb99d017a85fec699519b61162fab658f48a1574292e61b4cf095c1a97dde0caa80c2
7
+ data.tar.gz: 477c2edcc57f5f30e48798fa5f57266cd0848b4efed1927b770ee1cd97a7a51726adc2f41f58ca759e6cbff7ca4b33dc599ea6fd0f1d226661c5ffd3eb3be3b6
@@ -1,7 +1,11 @@
1
1
  module Vindsl
2
2
  module Alphabet
3
- ALPHABET = %w{A B C D E F G H J K L M N P R S T V W X Y }
3
+ ALPHABET = %w{A B C D E F G H J K L M N P R S T V W X Y Z}
4
4
 
5
- ALPHABET_WITH_NUMBERS = ALPHABET + %w{ 1 2 3 4 5 6 7 8 9 }
5
+ NUMBERS = %w{0 1 2 3 4 5 6 7 8 9}
6
+
7
+ ALPHABET_WITH_NUMBERS = ALPHABET + NUMBERS
8
+
9
+ ALPHABET_FOR_YEARS = %w{A B C D E F G H J K L M N P R S T V W X Y 1 2 3 4 5 6 7 8 9 }
6
10
  end
7
- end
11
+ end
data/lib/vindsl/dsl.rb ADDED
@@ -0,0 +1,28 @@
1
+ require 'vindsl/alphabet'
2
+ require 'vindsl/wmi'
3
+
4
+ module Vindsl
5
+ class DSL
6
+ attr_accessor :country, :manufacturer, :model_year
7
+ def initialize
8
+ yield self
9
+ end
10
+
11
+ def regexp
12
+ Regexp.new "^#{ wmi_regexp }[#{Alphabet::ALPHABET_WITH_NUMBERS.join}]{14}$"
13
+ end
14
+
15
+ def wmi_regexp
16
+ country_prefixes = WMI.country_prefixes_for country
17
+ manufacturer_prefixes = WMI.manufacturer_prefixes_for manufacturer
18
+ prefix_pairs = country_prefixes.product manufacturer_prefixes
19
+ ok_prefixes = prefix_pairs.select { |(c, m)| Regexp.new(c).match m}
20
+ chunks = ok_prefixes.map do |(_c, pfx)|
21
+ need_dots = 3 - pfx.length
22
+ pfx + ('.' * need_dots)
23
+ end
24
+
25
+ "(#{chunks.join '|'})"
26
+ end
27
+ end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module Vindsl
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/vindsl/vin.rb CHANGED
@@ -23,7 +23,7 @@ module Vindsl
23
23
  year_character = position(10)
24
24
  base = pre_2009? ? 1980 : 2010
25
25
 
26
- base + Vindsl::Alphabet::ALPHABET_WITH_NUMBERS.index(year_character)
26
+ base + Vindsl::Alphabet::ALPHABET_FOR_YEARS.index(year_character)
27
27
  end
28
28
 
29
29
  private
data/lib/vindsl/wmi.rb CHANGED
@@ -4,170 +4,526 @@ require 'vindsl/prefix_matcher'
4
4
  module Vindsl
5
5
  # World Manufacturer Number
6
6
  module WMI
7
- COUNTRIES = {
8
- 'A' => 'South Africa',
9
- 'CL9' => 'Tunisia',
10
- 'J' => 'Japan',
11
- 'K' => 'South Korea',
12
- 'SA' => 'United Kingdom',
13
- 'SCC' => 'United Kingdom',
14
- 'SCE' => 'Ireland',
15
- 'TM' => 'Czech Republic',
16
- 'TR' => 'Hungary',
17
- 'U' => 'Romania',
18
- 'VA' => 'Austria',
19
- 'VF' => 'France',
20
- 'VS' => 'Spain',
21
- 'VV' => 'Spain',
22
- 'W' => 'Germany',
23
- 'YK' => 'Finland',
24
- 'YS3' => 'Sweden',
25
- 'YTN' => 'Sweden',
26
- 'YV1' => 'Sweden',
27
- 'Z' => 'Italy',
28
- '1' => 'United States',
29
- '2' => 'Canada',
30
- '3' => 'Mexico',
31
- '4' => 'United States',
32
- '5' => 'United States',
33
- '6' => 'Australia',
34
- '8' => 'Argentina',
35
- '9' => 'Brazil',
36
- }
7
+ COUNTRIES = {
8
+ 'A' => 'South Africa',
9
+ 'CL9' => 'Tunisia',
10
+ 'J' => 'Japan',
11
+ 'K' => 'South Korea',
12
+ 'SA' => 'United Kingdom',
13
+ 'SCC' => 'United Kingdom',
14
+ 'SCE' => 'Ireland',
15
+ 'TM' => 'Czech Republic',
16
+ 'TR' => 'Hungary',
17
+ 'U' => 'Romania',
18
+ 'VA' => 'Austria',
19
+ 'VF' => 'France',
20
+ 'VS' => 'Spain',
21
+ 'VV' => 'Spain',
22
+ 'W' => 'Germany',
23
+ 'YK' => 'Finland',
24
+ 'YS3' => 'Sweden',
25
+ 'YTN' => 'Sweden',
26
+ 'YV1' => 'Sweden',
27
+ 'Z' => 'Italy',
28
+ '1' => 'United States',
29
+ '2' => 'Canada',
30
+ '3' => 'Mexico',
31
+ '4' => 'United States',
32
+ '5' => 'United States',
33
+ '6' => 'Australia',
34
+ '8' => 'Argentina',
35
+ '9' => 'Brazil',
36
+ }
37
37
 
38
- MANUFACTURERS = {
39
- 'AAV' => "Volkswagen",
40
- 'AFA' => "Ford",
41
- 'CL9' => "Wallyscar",
42
- 'JA' => "Isuzu",
43
- 'JF' => "Fuji Heavy Industries",
44
- 'JH' => "Honda",
45
- 'JMB' => "Mitsubishi",
46
- 'JMZ' => "Mazda",
47
- 'JN' => "Nissan",
48
- 'JS' => "Suzuki",
49
- 'JT' => "Toyota",
50
- 'KL' => "Daewoo",
51
- 'KMH' => "Hyundai",
52
- 'KN' => "Kia",
53
- 'KPT' => "SsangYong",
54
- 'SAJ' => "Jaguar",
55
- 'SAL' => "Land Rover",
56
- 'SAR' => "Rover",
57
- 'SCC' => "Lotus Cars",
58
- 'SCE' => "DeLorean",
59
- 'TMA' => "Hyundai",
60
- 'TMB' => "Škoda",
61
- 'TRU' => "Audi",
62
- 'UU' => "Dacia",
63
- 'VA0' => "ÖAF",
64
- 'VF1' => "Renault",
65
- 'VF3' => "Peugeot",
66
- 'VF6' => "Renault Trucks/Volvo",
67
- 'VF7' => "Citroën",
68
- 'VFE' => "IvecoBus",
69
- 'VSS' => "SEAT",
70
- 'VV9' => "Tauro Sport Auto",
71
- 'WAU' => "Audi",
72
- 'WAP' => "Alpina",
73
- 'WBA' => "BMW",
74
- 'WBS' => "BMW M",
75
- 'WDB' => "Mercedes-Benz",
76
- 'WDC' => "DaimlerChrysler AG/Daimler AG",
77
- 'WDD' => "DaimlerChrysler AG/Daimler AG",
78
- 'WMX' => "DaimlerChrysler AG/Daimler AG",
79
- 'WEB' => "EvoBus",
80
- 'WF0' => "Ford Germany",
81
- 'WJM' => "Iveco",
82
- 'WJR' => "Irmscher",
83
- 'WKK' => "Kässbohrer",
84
- 'WMA' => "MAN",
85
- 'WME' => "Smart",
86
- 'WMW' => "Mini",
87
- 'WP0' => "Porsche car",
88
- 'WP1' => "Porsche SUV",
89
- 'WUA' => "Quattro",
90
- 'WVG' => "Volkswagen",
91
- 'WVW' => "Volkswagen",
92
- 'WV1' => "Volkswagen Commercial Vehicles",
93
- 'WV2' => "Volkswagen Commercial Vehicles",
94
- 'W0L' => "Opel/Vauxhall",
95
- 'W0SV' => "Opel Special Vehicles",
96
- 'YK1' => "Saab",
97
- 'YS3' => "Saab",
98
- 'YTN' => "Saab NEVS",
99
- 'YV1' => "Volvo Cars",
100
- 'ZAM' => "Maserati",
101
- 'ZAR' => "Alfa Romeo",
102
- 'ZCF' => "Iveco",
103
- 'ZFA' => "Fiat Automobiles",
104
- 'ZFF' => "Ferrari",
105
- 'ZGA' => "IvecoBus",
106
- 'ZHW' => "Lamborghini",
107
- 'ZLA' => "Lancia",
108
- '1C' => "Chrysler",
109
- '1F' => "Ford",
110
- '1G' => "General Motors",
111
- '1G3' => "Oldsmobile",
112
- '1GC' => "Chevrolet",
113
- '1GM' => "Pontiac",
114
- '1H' => "Honda",
115
- '1J' => "Jeep",
116
- '1L' => "Lincoln",
117
- '1M' => "Mercury",
118
- '1N' => "Nissan",
119
- '1VW' => "Volkswagen",
120
- '1YV' => "Mazda",
121
- '1Z' => 'Ford',
122
- '2F' => "Ford",
123
- '2G' => "General Motors",
124
- '2G1' => "Chevrolet",
125
- '2G2' => "Pontiac",
126
- '2H' => "Honda",
127
- '2HM' => "Hyundai",
128
- '2M' => "Mercury",
129
- '2T' => "Toyota",
130
- '3F' => "Ford",
131
- '3G' => "General Motors",
132
- '3H' => "Honda",
133
- '3N' => "Nissan",
134
- '3VW' => "Volkswagen",
135
- '4F' => "Mazda",
136
- '4J' => "Mercedes-Benz",
137
- '4M' => "Mercury",
138
- '4S' => "Subaru",
139
- '4T' => "Toyota",
140
- '4US' => "BMW",
141
- '5F' => "Honda",
142
- '5L' => "Lincoln",
143
- '5T' => "Toyota",
144
- '5YJ' => "Tesla",
145
- '6F' => "Ford",
146
- '6G' => "General Motors",
147
- '6G1' => "Chevrolet",
148
- '6G2' => "Pontiac",
149
- '6H' => "Holden",
150
- '6MM' => "Mitsubishi",
151
- '6T1' => "Toyota",
152
- '8AP' => "Fiat",
153
- '8AT' => "Iveco",
154
- '9BD' => "Fiat Automóveis",
155
- '9BW' => "Volkswagen",
156
- '93H' => "Honda",
157
- '93W' => "Fiat Professional",
158
- '93Z' => "Iveco",
159
- '9BH' => "Hyundai",
160
- }
38
+ MANUFACTURERS = {
39
+ '10T' => 'Oshkosh',
40
+ '11V' => 'Ottawa',
41
+ '137' => 'AM General, Hummer',
42
+ '15G' => 'Gillig',
43
+ '17N' => 'John Deere',
44
+ '18X' => 'WRV',
45
+ '19U' => 'Acura',
46
+ '1A4' => 'Chrysler',
47
+ '1A8' => 'Chrysler',
48
+ '1AC' => 'AMC',
49
+ '1AM' => 'AMC',
50
+ '1B3' => 'Dodge',
51
+ '1B4' => 'Dodge',
52
+ '1B6' => 'Dodge',
53
+ '1B7' => 'Dodge',
54
+ '1B7' => 'Dodge',
55
+ '1BA' => 'Blue Bird',
56
+ '1BB' => 'Blue Bird',
57
+ '1BD' => 'Blue Bird',
58
+ '1C3' => 'Chrysler',
59
+ '1C4' => 'Chrysler',
60
+ '1C8' => 'Chrysler',
61
+ '1C9' => 'Chance',
62
+ '1CY' => 'Crane Carrier',
63
+ '1D3' => 'Dodge',
64
+ '1D4' => 'Dodge',
65
+ '1D5' => 'Dodge',
66
+ '1D7' => 'Dodge',
67
+ '1D8' => 'Dodge',
68
+ '1EC' => 'Fleetwood',
69
+ '1F1' => 'Ford',
70
+ '1F6' => 'Ford',
71
+ '1FA' => 'Ford',
72
+ '1FB' => 'Ford',
73
+ '1FC' => 'Ford',
74
+ '1FD' => 'Ford',
75
+ '1FE' => 'Ford',
76
+ '1FM' => 'Ford',
77
+ '1FT' => 'Ford',
78
+ '1FU' => 'Freightliner',
79
+ '1FV' => 'Freightliner',
80
+ '1G1' => 'Chevrolet',
81
+ '1G2' => 'Pontiac',
82
+ '1G3' => 'Oldsmobile',
83
+ '1G4' => 'Buick',
84
+ '1G5' => 'GMC, Pontiac',
85
+ '1G6' => 'Cadillac',
86
+ '1G8' => 'Chevrolet, Saturn',
87
+ '1GA' => 'Chevrolet',
88
+ '1GB' => 'Chevrolet',
89
+ '1GC' => 'Chevrolet',
90
+ '1GD' => 'GMC',
91
+ '1GE' => 'Cadillac',
92
+ '1GF' => 'Flexible',
93
+ '1GG' => 'Isuzu',
94
+ '1GH' => 'GMC, Oldsmobile',
95
+ '1GJ' => 'GMC',
96
+ '1GK' => 'GMC',
97
+ '1GM' => 'Pontiac',
98
+ '1GN' => 'Chevrolet',
99
+ '1GT' => 'GMC',
100
+ '1GY' => 'Cadillac',
101
+ '1HG' => 'Honda',
102
+ '1HS' => 'International',
103
+ '1HT' => 'International',
104
+ '1HV' => 'International',
105
+ '1J4' => 'Jeep',
106
+ '1J7' => 'Jeep',
107
+ '1J8' => 'Jeep',
108
+ '1JC' => 'AMC, Jeep',
109
+ '1JD' => 'AMC',
110
+ '1JT' => 'AMC, Jeep',
111
+ '1L1' => 'Lincoln',
112
+ '1LN' => 'Lincoln',
113
+ '1M1' => 'Mack',
114
+ '1M2' => 'Mack',
115
+ '1M3' => 'Mack',
116
+ '1M8' => 'MCI',
117
+ '1ME' => 'Mercury',
118
+ '1MR' => 'Lincoln',
119
+ '1N4' => 'Nissan',
120
+ '1N6' => 'Datsun, Nissan',
121
+ '1N9' => 'Neoplan',
122
+ '1NK' => 'Kenworth',
123
+ '1NP' => 'Peterbilt',
124
+ '1NX' => 'Toyota',
125
+ '1P3' => 'Plymouth',
126
+ '1P4' => 'Plymouth',
127
+ '1P7' => 'Plymouth',
128
+ '1P9' => 'Panoz',
129
+ '1RF' => 'Roadmaster',
130
+ '1S9' => 'Saleen',
131
+ '177' => 'Thomas',
132
+ '1T8' => 'Thomas',
133
+ '1TU' => 'TMC',
134
+ '1V1' => 'Volkswagen',
135
+ '1VW' => 'Volkswagen',
136
+ '1WA' => 'Autostar',
137
+ '1WB' => 'Autostar',
138
+ '1WU' => 'White Volvo',
139
+ '1WV' => 'Winnebago',
140
+ '1XK' => 'Kenworth',
141
+ '1XM' => 'AMC',
142
+ '1XP' => 'Peterbilt',
143
+ '1Y1' => 'Chevrolet, Geo',
144
+ '1YV' => 'Mazda',
145
+ '1Z3' => 'Mitsubishi',
146
+ '1Z5' => 'Mitsubishi',
147
+ '1Z7' => 'Mitsubishi',
148
+ '1ZV' => 'Ford',
149
+ '1ZW' => 'Mercury',
150
+ '2A3' => 'Chrysler',
151
+ '2A4' => 'Chrysler',
152
+ '2A8' => 'Chrysler',
153
+ '2B1' => 'Orion',
154
+ '2B3' => 'Dodge',
155
+ '2B4' => 'Dodge',
156
+ '2B5' => 'Dodge',
157
+ '2B6' => 'Dodge',
158
+ '2B7' => 'Dodge',
159
+ '2B8' => 'Dodge',
160
+ '2BC' => 'AMC, Jeep',
161
+ '2C1' => 'Chevrolet, Geo',
162
+ '2C3' => 'Chrysler',
163
+ '2C4' => 'Chrysler',
164
+ '2C7' => 'Pontiac',
165
+ '2C8' => 'Chrysler',
166
+ '2CC' => 'AMC, Eagle',
167
+ '2CK' => 'Geo, Pontiac',
168
+ '2CM' => 'AMC',
169
+ '2CN' => 'Chevrolet, Geo',
170
+ '2D4' => 'Dodge',
171
+ '2D6' => 'Dodge',
172
+ '2D7' => 'Dodge',
173
+ '2D8' => 'Dodge',
174
+ '2E3' => 'Eagle',
175
+ '2FA' => 'Ford',
176
+ '2FD' => 'Ford',
177
+ '2FM' => 'Ford',
178
+ '2FT' => 'Ford',
179
+ '2FU' => 'Freightliner',
180
+ '2FV' => 'Freightliner',
181
+ '2FW' => 'Sterling',
182
+ '2FZ' => 'Sterling',
183
+ '2G0' => 'GMC',
184
+ '2G1' => 'Chevrolet',
185
+ '2G2' => 'Pontiac',
186
+ '2G3' => 'Oldsmobile',
187
+ '2G4' => 'BuickX',
188
+ '2G5' => 'GMC',
189
+ '2G7' => 'Pontiac',
190
+ '2G8' => 'Chevrolet',
191
+ '2GA' => 'Chevrolet',
192
+ '2GB' => 'Chevrolet',
193
+ '2GD' => 'GMC',
194
+ '2GJ' => 'GMC',
195
+ '2GK' => 'GMC',
196
+ '2GN' => 'Chevrolet',
197
+ '2GT' => 'GMC',
198
+ '2HG' => 'Honda',
199
+ '2HH' => 'Acura',
200
+ '2HJ' => 'Honda',
201
+ '2HK' => 'Honda',
202
+ '2HM' => 'Hyundai',
203
+ '2HN' => 'Acura',
204
+ '2HS' => 'International',
205
+ '2HT' => 'International',
206
+ '2J4' => 'Jeep',
207
+ '2LM' => 'Lincoln',
208
+ '2M2' => 'Mack',
209
+ '2ME' => 'Mercury',
210
+ '2MH' => 'Mercury',
211
+ '2MR' => 'Mercury',
212
+ '2NK' => 'Kenworth',
213
+ '2NP' => 'Peterbilt',
214
+ '2P3' => 'Plymouth',
215
+ '2P4' => 'Plymouth',
216
+ '2P5' => 'Plymouth',
217
+ '2P9' => 'Prevost',
218
+ '2PC' => 'Prevost',
219
+ '2S2' => 'Suzuki',
220
+ '2S3' => 'Suzuki',
221
+ '2T1' => 'Toyota',
222
+ '2T2' => 'Lexus',
223
+ '2WK' => 'Western Star Trucks',
224
+ '2WL' => 'Western Star Trucks',
225
+ '2XK' => 'Kenworth',
226
+ '2XM' => 'Eagle',
227
+ '2XP' => 'Peterbilt',
228
+ '3A4' => 'Chrysler',
229
+ '3A8' => 'Chrysler',
230
+ '3AB' => 'Dina',
231
+ '3AL' => 'Freightliner',
232
+ '3B3' => 'Dodge',
233
+ '3B4' => 'Dodge',
234
+ '3B6' => 'Dodge',
235
+ '3B7' => 'Dodge',
236
+ '3BK' => 'Kenworth',
237
+ '3BP' => 'Peterbilt',
238
+ '3C3' => 'Chrysler',
239
+ '3C4' => 'Chrysler',
240
+ '3C8' => 'Chrysler',
241
+ '3CA' => 'Chrysler',
242
+ '3D3' => 'Dodge',
243
+ '3D5' => 'Dodge',
244
+ '3D6' => 'Dodge',
245
+ '3D7' => 'Dodge',
246
+ '3FA' => 'Ford',
247
+ '3FC' => 'Ford',
248
+ '3FD' => 'Ford',
249
+ '3FE' => 'Ford, Freightliner',
250
+ '3FR' => 'Ford',
251
+ '3FT' => 'Ford',
252
+ '3G1' => 'Chevrolet',
253
+ '3G2' => 'Pontiac',
254
+ '3G4' => 'Buick',
255
+ '3G5' => 'Buick',
256
+ '3G7' => 'Pontiac',
257
+ '3GB' => 'Chevrolet',
258
+ '3GC' => 'Chevrolet',
259
+ '3GD' => 'GMC',
260
+ '3GE' => 'Chevrolet',
261
+ '3GK' => 'GMC',
262
+ '3GN' => 'Chevrolet',
263
+ '3GT' => 'GMC',
264
+ '3GY' => 'Cadillac',
265
+ '3HA' => 'International',
266
+ '3HG' => 'Honda',
267
+ '3HM' => 'Honda',
268
+ '3HS' => 'International',
269
+ '3HT' => 'International',
270
+ '3LN' => 'Lincoln',
271
+ '3MA' => 'Mercury',
272
+ '3ME' => 'Mercury',
273
+ '3N1' => 'Nissan',
274
+ '3NK' => 'Kenworth',
275
+ '3NM' => 'Peterbilt',
276
+ '3P3' => 'Plymouth',
277
+ '3TM' => 'Toyota',
278
+ '3VW' => 'Volkswagen',
279
+ '3WK' => 'Kenworth',
280
+ '45V' => 'Utilimaster',
281
+ '46G' => 'Gillig',
282
+ '49H' => 'Sterling',
283
+ '4A3' => 'Mitsubishi',
284
+ '4A4' => 'Mitsubishi',
285
+ '4B3' => 'Dodge',
286
+ '4C3' => 'Chrysler',
287
+ '4CD' => 'Oshkosh',
288
+ '4DR' => 'Genesis, International',
289
+ '4E3' => 'Eagle',
290
+ '4F2' => 'Mazda',
291
+ '4F4' => 'Mazda',
292
+ '4G1' => 'Chevrolet',
293
+ '4G2' => 'Pontiac',
294
+ '4GD' => 'GMC',
295
+ '4GT' => 'Isuzu, WhiteGMC',
296
+ '4JG' => 'Mercedes-Benz',
297
+ '4KB' => 'Chevrolet',
298
+ '4KD' => 'GMC',
299
+ '4KL' => 'Isuzu',
300
+ '4M2' => 'Mercury',
301
+ '4N1' => 'Nissan',
302
+ '4N2' => 'Nissan',
303
+ '4NU' => 'Isuzu',
304
+ '4P3' => 'Plymouth',
305
+ '4S1' => 'Isuzu',
306
+ '4S2' => 'Isuzu',
307
+ '4S3' => 'Subaru',
308
+ '4S4' => 'Subaru',
309
+ '4S6' => 'Honda',
310
+ '4S7' => 'Spartan',
311
+ '4SL' => 'Magnum',
312
+ '4T1' => 'Toyota',
313
+ '4T3' => 'Toyota',
314
+ '4TA' => 'Toyota',
315
+ '4US' => 'BMW',
316
+ '4UZ' => 'Freightliner',
317
+ '4V1' => 'Volvo, WhiteGMC',
318
+ '4V2' => 'Volvo, WhiteGMC',
319
+ '4V4' => 'Volvo, WhiteGMC',
320
+ '4V5' => 'Volvo, WhiteGMC',
321
+ '4VA' => 'Volvo',
322
+ '4VG' => 'Volvo, WhiteGMC',
323
+ '4VH' => 'Volvo',
324
+ '4VL' => 'Volvo',
325
+ '4VM' => 'Volvo',
326
+ '4VZ' => 'Spartan',
327
+ '5AS' => 'GEM',
328
+ '5B4' => 'Workhorse',
329
+ '5CK' => 'Western Star Trucks',
330
+ '5FN' => 'Honda',
331
+ '5FY' => 'New Flyer',
332
+ '5GA' => 'Buick',
333
+ '5GR' => 'Hummer',
334
+ '5GT' => 'Hummer',
335
+ '5GZ' => 'Saturn',
336
+ '5J6' => 'Honda',
337
+ '5J8' => 'Acura',
338
+ '5KJ' => 'Western Star Trucks',
339
+ '5KK' => 'Western Star Trucks',
340
+ '5LM' => 'Lincoln',
341
+ '5LT' => 'Lincoln',
342
+ '5N1' => 'Nissan',
343
+ '5N3' => 'Infiniti',
344
+ '5NM' => 'Hyundai',
345
+ '5NP' => 'Hyundai',
346
+ '5PV' => 'Hino',
347
+ '5S3' => 'Saab',
348
+ '5SX' => 'Amercian LeFrance',
349
+ '5T4' => 'Workhorse',
350
+ '5TB' => 'Toyota',
351
+ '5TD' => 'Toyota',
352
+ '5TE' => 'Toyota',
353
+ '5TF' => 'Toyota',
354
+ '5UM' => 'BMW',
355
+ '5UX' => 'BMW',
356
+ '5Y2' => 'Pontiac',
357
+ '6G2' => 'Pontiac',
358
+ '6MM' => 'Mitsubishi',
359
+ '6MP' => 'Mercury',
360
+ '9BF' => 'Ford',
361
+ '9BW' => 'Volkswagen',
362
+ '9DW' => 'Volkswagen',
363
+ 'J81' => 'Chevrolet,Geo',
364
+ 'J87' => 'Isuzu',
365
+ 'J8B' => 'Chevrolet',
366
+ 'J8D' => 'GMC',
367
+ 'J8Z' => 'Chevrolet',
368
+ 'JA3' => 'Mitsubishi',
369
+ 'JA4' => 'Mitsubishi',
370
+ 'JA7' => 'Mitsubishi',
371
+ 'JAA' => 'Isuzu',
372
+ 'JAB' => 'Isuzu',
373
+ 'JAC' => 'Isuzu',
374
+ 'JAE' => 'Acura',
375
+ 'JAL' => 'Isuzu',
376
+ 'JB3' => 'Dodge',
377
+ 'JB4' => 'Dodge',
378
+ 'JB7' => 'Dodge',
379
+ 'JC2' => 'Ford',
380
+ 'JD1' => 'Daihatsu',
381
+ 'JD2' => 'Daihatsu',
382
+ 'JE3' => 'Eagle',
383
+ 'JF1' => 'Subaru',
384
+ 'JF2' => 'Subaru',
385
+ 'JF3' => 'Subaru',
386
+ 'JF4' => 'Saab',
387
+ 'JG1' => 'Chevrolet, Geo',
388
+ 'JG7' => 'Pontiac',
389
+ 'JGC' => 'Geo',
390
+ 'JH4' => 'Acura',
391
+ 'JHB' => 'Hino',
392
+ 'JHL' => 'Honda',
393
+ 'JHM' => 'Honda',
394
+ 'JJ3' => 'Chrysler',
395
+ 'JL6' => 'Mitsubishi',
396
+ 'JLS' => 'Sterling',
397
+ 'JM1' => 'Mazda',
398
+ 'JM2' => 'Mazda',
399
+ 'JM3' => 'Mazda',
400
+ 'JN1' => 'Datsun, Nissan',
401
+ 'JN3' => 'Nissan',
402
+ 'JN4' => 'Nissan',
403
+ 'JN6' => 'Datsun, Nissan',
404
+ 'JN8' => 'Nissan',
405
+ 'JNA' => 'Nissan',
406
+ 'JNK' => 'Infiniti',
407
+ 'JNR' => 'Infiniti',
408
+ 'JNX' => 'Infiniti',
409
+ 'JP3' => 'Plymouth',
410
+ 'JP4' => 'Plymouth',
411
+ 'JP7' => 'Plymouth',
412
+ 'JR2X' => 'Isuzu',
413
+ 'JS2' => 'Suzuki',
414
+ 'JS3' => 'Suzuki',
415
+ 'JS4' => 'Suzuki',
416
+ 'JT2' => 'Toyota',
417
+ 'JT3' => 'Toyota',
418
+ 'JT4' => 'Toyota',
419
+ 'JT5' => 'Toyota',
420
+ 'JT6' => 'Lexus',
421
+ 'JT8' => 'Lexus',
422
+ 'JTD' => 'Toyota',
423
+ 'JTE' => 'Toyota',
424
+ 'JTH' => 'Lexus',
425
+ 'JTJ' => 'Lexus',
426
+ 'JTK' => 'Scion',
427
+ 'JTL' => 'Scion',
428
+ 'JTM' => 'Toyota',
429
+ 'JTN' => 'Toyota',
430
+ 'JW6' => 'Mitsubishi',
431
+ 'JW7' => 'Mitsubishi',
432
+ 'KL1' => 'Chevrolet',
433
+ 'KL2' => 'Pontiac',
434
+ 'KL5' => 'Suzuki',
435
+ 'KL7' => 'Asuna',
436
+ 'KLA' => 'Daewoo',
437
+ 'KM8' => 'Hyundai',
438
+ 'KMF' => 'Hyundai',
439
+ 'KMH' => 'Hyundai',
440
+ 'KNA' => 'Kia',
441
+ 'KND' => 'Hyundai, Kia',
442
+ 'KNJ' => 'Ford',
443
+ 'KPH' => 'Mitsubishi',
444
+ 'LES' => 'Isuzu',
445
+ 'LM5' => 'Isuzu',
446
+ 'ML3' => 'Dodge',
447
+ 'SA9' => 'Morgan',
448
+ 'SAJ' => 'Jaguar',
449
+ 'SAL' => 'Land Rover',
450
+ 'SAT' => 'Triumph',
451
+ 'SAX' => 'Sterling',
452
+ 'SCA' => 'Rolls-Royce',
453
+ 'SCB' => 'Bentley',
454
+ 'SCC' => 'Lotus',
455
+ 'SCF' => 'Aston Martin',
456
+ 'SDL' => 'TVR Engineering',
457
+ 'SHH' => 'Honda',
458
+ 'SHS' => 'Honda',
459
+ 'SJN' => 'Nissan UK',
460
+ 'TRU' => 'Audi',
461
+ 'VF1' => 'Renault',
462
+ 'VF7' => 'Citroën',
463
+ 'VF3' => 'Peugeot',
464
+ 'VG6' => 'Mack',
465
+ 'VSS' => 'Seat',
466
+ 'W06' => 'Cadillac',
467
+ 'WA1' => 'Audi',
468
+ 'WAU' => 'Audi',
469
+ 'WBA' => 'BMW',
470
+ 'WBS' => 'BMW',
471
+ 'WBX' => 'BMW',
472
+ 'WD0' => 'Dodge',
473
+ 'WD1' => 'Dodge',
474
+ 'WD2' => 'Dodge',
475
+ 'WD5' => 'Dodge',
476
+ 'WD8' => 'Dodge',
477
+ 'WDB' => 'Maybach, Mercedes-Benz',
478
+ 'WDC' => 'Mercedes-Benz',
479
+ 'WDD' => 'Mercedes-Benz',
480
+ 'WDP' => 'Dodge',
481
+ 'WDX' => 'Dodge',
482
+ 'WDY' => 'Dodge',
483
+ 'WF1' => 'Merkur',
484
+ 'WKK' => 'Fahrzeugwerke',
485
+ 'WME' => 'Mercedes-Benz',
486
+ 'WMW' => 'Mini',
487
+ 'WP0' => 'Porsche',
488
+ 'WP1' => 'Porsche',
489
+ 'WUA' => 'Audi',
490
+ 'WV2' => 'Volkswagen',
491
+ 'WV3' => 'Volkswagen',
492
+ 'WVG' => 'Volkswagen',
493
+ 'WVW' => 'Volkswagen',
494
+ 'XTA' => 'Lada',
495
+ 'YB3' => 'Volvo',
496
+ 'YS3' => 'Saab',
497
+ 'YV1' => 'Volvo',
498
+ 'YV2' => 'Volvo',
499
+ 'YV4' => 'Volvo',
500
+ 'YV5' => 'Volvo',
501
+ 'ZA9' => 'Lamborghini',
502
+ 'ZAM' => 'Maserati',
503
+ 'ZAR' => 'Alfa Romeo',
504
+ 'ZC2' => 'Chrysler',
505
+ 'ZFA' => 'Fiat',
506
+ 'ZFF' => 'Ferrari',
507
+ 'ZHWX' => 'Lamborghini',
508
+ }
161
509
 
162
- COUNTRY_MATCHER = PrefixMatcher.new COUNTRIES
163
- MANUFACTURER_MATCHER = PrefixMatcher.new MANUFACTURERS
510
+ COUNTRY_MATCHER = PrefixMatcher.new COUNTRIES
511
+ MANUFACTURER_MATCHER = PrefixMatcher.new MANUFACTURERS
164
512
 
165
- def self.country_for(vin)
166
- COUNTRY_MATCHER.find vin
167
- end
513
+ def self.country_for(vin)
514
+ COUNTRY_MATCHER.find vin
515
+ end
168
516
 
169
- def self.manufacturer_for(vin)
170
- MANUFACTURER_MATCHER.find vin
171
- end
172
- end
517
+ def self.country_prefixes_for(country_name)
518
+ COUNTRIES.select{ |k, name| name == country_name }.keys
519
+ end
520
+
521
+ def self.manufacturer_for(vin)
522
+ MANUFACTURER_MATCHER.find vin
523
+ end
524
+
525
+ def self.manufacturer_prefixes_for(manufacturer_name)
526
+ MANUFACTURERS.select{ |k, name| name == manufacturer_name }.keys
527
+ end
528
+ end
173
529
  end
data/spec/dsl_spec.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'vindsl/dsl'
2
+
3
+ describe Vindsl::DSL do
4
+ let(:scarlet){ '1ZVBP8AM7C5280000' }
5
+ let(:yellow){ 'JA3AY11A2VU000000' }
6
+ subject do
7
+ Vindsl::DSL.new do |vin|
8
+ vin.country = 'United States'
9
+ vin.manufacturer = 'Ford'
10
+ vin.model_year = 2012
11
+ end
12
+ end
13
+
14
+ it 'provides a VIN regexp' do
15
+ expect(scarlet).to match subject.regexp
16
+ expect(yellow).to_not match subject.regexp
17
+ end
18
+
19
+ it 'provides a WMI regexp' do
20
+ expect(scarlet[0..3]).to match subject.wmi_regexp
21
+ expect(yellow[0..3]).to_not match subject.wmi_regexp
22
+ end
23
+ end
data/spec/vin_spec.rb CHANGED
@@ -18,4 +18,21 @@ describe Vindsl::VIN do
18
18
  expect(subject.model_year).to eq 2012
19
19
  end
20
20
  end
21
+
22
+ describe "The old yellow car" do
23
+ let(:yellow){ 'JA3AY11A2VU000000' }
24
+ subject{ described_class.new yellow }
25
+
26
+ it 'looks up the correct country of origin' do
27
+ expect(subject.country).to eq 'Japan'
28
+ end
29
+
30
+ it 'looks up the correct manufacturer' do
31
+ expect(subject.manufacturer).to eq 'Mitsubishi'
32
+ end
33
+
34
+ it 'looks up the correct model year' do
35
+ expect(subject.model_year).to eq 1997
36
+ end
37
+ end
21
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vindsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryce Kerley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-12 00:00:00.000000000 Z
11
+ date: 2014-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -67,10 +67,12 @@ files:
67
67
  - Rakefile
68
68
  - lib/vindsl.rb
69
69
  - lib/vindsl/alphabet.rb
70
+ - lib/vindsl/dsl.rb
70
71
  - lib/vindsl/prefix_matcher.rb
71
72
  - lib/vindsl/version.rb
72
73
  - lib/vindsl/vin.rb
73
74
  - lib/vindsl/wmi.rb
75
+ - spec/dsl_spec.rb
74
76
  - spec/prefix_matcher_spec.rb
75
77
  - spec/spec_helper.rb
76
78
  - spec/vin_spec.rb
@@ -100,6 +102,7 @@ signing_key:
100
102
  specification_version: 4
101
103
  summary: Vehicle Information Number gem
102
104
  test_files:
105
+ - spec/dsl_spec.rb
103
106
  - spec/prefix_matcher_spec.rb
104
107
  - spec/spec_helper.rb
105
108
  - spec/vin_spec.rb