vindetta 0.23.0 → 0.24.0

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: 431f60cb9e88b478d17ac6364e430add13aae1aa
4
- data.tar.gz: 744ed0e12ac60ca9d2ec5f099120a82b1c702c2d
3
+ metadata.gz: ad6e970871eb591e0f430b78fe2940201dedd0e7
4
+ data.tar.gz: 38c7548b9a5a98507205f998176db995f659aa35
5
5
  SHA512:
6
- metadata.gz: be530f83c70f9d5ca9626596e0b01ee2760da8981fc9ea2a2d0ecd02ab462c3615c01fa87497dc886a5d2ea5b6f1e5823cf05419305fcf9999adb377e2f13e36
7
- data.tar.gz: 824a3482af1ace05096c5742f8266c46323fb62911230acc79268b829b29e31325ead79b8a92825027c95edb66eed5e86e8c2cff2127cc519a9d61678985dde0
6
+ metadata.gz: d29396ef25dfea7edde00fecfe8ea48f0497f0ddb9a041da5bab0f24df4213c1b1f68fe1133c8250b8002f3fea269afd30f604959584f79009337c477c7b792e
7
+ data.tar.gz: 96872e1404a6ec1d0863cb0ba5d2e5966db0dde38e4b837274829fc74a14f232a862ca4a35caf87b9f307abf2d93d1637b8f5d63f70ee986438b5fd35da7a647
data/exe/vindetta CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require "vindetta"
4
4
 
5
- Vindetta::CLI.run(ARGV)
5
+ exit Vindetta::CLI.run(ARGV)
data/lib/vindetta/cli.rb CHANGED
@@ -13,7 +13,7 @@ module Vindetta
13
13
  version Vindetta::VERSION
14
14
 
15
15
  desc "Validates a VIN"
16
-
16
+
17
17
  command %i[validate v] do |c|
18
18
  c.action do |_global, _options, args|
19
19
  vin = args.first
@@ -1,5 +1,9 @@
1
1
  module Vindetta
2
2
  class Decoder
3
+ BASE_MODEL_YEAR = 1980
4
+ ALPHA = ('A'..'Z').to_a
5
+ NUMERIC = ("0".."9").to_a
6
+
3
7
  def self.vin(vin)
4
8
  {
5
9
  :plant_code => vin[PLANT_CODE_INDEX],
@@ -13,16 +17,12 @@ module Vindetta
13
17
  private
14
18
 
15
19
  def self.model_year(vin)
16
- @years ||= YAML.load_file(File.expand_path("../data/vis.yaml", __FILE__))["year"]
17
- @alpha ||= "ABCDEFGHJKLMNPRSTUVWXYZ".chars
18
-
19
- tenth = vin[9]
20
- seventh = vin[6]
20
+ index = ((ALPHA - %w[I O Q U Z]) + (NUMERIC - %w[0])).find_index { |c| c == vin[9] }
21
21
 
22
- if @alpha.include?(seventh)
23
- @years[tenth].last
22
+ if ALPHA.include?(vin[6])
23
+ BASE_MODEL_YEAR + index + 30
24
24
  else
25
- @years[tenth].first
25
+ BASE_MODEL_YEAR + index
26
26
  end
27
27
  end
28
28
  end
@@ -21,8 +21,8 @@ module Vindetta
21
21
 
22
22
  def self.vis(_options = {})
23
23
  [
24
- VIS_CHARACTERS.sample(VIS_LENGTH - 1),
25
- MODEL_YEAR_CHARACTERS.sample
24
+ MODEL_YEAR_CHARACTERS.sample,
25
+ VIS_CHARACTERS.sample(VIS_LENGTH - 1)
26
26
  ].flatten.join("")
27
27
  end
28
28
  end
@@ -1,3 +1,3 @@
1
1
  module Vindetta
2
- VERSION = "0.23.0".freeze
2
+ VERSION = "0.24.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vindetta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.0
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Decot
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-22 00:00:00.000000000 Z
11
+ date: 2018-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli
@@ -161,7 +161,6 @@ files:
161
161
  - lib/vindetta.rb
162
162
  - lib/vindetta/calculator.rb
163
163
  - lib/vindetta/cli.rb
164
- - lib/vindetta/data/vis.yaml
165
164
  - lib/vindetta/data/wmi.yaml
166
165
  - lib/vindetta/decoder.rb
167
166
  - lib/vindetta/generator.rb
@@ -1,93 +0,0 @@
1
- ---
2
-
3
- year:
4
- A:
5
- - 1980
6
- - 2010
7
- B:
8
- - 1981
9
- - 2011
10
- C:
11
- - 1982
12
- - 2012
13
- D:
14
- - 1983
15
- - 2013
16
- E:
17
- - 1984
18
- - 2014
19
- F:
20
- - 1985
21
- - 2015
22
- G:
23
- - 1986
24
- - 2016
25
- H:
26
- - 1987
27
- - 2017
28
- J:
29
- - 1988
30
- - 2018
31
- K:
32
- - 1989
33
- - 2019
34
- L:
35
- - 1990
36
- - 2020
37
- M:
38
- - 1991
39
- - 2021
40
- N:
41
- - 1992
42
- - 2022
43
- P:
44
- - 1993
45
- - 2023
46
- R:
47
- - 1994
48
- - 2024
49
- S:
50
- - 1995
51
- - 2025
52
- T:
53
- - 1996
54
- - 2026
55
- V:
56
- - 1997
57
- - 2027
58
- W:
59
- - 1998
60
- - 2028
61
- X:
62
- - 1999
63
- - 2029
64
- Y:
65
- - 2000
66
- - 2030
67
- "1":
68
- - 2001
69
- - 2031
70
- "2":
71
- - 2002
72
- - 2032
73
- "3":
74
- - 2003
75
- - 2033
76
- "4":
77
- - 2004
78
- - 2034
79
- "5":
80
- - 2005
81
- - 2035
82
- "6":
83
- - 2006
84
- - 2036
85
- "7":
86
- - 2007
87
- - 2037
88
- "8":
89
- - 2008
90
- - 2038
91
- "9":
92
- - 2009
93
- - 2039