vinquery 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vinquery (0.1.0)
4
+ vinquery (0.2.0)
5
5
  nokogiri (>= 1.4.4)
6
6
 
7
7
  GEM
@@ -2,7 +2,7 @@ require 'net/http'
2
2
  require 'nokogiri'
3
3
 
4
4
  class Vinquery
5
- attr_reader :attributes, :errors
5
+ attr_reader :attributes, :errors, :result
6
6
 
7
7
  def self.get(vin, options={})
8
8
  request = Vinquery.new options[:url], options[:access_code], options[:report_type]
@@ -18,20 +18,20 @@ class Vinquery
18
18
  end
19
19
 
20
20
  def fetch(vin)
21
- # initialize http get with vin
21
+ # use reducable=FALSE to get additional fields like fuel_type
22
22
  url_s = "#{@url}?accessCode=#{@access_code}&vin=#{vin}&reportType=#{@report_type}&reducable=FALSE"
23
23
  url = URI.parse(URI.escape(url_s))
24
24
  begin
25
- res = Net::HTTP.get url
25
+ @result = Net::HTTP.get url
26
26
  rescue Exception => e
27
27
  xml = Nokogiri::XML::Builder.new do |doc|
28
28
  doc.vin(:number => vin,:status => "FAILED") {
29
- doc.message(:Key => "VinQuery unavailable", :Value => "Oops, it looks like our VIN decoding database is down right now. Please try again later.")
29
+ doc.message(:Key => "VinQuery unavailable", :Value => "Oops, it looks like our VIN decoder is unavailable at the moment. Please try again later.")
30
30
  }
31
31
  end
32
- res = xml.to_xml
32
+ @result = xml.to_xml
33
33
  end
34
- @doc = Nokogiri::HTML(res)
34
+ @doc = Nokogiri::HTML(@result)
35
35
  end
36
36
 
37
37
  def parse(doc)
@@ -41,11 +41,11 @@ class Vinquery
41
41
  end
42
42
 
43
43
  def set_attributes(doc)
44
- attributes = {}
44
+ attributes = {:vendor_result => @result}
45
45
  doc.xpath('//vehicle[1]/item').each do |item|
46
46
  attributes[item.attributes['key'].value.downcase.gsub(/ /, '_').intern] = item.attributes['value'].value
47
47
  end
48
-
48
+
49
49
  @attributes = attributes
50
50
  end
51
51
 
@@ -1,3 +1,3 @@
1
1
  class Vinquery
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: vinquery
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.0
5
+ version: 0.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jake Mallory
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-06-20 00:00:00 Z
14
+ date: 2011-06-24 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: nokogiri