nhtsa_vin 0.0.1 → 0.0.3
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 +4 -4
- data/README.md +2 -1
- data/lib/nhtsa_vin/query.rb +8 -3
- data/lib/nhtsa_vin/version.rb +1 -1
- data/nhtsa_vin.gemspec +5 -1
- data/spec/lib/nhtsa_vin/query_spec.rb +13 -2
- metadata +4 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 987b6fadc99bac8045a8288ca6effb187501f19d
|
4
|
+
data.tar.gz: bcdb074f6bf27055805bd9a6821446c3fed38ec6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28447017cd5ea2d27cf6cc684085fe2720744cc64a0f37587916574fd138c018e80c0313a694921524a53c0117163a53fd170aa86e8a73533ee5bbc11c6e2ff9
|
7
|
+
data.tar.gz: c82a876e940ca2aea5ae07d0f533614129b644cc7f824c571f89b543779edfac53e734729ba46274b8b4656c3b0f3a331da7398fc137ed592adcacbea938ea33
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# NHTSA Vin
|
2
|
-
|
2
|
+
|
3
|
+
[](https://badge.fury.io/rb/nhtsa_vin)
|
3
4
|
|
4
5
|
A ruby gem for fetching and parsing vehicle identification via the vehicle identification number (VIN) from the [NHTSA webservice](https://vpic.nhtsa.dot.gov/api/Home). Note, this gem is not officially affiliated with the NHTSA.
|
5
6
|
|
data/lib/nhtsa_vin/query.rb
CHANGED
@@ -6,7 +6,7 @@ module NhtsaVin
|
|
6
6
|
|
7
7
|
NHTSA_URL = 'https://vpic.nhtsa.dot.gov/api/vehicles/decodevin/'.freeze
|
8
8
|
|
9
|
-
attr_reader :vin, :url, :response, :raw_response
|
9
|
+
attr_reader :vin, :url, :response, :data, :error, :error_code, :raw_response
|
10
10
|
|
11
11
|
def initialize(vin, options={})
|
12
12
|
@vin = vin
|
@@ -32,8 +32,13 @@ module NhtsaVin
|
|
32
32
|
# 6 - Incomplete VIN.
|
33
33
|
# 8 - No detailed data available currently.
|
34
34
|
# 11- Incorrect Model Year, decoded data may not be accurate!
|
35
|
-
@
|
36
|
-
|
35
|
+
@error_code = value_id_for('Error Code')&.to_i
|
36
|
+
@valid = (@error_code < 4) ? true : false
|
37
|
+
|
38
|
+
if @error_code != 0
|
39
|
+
@error = value_for('Error Code')
|
40
|
+
end
|
41
|
+
return nil unless valid?
|
37
42
|
|
38
43
|
make = value_for('Make').capitalize
|
39
44
|
model = value_for('Model')
|
data/lib/nhtsa_vin/version.rb
CHANGED
data/nhtsa_vin.gemspec
CHANGED
@@ -6,7 +6,11 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.platform = Gem::Platform::RUBY
|
7
7
|
|
8
8
|
gem.summary = 'A ruby library for accessing vin records from the NHTSA'
|
9
|
-
gem.description =
|
9
|
+
gem.description = 'A ruby gem for fetching and parsing vehicle identificationi'\
|
10
|
+
'via the vehicle identification number (VIN) from the NHTSA'\
|
11
|
+
'webservice. Note, this gem is not officially affiliated with'\
|
12
|
+
'the NHTSA.'
|
13
|
+
|
10
14
|
gem.homepage = 'https://github.com/deliv/nhtsa_vin'
|
11
15
|
gem.licenses = ['MIT']
|
12
16
|
gem.authors = ['Barclay Loftus']
|
@@ -23,7 +23,12 @@ describe NhtsaVin::Query do
|
|
23
23
|
expect(client.raw_response).to eq success_response
|
24
24
|
expect(client.valid?).to be true
|
25
25
|
end
|
26
|
-
|
26
|
+
it 'has no error' do
|
27
|
+
expect(client.error).to be_nil
|
28
|
+
end
|
29
|
+
it 'has an error code of 0' do
|
30
|
+
expect(client.error_code).to eq 0
|
31
|
+
end
|
27
32
|
context 'its response' do
|
28
33
|
let(:response) { client.get }
|
29
34
|
it 'returns a struct' do
|
@@ -36,7 +41,7 @@ describe NhtsaVin::Query do
|
|
36
41
|
expect(response.body_style).to eq 'Wagon'
|
37
42
|
expect(response.doors).to eq 4
|
38
43
|
end
|
39
|
-
it 'parses out the type' do
|
44
|
+
it 'parses out the type enumeration' do
|
40
45
|
expect(response.type).to eq 'Minivan'
|
41
46
|
end
|
42
47
|
end
|
@@ -54,6 +59,12 @@ describe NhtsaVin::Query do
|
|
54
59
|
it 'returns nil' do
|
55
60
|
expect(client.get).to be_nil
|
56
61
|
end
|
62
|
+
it 'has an error message' do
|
63
|
+
expect(client.error).to eq '11- Incorrect Model Year, decoded data may not be accurate!'
|
64
|
+
end
|
65
|
+
it 'has an error code' do
|
66
|
+
expect(client.error_code).to eq 11
|
67
|
+
end
|
57
68
|
end
|
58
69
|
end
|
59
70
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nhtsa_vin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Barclay Loftus
|
@@ -52,21 +52,9 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description:
|
56
|
-
|
57
|
-
|
58
|
-
gem is currently in early development. \n\n## Installation\n\nAdd this line to your
|
59
|
-
application's Gemfile:\n\n```ruby\ngem 'nhsta_vin'\n```\n\nAnd then execute:\n\n
|
60
|
-
\ bundle\n\nOr install it yourself as:\n\n gem install nhsta_vin\n\n## Usage\n\nUsage
|
61
|
-
is fairly simple. Provide a VIN, and the gem will return a struct of vehicle data.
|
62
|
-
\n\n```ruby\nquery = NhtsaVin.get('1J4BA5H11AL143811')\nquery.valid? # => true\nquery.response
|
63
|
-
# => <Struct::NhtsaResponse make=\"Jeep\", model=\"Grand Cherokee\", trim=\"Laredo/Rocky
|
64
|
-
Mountain Edition\", type=\"SUV\", year=\"2008\", size=nil, ... doors=4>\n```\n\nIn
|
65
|
-
the result no match is found, the result will be `nil`, and `#valid?` will return
|
66
|
-
`false`. \n\nVehicle Types\n----\n\nFor brievity, we're reducing the `Vehicle Type`
|
67
|
-
response to an enumerated set of `[\"Car\", \"Truck\", \"Van\", \"SUV\", \"Minivan\"]`.
|
68
|
-
We're doing a rough parse of the type and body style to achieve this. It's probably
|
69
|
-
not perfect. \n\n\n## License\n\nLicensed under the MIT License.\n"
|
55
|
+
description: A ruby gem for fetching and parsing vehicle identificationivia the vehicle
|
56
|
+
identification number (VIN) from the NHTSAwebservice. Note, this gem is not officially
|
57
|
+
affiliated withthe NHTSA.
|
70
58
|
email:
|
71
59
|
- barclay@deliv.co
|
72
60
|
executables: []
|