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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e823ae979f2ceef4999a253bf86f204dec06313e
4
- data.tar.gz: fd26206453b273c66c0fed4eddfa6d675be7d8a8
3
+ metadata.gz: afc06bf3d738f114978538c4871eb471445325d3
4
+ data.tar.gz: 1622501a3713dc46419d4ab9bd3df6ccddf88f43
5
5
  SHA512:
6
- metadata.gz: f3661ba71eec6117c0056b3e1ffc124ffcdfb64d24e19542bdb66d5564f03113d70720b5eec6303503ff4512e90c6c4c10f0d858a70d9ffd74ce726cceb6e1c8
7
- data.tar.gz: 20c4cb082839d425516cd5d21abb955a883a0fc64cf92d61dd01b20e9510e3f49c28fb3e67b380ae1402484e0449ec9990649c8712b6b1842b1885bc850fdc82
6
+ metadata.gz: 5482401382b1cb73967fd3d3b14b557c0fab803581adc2b6f8e4606c0078435452171337e4224297d15d852a515365f80c2d81b617707cee152e3daf34ba81ae
7
+ data.tar.gz: e1db25fff8d9692e97f566891c35e9c001c772697fe3ed572290f19e6b2d176da6344bc846559eb2d4672fc8a891b41ed611803fe478e99b2678f48cf7098042
data/Gemfile CHANGED
@@ -5,4 +5,4 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
5
5
  # Specify your gem's dependencies in sipp.gemspec
6
6
  gemspec
7
7
 
8
- gem 'activesupport', '~> 3.0'
8
+ gem 'activesupport', '~> 4.1'
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
- validate_transmission &&
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, TransmissionError, FuelACError
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, transmission, fuel_ac].join(' - ')
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 validate_transmission
91
- if @code[2].blank? || !TRANSMISSION.keys.include?(@code[2])
92
- raise TransmissionError, :invalid_transmission
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
@@ -46,7 +46,7 @@ module SIPP
46
46
  'K' => 'Commercial Van/Truck',
47
47
  }
48
48
 
49
- TRANSMISSION = {
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
@@ -1,3 +1,3 @@
1
1
  module SIPP
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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 TransmissionError < StandardError; end
8
+ class TransmissionDriveError < StandardError; end
9
9
  class FuelACError < StandardError; end
10
10
  # Your code goes here...
11
11
  end
data/sipp.gemspec CHANGED
@@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "rake", "~> 10.0"
28
28
  spec.add_development_dependency "rspec", "~> 3.0"
29
29
 
30
- spec.add_dependency "activesupport", "~> 3.0"
30
+ spec.add_dependency "activesupport", "~> 4.1"
31
31
  end
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.0
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-30 00:00:00.000000000 Z
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: '3.0'
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: '3.0'
68
+ version: '4.1'
69
69
  description: Translates car SIPP codes into something meaningful
70
70
  email:
71
71
  - max@buslaev.net