sipp 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e823ae979f2ceef4999a253bf86f204dec06313e
4
+ data.tar.gz: fd26206453b273c66c0fed4eddfa6d675be7d8a8
5
+ SHA512:
6
+ metadata.gz: f3661ba71eec6117c0056b3e1ffc124ffcdfb64d24e19542bdb66d5564f03113d70720b5eec6303503ff4512e90c6c4c10f0d858a70d9ffd74ce726cceb6e1c8
7
+ data.tar.gz: 20c4cb082839d425516cd5d21abb955a883a0fc64cf92d61dd01b20e9510e3f49c28fb3e67b380ae1402484e0449ec9990649c8712b6b1842b1885bc850fdc82
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.idea/
3
+ /.yardoc
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.3.3
7
+ before_install: gem install bundler -v 1.17.3
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at max@buslaev.net. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in sipp.gemspec
6
+ gemspec
7
+
8
+ gem 'activesupport', '~> 3.0'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Max Buslaev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # Sipp
2
+
3
+ A simple wrapper to decode [SIPP/ACRISS](https://www.acriss.org/car-codes/) car codes.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'sipp'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install sipp
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ code = SIPP::Code.new 'CCMN'
25
+ code.to_s # "Compact - 2/4 Door - Manual Unspecified Drive - Unspecified Fuel/Power Without Air"
26
+
27
+ code.ac? # false
28
+ ```
29
+ If the code is invalid, it will return `nil` on all checks.
30
+
31
+ Calling `code.validate!` will throw validation errors with exceptions.
32
+
33
+ ## TODO
34
+ - add pseudo codes
35
+ - add van codes
36
+ - add i18n helpers
37
+ - add query methods for common checks (like `.diesel?` etc)
38
+
39
+
40
+ ## Development
41
+
42
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
43
+
44
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
45
+
46
+ ## Contributing
47
+
48
+ Bug reports and pull requests are welcome on GitHub at https://github.com/austerlitz/sipp. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
49
+
50
+ ## License
51
+
52
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
53
+
54
+ ## Code of Conduct
55
+
56
+ Everyone interacting in the Sipp project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/austerlitz/sipp/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "sipp"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/sipp/code.rb ADDED
@@ -0,0 +1,106 @@
1
+ require 'sipp/dictionary'
2
+
3
+ module SIPP
4
+ class Code
5
+ include Dictionary
6
+
7
+ attr_reader :code
8
+
9
+ def initialize(code = nil)
10
+ @code = code.to_s.upcase
11
+
12
+ end
13
+
14
+ def validate!
15
+ validate_code &&
16
+ validate_category &&
17
+ validate_type &&
18
+ validate_transmission &&
19
+ validate_fuel_ac
20
+ end
21
+
22
+ def valid?
23
+ validate!
24
+ rescue CodeError, CategoryError, TypeError, TransmissionError, FuelACError
25
+ false
26
+ end
27
+
28
+ def category
29
+ CATEGORY[code[0]] if valid?
30
+ end
31
+
32
+ def type
33
+ TYPE[code[1]] if valid?
34
+ end
35
+
36
+ def transmission
37
+ TRANSMISSION[code[2]] if valid?
38
+ end
39
+
40
+ def fuel_ac
41
+ FUEL_AC[code[3]] if valid?
42
+ end
43
+
44
+ def fuel
45
+ FUEL[code[3]] if valid?
46
+ end
47
+
48
+ def ac
49
+ AC[code[3]] if valid?
50
+ end
51
+
52
+ def ac?
53
+ if valid?
54
+ 'Air' == ac ? true : false # TODO fix magic string
55
+ else
56
+ nil
57
+ end
58
+ end
59
+
60
+ def to_s
61
+ [category, type, transmission, fuel_ac].join(' - ')
62
+ end
63
+
64
+ private
65
+
66
+ def validate_code
67
+ if @code.blank? || 4 != @code.length
68
+ raise CodeError, :invalid_code
69
+ else
70
+ true
71
+ end
72
+ end
73
+
74
+ def validate_category
75
+ if @code[0].blank? || !CATEGORY.keys.include?(@code[0])
76
+ raise CategoryError, :invalid_category
77
+ else
78
+ true
79
+ end
80
+ end
81
+
82
+ def validate_type
83
+ if @code[1].blank? || !TYPE.keys.include?(@code[1])
84
+ raise TypeError, :invalid_type
85
+ else
86
+ true
87
+ end
88
+ end
89
+
90
+ def validate_transmission
91
+ if @code[2].blank? || !TRANSMISSION.keys.include?(@code[2])
92
+ raise TransmissionError, :invalid_transmission
93
+ else
94
+ true
95
+ end
96
+ end
97
+
98
+ def validate_fuel_ac
99
+ if @code[3].blank? || !FUEL_AC.keys.include?(@code[3])
100
+ raise FuelACError, :invalid_fuel_ac
101
+ else
102
+ true
103
+ end
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,122 @@
1
+ module SIPP
2
+ module Dictionary
3
+ CATEGORY = {
4
+ 'M' => 'Mini',
5
+ 'N' => 'Mini Elite',
6
+ 'E' => 'Economy',
7
+ 'H' => 'Economy Elite',
8
+ 'C' => 'Compact',
9
+ 'D' => 'Compact Elite',
10
+ 'I' => 'Intermediate',
11
+ 'J' => 'Intermediate Elite',
12
+ 'S' => 'Standard',
13
+ 'R' => 'Standard Elite',
14
+ 'F' => 'Fullsize',
15
+ 'G' => 'Fullsize Elite',
16
+ 'P' => 'Premium',
17
+ 'U' => 'Premium Elite',
18
+ 'L' => 'Luxury',
19
+ 'W' => 'Luxury Elite',
20
+ 'O' => 'Oversize',
21
+ 'X' => 'Special',
22
+ }
23
+
24
+ TYPE = {
25
+ 'B' => '2-3 Door',
26
+ 'C' => '2/4 Door',
27
+ 'D' => '4-5 Door',
28
+ 'W' => 'Wagon/Estate',
29
+ 'V' => 'Passenger Van',
30
+ 'L' => 'Limousine/Sedan',
31
+ 'S' => 'Sport',
32
+ 'T' => 'Convertible',
33
+ 'F' => 'SUV',
34
+ 'J' => 'Open Air All Terrain',
35
+ 'X' => 'Special',
36
+ 'P' => 'Pick up (single/extended cab) 2 door',
37
+ 'Q' => 'Pick up (double cab) 4 door',
38
+ 'Z' => 'Special Offer Car',
39
+ 'E' => 'Coupe',
40
+ 'M' => 'Monospace',
41
+ 'R' => 'Recreational Vehicle',
42
+ 'H' => 'Motor Home',
43
+ 'Y' => '2 Wheel Vehicle',
44
+ 'N' => 'Roadster',
45
+ 'G' => 'Crossover',
46
+ 'K' => 'Commercial Van/Truck',
47
+ }
48
+
49
+ TRANSMISSION = {
50
+ 'M' => 'Manual Unspecified Drive',
51
+ 'N' => 'Manual 4WD',
52
+ 'C' => 'Manual AWD',
53
+ 'A' => 'Auto Unspecified Drive',
54
+ 'B' => 'Auto 4WD',
55
+ 'D' => 'Auto AWD',
56
+ }
57
+
58
+ FUEL_AC = {
59
+ 'R' => 'Unspecified Fuel/Power With Air',
60
+ 'N' => 'Unspecified Fuel/Power Without Air',
61
+ 'D' => 'Diesel Air',
62
+ 'Q' => 'Diesel No Air',
63
+ 'H' => 'Hybrid Air',
64
+ 'I' => 'Hybrid Plug in Air',
65
+ 'E' => 'Electric (Distance < 250mi/400km) Air',
66
+ 'C' => 'Electric Plus (Distance ≥ 250mi/400km) Air',
67
+ 'L' => 'LPG/Compressed Gas Air',
68
+ 'S' => 'LPG/Compressed Gas No Air',
69
+ 'A' => 'Hydrogen Air',
70
+ 'B' => 'Hydrogen No Air',
71
+ 'M' => 'Multi Fuel/Power Air',
72
+ 'F' => 'Multi fuel/power No Air',
73
+ 'V' => 'Petrol Air',
74
+ 'Z' => 'Petrol No Air',
75
+ 'U' => 'Ethanol Air',
76
+ 'X' => 'Ethanol No Air',
77
+ }
78
+
79
+ FUEL = {
80
+ 'R' => 'Unspecified Fuel/Power',
81
+ 'N' => 'Unspecified Fuel/Power',
82
+ 'D' => 'Diesel',
83
+ 'Q' => 'Diesel',
84
+ 'H' => 'Hybrid',
85
+ 'I' => 'Hybrid Plug in',
86
+ 'E' => 'Electric (Distance < 250mi/400km)',
87
+ 'C' => 'Electric Plus (Distance ≥ 250mi/400km)',
88
+ 'L' => 'LPG/Compressed Gas',
89
+ 'S' => 'LPG/Compressed Gas',
90
+ 'A' => 'Hydrogen',
91
+ 'B' => 'Hydrogen',
92
+ 'M' => 'Multi Fuel/Power',
93
+ 'F' => 'Multi fuel/power',
94
+ 'V' => 'Petrol',
95
+ 'Z' => 'Petrol',
96
+ 'U' => 'Ethanol',
97
+ 'X' => 'Ethanol',
98
+ }
99
+
100
+ AC = {
101
+ 'R' => 'Air',
102
+ 'N' => 'No Air',
103
+ 'D' => 'Air',
104
+ 'Q' => 'No Air',
105
+ 'H' => 'Air',
106
+ 'I' => 'Air',
107
+ 'E' => 'Air',
108
+ 'C' => 'Air',
109
+ 'L' => 'Air',
110
+ 'S' => 'No Air',
111
+ 'A' => 'Air',
112
+ 'B' => 'No Air',
113
+ 'M' => 'Air',
114
+ 'F' => 'No Air',
115
+ 'V' => 'Air',
116
+ 'Z' => 'No Air',
117
+ 'U' => 'Air',
118
+ 'X' => 'No Air',
119
+ }
120
+ end
121
+ end
122
+
@@ -0,0 +1,3 @@
1
+ module SIPP
2
+ VERSION = "0.1.0"
3
+ end
data/lib/sipp.rb ADDED
@@ -0,0 +1,15 @@
1
+ require "sipp/version"
2
+
3
+ module SIPP
4
+ class Error < StandardError; end
5
+ class CodeError < StandardError; end
6
+ class CategoryError < StandardError; end
7
+ class TypeError < StandardError; end
8
+ class TransmissionError < StandardError; end
9
+ class FuelACError < StandardError; end
10
+ # Your code goes here...
11
+ end
12
+
13
+ require 'active_support/all'
14
+ require "sipp/code"
15
+ require "sipp/dictionary"
data/sipp.gemspec ADDED
@@ -0,0 +1,31 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "sipp/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sipp"
8
+ spec.version = SIPP::VERSION
9
+ spec.authors = ["Max Buslaev"]
10
+ spec.email = ["max@buslaev.net"]
11
+
12
+ spec.summary = %q{SIPP aka ACRISS code dictionary}
13
+ spec.description = %q{Translates car SIPP codes into something meaningful}
14
+ spec.homepage = "https://github.com/austerlitz/sipp"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.17"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec", "~> 3.0"
29
+
30
+ spec.add_dependency "activesupport", "~> 3.0"
31
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sipp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Max Buslaev
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-07-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: Translates car SIPP codes into something meaningful
70
+ email:
71
+ - max@buslaev.net
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - lib/sipp.rb
87
+ - lib/sipp/code.rb
88
+ - lib/sipp/dictionary.rb
89
+ - lib/sipp/version.rb
90
+ - sipp.gemspec
91
+ homepage: https://github.com/austerlitz/sipp
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.5.2
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: SIPP aka ACRISS code dictionary
115
+ test_files: []