vin_query 1.1.0 → 1.2.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +2 -2
- data/lib/vin_query/configuration.rb +12 -2
- data/lib/vin_query/query.rb +3 -3
- data/lib/vin_query/version.rb +1 -1
- data/spec/lib/vin_query/configuration_spec.rb +3 -3
- data/spec/lib/vin_query/query_spec.rb +6 -1
- data/vin_query.gemspec +3 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a69843444674f6ac232c24be8b0026289422560
|
4
|
+
data.tar.gz: 7d569af4c7c81e2b261112efd7bd1b6063c82212
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcb18a7414c10c4e598888617d6e9ab51a0f49c84b169b3443874bd6f37776e7476ee08c4fa044e806fe9fcadf0839196bb2ce384bdf8394b33194fccb95830e
|
7
|
+
data.tar.gz: 82bfd9a55730d22ec5b356646d0e3664283bc981ef262edb8c6dc5a331057cf945a68a3e495c8865785d8d9fc10b486ac9ff5692ef929a2c83b38235a71303ee
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# VinQuery
|
2
2
|
|
3
|
-
[](https://travis-ci.org/jyunderwood/vin_query)
|
4
4
|
|
5
5
|
A ruby library for fetching and parsing VIN information from vinquery.com, a vehicle identification number decoding service.
|
6
6
|
|
@@ -45,7 +45,7 @@ It also accepts a configuration block to streamline gets.
|
|
45
45
|
VinQuery.configure do |config|
|
46
46
|
config.url = 'vinquery-url-here'
|
47
47
|
config.access_code = 'access-code-here'
|
48
|
-
config.report_type =
|
48
|
+
config.report_type = VinQuery::ReportType::EXTENDED
|
49
49
|
end
|
50
50
|
|
51
51
|
query = VinQuery.get('1C3CC4FB8AN236750')
|
@@ -1,10 +1,20 @@
|
|
1
1
|
module VinQuery
|
2
|
+
module ReportType
|
3
|
+
BASIC = 0
|
4
|
+
STANDARD = 1
|
5
|
+
EXTENDED = 2
|
6
|
+
LITE = 3
|
7
|
+
end
|
8
|
+
|
2
9
|
class << self
|
3
10
|
attr_accessor :configuration
|
11
|
+
|
12
|
+
def configuration
|
13
|
+
@configuration ||= Configuration.new
|
14
|
+
end
|
4
15
|
end
|
5
16
|
|
6
17
|
def self.configure
|
7
|
-
self.configuration ||= Configuration.new
|
8
18
|
yield(configuration)
|
9
19
|
end
|
10
20
|
|
@@ -16,7 +26,7 @@ module VinQuery
|
|
16
26
|
attr_accessor :url, :access_code, :report_type
|
17
27
|
|
18
28
|
def initialize
|
19
|
-
@report_type =
|
29
|
+
@report_type = ReportType::EXTENDED
|
20
30
|
end
|
21
31
|
|
22
32
|
def merge_options(options={})
|
data/lib/vin_query/query.rb
CHANGED
@@ -3,7 +3,7 @@ require 'nokogiri'
|
|
3
3
|
|
4
4
|
module VinQuery
|
5
5
|
class Query
|
6
|
-
attr_reader :vin, :url, :trim_levels
|
6
|
+
attr_reader :vin, :url, :response_xml, :trim_levels
|
7
7
|
|
8
8
|
def initialize(vin, options={})
|
9
9
|
VinQuery.configuration.merge_options(options)
|
@@ -57,8 +57,8 @@ module VinQuery
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def get
|
60
|
-
|
61
|
-
parse(
|
60
|
+
@response_xml = fetch(@url)
|
61
|
+
parse(@response_xml) if validate(@response_xml)
|
62
62
|
end
|
63
63
|
|
64
64
|
private
|
data/lib/vin_query/version.rb
CHANGED
@@ -14,13 +14,13 @@ describe VinQuery::Configuration do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'has a default report type' do
|
17
|
-
expect(VinQuery.configuration.report_type).to eq
|
17
|
+
expect(VinQuery.configuration.report_type).to eq VinQuery::ReportType::EXTENDED
|
18
18
|
end
|
19
19
|
|
20
20
|
context 'when manually given options' do
|
21
21
|
it 'overrides default configuration settings' do
|
22
|
-
VinQuery.configuration.merge_options(report_type:
|
23
|
-
expect(VinQuery.configuration.report_type).to eq
|
22
|
+
VinQuery.configuration.merge_options(report_type: VinQuery::ReportType::LITE)
|
23
|
+
expect(VinQuery.configuration.report_type).to eq VinQuery::ReportType::LITE
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'overrides previously set configuration settings' do
|
@@ -100,6 +100,7 @@ describe VinQuery::Query do
|
|
100
100
|
end
|
101
101
|
|
102
102
|
it 'fetches xml and response is valid' do
|
103
|
+
expect(client.response_xml).to eq xml_multi
|
103
104
|
expect(client.valid?).to be true
|
104
105
|
end
|
105
106
|
|
@@ -115,6 +116,7 @@ describe VinQuery::Query do
|
|
115
116
|
end
|
116
117
|
|
117
118
|
it 'fetches xml and response is not valid' do
|
119
|
+
expect(client.response_xml).to eq xml_error
|
118
120
|
expect(client.valid?).to be false
|
119
121
|
end
|
120
122
|
|
@@ -124,10 +126,13 @@ describe VinQuery::Query do
|
|
124
126
|
end
|
125
127
|
|
126
128
|
context '404 response' do
|
127
|
-
|
129
|
+
let(:response_404) { '<html>404</html>' }
|
130
|
+
|
131
|
+
before { allow(client).to receive(:fetch).and_return(response_404) }
|
128
132
|
|
129
133
|
it 'fetches xml and response cannot be validated' do
|
130
134
|
expect{ client.get }.to raise_error VinQuery::ValidationError
|
135
|
+
expect(client.response_xml).to eq response_404
|
131
136
|
end
|
132
137
|
end
|
133
138
|
end
|
data/vin_query.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.summary = 'A ruby library for accessing vinquery.com'
|
9
9
|
gem.description = 'A ruby library for fetching and parsing VIN information from vinquery.com, a vehicle identification number decoding service.'
|
10
10
|
gem.homepage = 'https://github.com/jyunderwood/vin_query'
|
11
|
-
|
11
|
+
gem.licenses = ['MIT']
|
12
12
|
gem.authors = ['Jonathan Underwood']
|
13
13
|
gem.email = ['jonathan@jyunderwood.com']
|
14
14
|
|
@@ -17,6 +17,8 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ['lib']
|
19
19
|
|
20
|
+
gem.required_ruby_version = '>= 2.0.0'
|
21
|
+
|
20
22
|
gem.add_dependency 'nokogiri', '> 1.5'
|
21
23
|
|
22
24
|
gem.add_development_dependency 'rake'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vin_query
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Underwood
|
@@ -97,7 +97,8 @@ files:
|
|
97
97
|
- spec/spec_helper.rb
|
98
98
|
- vin_query.gemspec
|
99
99
|
homepage: https://github.com/jyunderwood/vin_query
|
100
|
-
licenses:
|
100
|
+
licenses:
|
101
|
+
- MIT
|
101
102
|
metadata: {}
|
102
103
|
post_install_message:
|
103
104
|
rdoc_options: []
|
@@ -107,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
108
|
requirements:
|
108
109
|
- - ">="
|
109
110
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
111
|
+
version: 2.0.0
|
111
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
113
|
requirements:
|
113
114
|
- - ">="
|