vin_query 1.1.0 → 1.2.0

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: e009eb9349dbfd08405cb85579c97ecd30bc0e07
4
- data.tar.gz: 2ac76344b14f533acfa5bf73762580d8e8a056cf
3
+ metadata.gz: 3a69843444674f6ac232c24be8b0026289422560
4
+ data.tar.gz: 7d569af4c7c81e2b261112efd7bd1b6063c82212
5
5
  SHA512:
6
- metadata.gz: 19a2ab043fce4cd50b2239d2892297c00d3cb18986d82da20cbf3d05c42aaec258d6a3f2f61c3cb3b4fe9a7c937cbca719e9a4c963c2b89232b7873cafd8b9cd
7
- data.tar.gz: 83761294c6cd620c739a6262eaf7769feb10ed2aaafacb9cb7551e79b0c34fb27420dce2e1c47b7766ab4b005cb30e631dd2fed8786220ba718cb0e226cdb5ba
6
+ metadata.gz: bcb18a7414c10c4e598888617d6e9ab51a0f49c84b169b3443874bd6f37776e7476ee08c4fa044e806fe9fcadf0839196bb2ce384bdf8394b33194fccb95830e
7
+ data.tar.gz: 82bfd9a55730d22ec5b356646d0e3664283bc981ef262edb8c6dc5a331057cf945a68a3e495c8865785d8d9fc10b486ac9ff5692ef929a2c83b38235a71303ee
@@ -1,3 +1,8 @@
1
+ ## v1.2.0 (2016-12-12)
2
+
3
+ - Expose response XML, and add ReportType constants
4
+ - Add license and required ruby version to gemspec
5
+
1
6
  ## v1.1.0 (2016-12-12)
2
7
 
3
8
  - Add configuration block pattern
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # VinQuery
2
2
 
3
- [![Build Status](https://travis-ci.org/jyunderwood/vin_query.png?branch=master)](https://travis-ci.org/jyunderwood/vin_query)
3
+ [![Build Status](https://travis-ci.org/jyunderwood/vin_query.svg?branch=master)](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 = 2
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 = 2
29
+ @report_type = ReportType::EXTENDED
20
30
  end
21
31
 
22
32
  def merge_options(options={})
@@ -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
- xml = fetch(@url)
61
- parse(xml) if validate(xml)
60
+ @response_xml = fetch(@url)
61
+ parse(@response_xml) if validate(@response_xml)
62
62
  end
63
63
 
64
64
  private
@@ -1,3 +1,3 @@
1
1
  module VinQuery
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -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 2
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: 3)
23
- expect(VinQuery.configuration.report_type).to eq 3
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
- before { allow(client).to receive(:fetch).and_return('<html>404</html>') }
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
@@ -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.1.0
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: '0'
111
+ version: 2.0.0
111
112
  required_rubygems_version: !ruby/object:Gem::Requirement
112
113
  requirements:
113
114
  - - ">="