sipp 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/lib/sipp/code.rb +29 -7
- data/lib/sipp/dictionary.rb +18 -1
- data/lib/sipp/version.rb +1 -1
- data/lib/sipp.rb +1 -1
- data/sipp.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afc06bf3d738f114978538c4871eb471445325d3
|
4
|
+
data.tar.gz: 1622501a3713dc46419d4ab9bd3df6ccddf88f43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5482401382b1cb73967fd3d3b14b557c0fab803581adc2b6f8e4606c0078435452171337e4224297d15d852a515365f80c2d81b617707cee152e3daf34ba81ae
|
7
|
+
data.tar.gz: e1db25fff8d9692e97f566891c35e9c001c772697fe3ed572290f19e6b2d176da6344bc846559eb2d4672fc8a891b41ed611803fe478e99b2678f48cf7098042
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -33,7 +33,7 @@ Calling `code.validate!` will throw validation errors with exceptions.
|
|
33
33
|
## TODO
|
34
34
|
- add pseudo codes
|
35
35
|
- add van codes
|
36
|
-
- add i18n helpers
|
36
|
+
- add i18n helpers or redo strings into symbols to be i18n-ised
|
37
37
|
- add query methods for common checks (like `.diesel?` etc)
|
38
38
|
|
39
39
|
|
data/lib/sipp/code.rb
CHANGED
@@ -7,7 +7,7 @@ module SIPP
|
|
7
7
|
attr_reader :code
|
8
8
|
|
9
9
|
def initialize(code = nil)
|
10
|
-
@code = code.to_s.upcase
|
10
|
+
@code = code.to_s.strip.upcase
|
11
11
|
|
12
12
|
end
|
13
13
|
|
@@ -15,13 +15,13 @@ module SIPP
|
|
15
15
|
validate_code &&
|
16
16
|
validate_category &&
|
17
17
|
validate_type &&
|
18
|
-
|
18
|
+
validate_transmission_drive &&
|
19
19
|
validate_fuel_ac
|
20
20
|
end
|
21
21
|
|
22
22
|
def valid?
|
23
23
|
validate!
|
24
|
-
rescue CodeError, CategoryError, TypeError,
|
24
|
+
rescue CodeError, CategoryError, TypeError, TransmissionDriveError, FuelACError
|
25
25
|
false
|
26
26
|
end
|
27
27
|
|
@@ -33,10 +33,32 @@ module SIPP
|
|
33
33
|
TYPE[code[1]] if valid?
|
34
34
|
end
|
35
35
|
|
36
|
+
def transmission_drive
|
37
|
+
TRANSMISSION_DRIVE[code[2]] if valid?
|
38
|
+
end
|
39
|
+
|
36
40
|
def transmission
|
37
41
|
TRANSMISSION[code[2]] if valid?
|
38
42
|
end
|
39
43
|
|
44
|
+
def transmission_manual?
|
45
|
+
if valid?
|
46
|
+
'Manual' == transmission ? true : false # TODO fix magic string
|
47
|
+
else
|
48
|
+
nil
|
49
|
+
end
|
50
|
+
end
|
51
|
+
def transmission_auto?
|
52
|
+
if valid?
|
53
|
+
'Auto' == transmission ? true : false # TODO fix magic string
|
54
|
+
else
|
55
|
+
nil
|
56
|
+
end
|
57
|
+
end
|
58
|
+
def drive
|
59
|
+
DRIVE[code[2]] if valid?
|
60
|
+
end
|
61
|
+
|
40
62
|
def fuel_ac
|
41
63
|
FUEL_AC[code[3]] if valid?
|
42
64
|
end
|
@@ -58,7 +80,7 @@ module SIPP
|
|
58
80
|
end
|
59
81
|
|
60
82
|
def to_s
|
61
|
-
[category, type,
|
83
|
+
[category, type, transmission_drive, fuel_ac].join(' - ')
|
62
84
|
end
|
63
85
|
|
64
86
|
private
|
@@ -87,9 +109,9 @@ module SIPP
|
|
87
109
|
end
|
88
110
|
end
|
89
111
|
|
90
|
-
def
|
91
|
-
if @code[2].blank? || !
|
92
|
-
raise
|
112
|
+
def validate_transmission_drive
|
113
|
+
if @code[2].blank? || !TRANSMISSION_DRIVE.keys.include?(@code[2])
|
114
|
+
raise TransmissionDriveError, :invalid_transmission_drive
|
93
115
|
else
|
94
116
|
true
|
95
117
|
end
|
data/lib/sipp/dictionary.rb
CHANGED
@@ -46,7 +46,7 @@ module SIPP
|
|
46
46
|
'K' => 'Commercial Van/Truck',
|
47
47
|
}
|
48
48
|
|
49
|
-
|
49
|
+
TRANSMISSION_DRIVE = {
|
50
50
|
'M' => 'Manual Unspecified Drive',
|
51
51
|
'N' => 'Manual 4WD',
|
52
52
|
'C' => 'Manual AWD',
|
@@ -54,6 +54,23 @@ module SIPP
|
|
54
54
|
'B' => 'Auto 4WD',
|
55
55
|
'D' => 'Auto AWD',
|
56
56
|
}
|
57
|
+
TRANSMISSION = {
|
58
|
+
'M' => 'Manual',
|
59
|
+
'N' => 'Manual',
|
60
|
+
'C' => 'Manual',
|
61
|
+
'A' => 'Auto',
|
62
|
+
'B' => 'Auto',
|
63
|
+
'D' => 'Auto',
|
64
|
+
}
|
65
|
+
|
66
|
+
DRIVE = {
|
67
|
+
'M' => 'Unspecified',
|
68
|
+
'N' => '4WD',
|
69
|
+
'C' => 'AWD',
|
70
|
+
'A' => 'Unspecified',
|
71
|
+
'B' => '4WD',
|
72
|
+
'D' => 'AWD',
|
73
|
+
}
|
57
74
|
|
58
75
|
FUEL_AC = {
|
59
76
|
'R' => 'Unspecified Fuel/Power With Air',
|
data/lib/sipp/version.rb
CHANGED
data/lib/sipp.rb
CHANGED
@@ -5,7 +5,7 @@ module SIPP
|
|
5
5
|
class CodeError < StandardError; end
|
6
6
|
class CategoryError < StandardError; end
|
7
7
|
class TypeError < StandardError; end
|
8
|
-
class
|
8
|
+
class TransmissionDriveError < StandardError; end
|
9
9
|
class FuelACError < StandardError; end
|
10
10
|
# Your code goes here...
|
11
11
|
end
|
data/sipp.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sipp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Buslaev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '4.1'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '4.1'
|
69
69
|
description: Translates car SIPP codes into something meaningful
|
70
70
|
email:
|
71
71
|
- max@buslaev.net
|