nhtsa_vin 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b59380a0e5ddb9e3885510cc564dfe25aa0bc3f7
4
- data.tar.gz: 5b5e62bc3c546f638da79f78defe1b549e20ec0e
3
+ metadata.gz: 304f6e9a4706dcfd739db613ae7c72498315105c
4
+ data.tar.gz: d4d6d09d018be6ad53808f6f1373fd2bf8ab1b62
5
5
  SHA512:
6
- metadata.gz: ca9557397db41dceaa8e7db53e26f7560b63e6bee043912dfa39107490d0e36c51e3bd7ecb2f6bac7c60aadfb3b7c3d8d399be31fa1f3ad9994bc0fc5b67e02b
7
- data.tar.gz: b73345bd38a58f64fe14b252f1d05b016d9770658560e5ff71e65803baf1adeca134b16a86fa27abf7ccff0e944d8954e5c9ac5b0cc03acffbcbe859c1496151
6
+ metadata.gz: 85c5e99bbd033576db5f582aeaff92ec8317fa74e459d58e8e68a396b134d2cdeebd601fb43d0446274e04ea26e24b7706d1047ae18ce1237b4f017cc4bc3716
7
+ data.tar.gz: 2d5b4cb48f8ebab768ce8ee7cda45bb5b2dc106e15bb6a09892195ea9570ea79da42ff06423c2f928a4b874d147c9b71c216594871dbc951807154a800592570
data/.gitignore CHANGED
@@ -4,3 +4,5 @@ rdoc/*
4
4
  *.gem
5
5
  .bundle
6
6
  Gemfile.lock
7
+ .idea/*
8
+ coverage/*
data/README.md CHANGED
@@ -30,16 +30,23 @@ Or install it yourself as:
30
30
  Validation
31
31
  ----
32
32
 
33
- Prior to dispatching a call to the web service, you can optionally validate a given VIN first.
33
+ Prior to dispatching a call to the web service, you can optionally validate a given VIN first. Calling `#validate` returns an `NhtsaVin::Validation`.
34
34
 
35
35
  ```ruby
36
- validation = NhtsaVin.Validate.new('1J4BA5H11AL143811') # => <#NhtsaVin.Validate>
36
+ validation = NhtsaVin.validate('1J4BA5H11AL143811') # => <#NhtsaVin.Validate>
37
37
  validation.valid? # => true
38
- validation.checksum # => 1
39
38
 
40
- validation = NhtsaVin.Validate.new('SOMEBADVIN') # => <#NhtsaVin.Validate>
39
+ validation = NhtsaVin.validate('SOMEBADVIN') # => <#NhtsaVin.Validate>
41
40
  validation.valid? # => false
42
- validation.checksum # => nil
41
+ validation.error # => 'Invalid VIN format'
42
+ ```
43
+
44
+ Once validated, the validation also provides the components of a VIN, and additional information
45
+
46
+ ```ruby
47
+ validation = NhtsaVin.validate('1J4BA5H11AL143811') # => <#NhtsaVin.Validate>
48
+ validation.checksum # => '1'
49
+ validation.plant # => 'L'
43
50
  ```
44
51
 
45
52
  Query
@@ -8,6 +8,10 @@ module NhtsaVin
8
8
  def get(vin, options={})
9
9
  query = NhtsaVin::Query.new(vin, options)
10
10
  query.get
11
- return query
11
+ query
12
+ end
13
+
14
+ def validate(vin)
15
+ NhtsaVin::Validation.new(vin)
12
16
  end
13
17
  end
@@ -1,3 +1,3 @@
1
1
  module NhtsaVin
2
- VERSION = '0.0.5'.freeze
2
+ VERSION = '0.0.6'.freeze
3
3
  end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe NhtsaVin do
4
+ let(:vin) { '2G1WT57K291223396' }
5
+ describe '#get' do
6
+ let(:get) { NhtsaVin.get(vin) }
7
+ it 'returns a query' do
8
+ expect(get).to be_a NhtsaVin::Query
9
+ end
10
+ end
11
+ describe '#validate' do
12
+ let(:validate) { NhtsaVin.validate(vin) }
13
+ it 'returns a validation' do
14
+ expect(validate).to be_a NhtsaVin::Validation
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nhtsa_vin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Barclay Loftus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-07 00:00:00.000000000 Z
11
+ date: 2018-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -79,6 +79,7 @@ files:
79
79
  - spec/fixtures/success.json
80
80
  - spec/lib/nhtsa_vin/query_spec.rb
81
81
  - spec/lib/nhtsa_vin/validation_spec.rb
82
+ - spec/lib/nhtsa_vin_spec.rb
82
83
  - spec/spec_helper.rb
83
84
  homepage: https://github.com/deliv/nhtsa_vin
84
85
  licenses:
@@ -109,4 +110,5 @@ test_files:
109
110
  - spec/fixtures/success.json
110
111
  - spec/lib/nhtsa_vin/query_spec.rb
111
112
  - spec/lib/nhtsa_vin/validation_spec.rb
113
+ - spec/lib/nhtsa_vin_spec.rb
112
114
  - spec/spec_helper.rb