edmunds_cars 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "httparty"
4
+
5
+ group :development do
6
+ gem "bundler"
7
+ gem "jeweler"
8
+ gem "rdoc"
9
+ end
10
+
11
+ group :test do
12
+ gem 'webmock'
13
+ gem 'vcr'
14
+ gem 'turn'
15
+ gem 'rake'
16
+ end
17
+
data/Gemfile.lock ADDED
@@ -0,0 +1,40 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.2)
5
+ ansi (1.4.3)
6
+ crack (0.3.1)
7
+ git (1.2.5)
8
+ httparty (0.9.0)
9
+ multi_json (~> 1.0)
10
+ multi_xml
11
+ jeweler (1.8.4)
12
+ bundler (~> 1.0)
13
+ git (>= 1.2.5)
14
+ rake
15
+ rdoc
16
+ json (1.7.5)
17
+ multi_json (1.5.0)
18
+ multi_xml (0.5.1)
19
+ rake (10.0.3)
20
+ rdoc (3.12)
21
+ json (~> 1.4)
22
+ turn (0.9.6)
23
+ ansi
24
+ vcr (2.4.0)
25
+ webmock (1.9.0)
26
+ addressable (>= 2.2.7)
27
+ crack (>= 0.1.7)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ bundler
34
+ httparty
35
+ jeweler
36
+ rake
37
+ rdoc
38
+ turn
39
+ vcr
40
+ webmock
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Conner Wingard
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # EdmundsCars
2
+
3
+ A ruby wrapper for the Edmunds ( <http://www.edmunds.com> ) api for auto information.
4
+
5
+ First register for an edmunds developer account at <http://developer.edmunds.com/>
6
+
7
+ -- edmunds = EdmundsCars::Models.new("YOUR_API_KEY")
8
+ -- toyota_four_runner = edmunds.by_make_model("toyota","4runner")
9
+
10
+ This will provide a bunch of json about 4Runners. More documentation comings soon!
11
+
12
+ == Contributing to edmunds_cars
13
+
14
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
15
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
16
+ * Fork the project
17
+ * Start a feature/bugfix branch
18
+ * Commit and push until you are happy with your contribution
19
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
20
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
21
+
22
+ == Copyright
23
+
24
+ Copyright (c) 2013 Conner Wingard. See LICENSE.txt for
25
+ further details.
26
+
data/Rakefile ADDED
@@ -0,0 +1,48 @@
1
+ # encoding: utf-8
2
+ require 'rubygems'
3
+ require 'bundler'
4
+ require './lib/edmunds_cars/version'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ gem.name = "edmunds_cars"
17
+ gem.homepage = "http://github.com/ConnerMan/edmunds_cars"
18
+ gem.license = "MIT"
19
+ gem.summary = %Q{A wrapper for the edmunds.com REST api}
20
+ gem.description = %Q{Easily query information about cars through the edmunds api. }
21
+ gem.email = "conner@connerwingard.com"
22
+ gem.version = EdmundsCars::VERSION
23
+ gem.authors = ["Conner Wingard"]
24
+
25
+ gem.require_paths = ["lib"]
26
+
27
+ gem.add_dependency("httparty","~> 0.9.0")
28
+ end
29
+ Jeweler::RubygemsDotOrgTasks.new
30
+
31
+ require 'rake/testtask'
32
+ Rake::TestTask.new do |t|
33
+ t.test_files = FileList['spec/lib/edmunds_cars/*_spec.rb']
34
+ t.verbose = true
35
+ t.warning = true
36
+ end
37
+ task :default => :test
38
+
39
+
40
+ require 'rdoc/task'
41
+ RDoc::Task.new do |rdoc|
42
+ version = EdmundsCars::VERSION
43
+
44
+ rdoc.rdoc_dir = 'rdoc'
45
+ rdoc.title = "edmunds_cars #{version}"
46
+ rdoc.rdoc_files.include('README*')
47
+ rdoc.rdoc_files.include('lib/**/*.rb')
48
+ end
@@ -0,0 +1,76 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "edmunds_cars"
8
+ s.version = "0.2.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Conner Wingard"]
12
+ s.date = "2013-01-13"
13
+ s.description = "Easily query information about cars through the edmunds api. "
14
+ s.email = "conner@connerwingard.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ "Gemfile",
21
+ "Gemfile.lock",
22
+ "LICENSE.txt",
23
+ "README.md",
24
+ "Rakefile",
25
+ "edmunds_cars.gemspec",
26
+ "lib/edmunds_cars.rb",
27
+ "lib/edmunds_cars/consumer_reviews.rb",
28
+ "lib/edmunds_cars/depreciation.rb",
29
+ "lib/edmunds_cars/incentives.rb",
30
+ "lib/edmunds_cars/maintenance.rb",
31
+ "lib/edmunds_cars/make_ids.rb",
32
+ "lib/edmunds_cars/makes.rb",
33
+ "lib/edmunds_cars/models.rb",
34
+ "lib/edmunds_cars/photos.rb",
35
+ "lib/edmunds_cars/resale.rb",
36
+ "lib/edmunds_cars/styles.rb",
37
+ "lib/edmunds_cars/total_cash_price.rb",
38
+ "lib/edmunds_cars/true_cost_to_own.rb",
39
+ "lib/edmunds_cars/true_market_value.rb",
40
+ "lib/edmunds_cars/vehicles.rb",
41
+ "lib/edmunds_cars/version.rb",
42
+ "lib/edmunds_cars/vin.rb",
43
+ "spec/lib/edmunds_cars/vehicle_spec.rb",
44
+ "spec/spec_helper.rb"
45
+ ]
46
+ s.homepage = "http://github.com/ConnerMan/edmunds_cars"
47
+ s.licenses = ["MIT"]
48
+ s.require_paths = ["lib"]
49
+ s.rubygems_version = "1.8.24"
50
+ s.summary = "A wrapper for the edmunds.com REST api"
51
+
52
+ if s.respond_to? :specification_version then
53
+ s.specification_version = 3
54
+
55
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
56
+ s.add_runtime_dependency(%q<httparty>, [">= 0"])
57
+ s.add_development_dependency(%q<bundler>, [">= 0"])
58
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
59
+ s.add_development_dependency(%q<rdoc>, [">= 0"])
60
+ s.add_runtime_dependency(%q<httparty>, ["~> 0.9.0"])
61
+ else
62
+ s.add_dependency(%q<httparty>, [">= 0"])
63
+ s.add_dependency(%q<bundler>, [">= 0"])
64
+ s.add_dependency(%q<jeweler>, [">= 0"])
65
+ s.add_dependency(%q<rdoc>, [">= 0"])
66
+ s.add_dependency(%q<httparty>, ["~> 0.9.0"])
67
+ end
68
+ else
69
+ s.add_dependency(%q<httparty>, [">= 0"])
70
+ s.add_dependency(%q<bundler>, [">= 0"])
71
+ s.add_dependency(%q<jeweler>, [">= 0"])
72
+ s.add_dependency(%q<rdoc>, [">= 0"])
73
+ s.add_dependency(%q<httparty>, ["~> 0.9.0"])
74
+ end
75
+ end
76
+
@@ -0,0 +1,21 @@
1
+ require 'httparty'
2
+
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__)))
4
+
5
+ require "edmunds_cars/version"
6
+ require "edmunds_cars/vehicles"
7
+ require "edmunds_cars/consumer_reviews"
8
+ require "edmunds_cars/depreciation"
9
+ require "edmunds_cars/incentives"
10
+ require "edmunds_cars/maintenance"
11
+ require "edmunds_cars/make_ids"
12
+ require "edmunds_cars/makes"
13
+ require "edmunds_cars/models"
14
+ require "edmunds_cars/photos"
15
+ require "edmunds_cars/resale"
16
+ require "edmunds_cars/styles"
17
+ require "edmunds_cars/total_cash_price"
18
+ require "edmunds_cars/true_cost_to_own"
19
+ require "edmunds_cars/true_market_value"
20
+ require "edmunds_cars/vehicles"
21
+ require "edmunds_cars/vin"
@@ -0,0 +1,12 @@
1
+ module EdmundsCars
2
+ class ConsumerReviews < Vehicles
3
+
4
+ base_uri "http://api.edmunds.com/v1/api/crrrepository"
5
+
6
+ def by_make_model_year(make, model, year)
7
+ self.class.get("/getcrrformakemodelyear", :query => {:make => make, :model => model, :year => year})
8
+ end
9
+
10
+ end
11
+ end
12
+
@@ -0,0 +1,17 @@
1
+ module EdmundsCars
2
+ class Depreciation < Vehicles
3
+
4
+ base_uri "http://api.edmunds.com/v1/api/tco/depreciation"
5
+
6
+ # Get the depreciation value in dollars over the next 5 years for a used vehicle by Style ID and zipcode
7
+ def used_rates_by_styleid_and_zip(style_id, zip)
8
+ self.class.get("/usedratesbystyleidandzip/#{style_id}/#{zip}")
9
+ end
10
+
11
+ # Get the depreciation value in dollars over the next 5 years for a new vehicle by Style ID and zipcode
12
+ def new_rates_by_styleid_and_zip(style_id, zip)
13
+ self.class.get("/newratesbystyleidandzip/#{style_id}/#{zip}")
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ module EdmundsCars
2
+ class Incentives < Vehicles
3
+
4
+ base_uri "http://api.edmunds.com/v1/api/incentive/incentiverepository"
5
+
6
+ def by_style_id(style_id)
7
+ self.class.get("/findincentivesbystyleid", :query => {:styleid => style_id})
8
+ end
9
+
10
+ end
11
+ end
12
+
@@ -0,0 +1,32 @@
1
+ module EdmundsCars
2
+ class Maintenance < Vehicles
3
+
4
+ base_uri "http://api.edmunds.com/v1/api/maintenance"
5
+
6
+ def service_bulletins_by_model_year_id(id)
7
+ self.class.get("/servicebulletinrepository/findbymodelyearid", :query => {:modelyearid => id})
8
+ end
9
+
10
+ def service_bulletin_by_id(id)
11
+ self.class.get("/servicebulletin/#{id}")
12
+ end
13
+
14
+ def style_notes_by_id(id)
15
+ self.class.get("/stylenotes/#{id}")
16
+ end
17
+
18
+ def labor_rates_by_zip
19
+ self.class.get("/ziplaborrate/#{zipcode}")
20
+ end
21
+
22
+ def recall_by_id(id)
23
+ self.class.get("/recall/#{id}")
24
+ end
25
+
26
+ def recall_by_model_year_id(model_year_id)
27
+ self.class.get("/recallrepository", :query => {:modelyearid => model_year_id})
28
+ end
29
+
30
+ end
31
+ end
32
+
@@ -0,0 +1,65 @@
1
+ module EdmundsCars
2
+
3
+ #edmunds ids for each make
4
+ AM_GENERAL = '200347864'
5
+ ACURA = '200002038'
6
+ ASTON_MARTIN = '200001769'
7
+ AUDI = '200000001'
8
+ BMW = '200000081'
9
+ BENTLEY = '200005848'
10
+ BUGATTI = '200030397'
11
+ BUICK = '200006659'
12
+ CADILLAC = '200001663'
13
+ CHEVROLET = '200000404'
14
+ CHRYSLER = '200003644'
15
+ DAEWOO = '200312185'
16
+ DODGE = '200009788'
17
+ EAGLE = '200347865'
18
+ FIAT = '200033022'
19
+ FERRARI = '200006023'
20
+ FISKER = '200005745'
21
+ FORD = '200005143'
22
+ GMC = '200007302'
23
+ GEO = '200347866'
24
+ HUMMER = '200004021'
25
+ HONDA = '200001444'
26
+ HYUNDAI = '200001398'
27
+ INFINITI = '200000089'
28
+ ISUZU = '200110731'
29
+ JAGUAR = '200003196'
30
+ JEEP = '200001510'
31
+ KIA = '200003063'
32
+ LAMBORGHINI = '200005922'
33
+ LAND_ROVER = '200006582'
34
+ LEXUS = '200001623'
35
+ LINCOLN = '200001777'
36
+ LOTUS = '200006242'
37
+ MINI = '200002305'
38
+ MASERATI = '200028029'
39
+ MAYBACH = '200043087'
40
+ MAZDA = '200004100'
41
+ MCLAREN = '200051397'
42
+ MERCEDES_BENZ = '200000130'
43
+ MERCURY = '200007711'
44
+ MITSUBISHI = '200002915'
45
+ NISSAN = '200000201'
46
+ OLDSMOBILE = '200249342'
47
+ PANOZ = '200194838'
48
+ PLYMOUTH = '200339126'
49
+ PONTIAC = '200002634'
50
+ PORSCHE = '200000886'
51
+ RAM = '200393150'
52
+ ROLLS_ROYCE = '200005044'
53
+ SRT = '200412738'
54
+ SAAB = '200074504'
55
+ SATURN = '200004446'
56
+ SCION = '200006515'
57
+ SPYKER = '200046567'
58
+ SUBARU = '200004491'
59
+ SUZUKI = '200001853'
60
+ TESLA = '200018920'
61
+ TOYOTA = '200003381'
62
+ VOLKSWAGEN = '200000238'
63
+ VOLVO = '200010382'
64
+ SMART = '200038885'
65
+ end
@@ -0,0 +1,15 @@
1
+ module EdmundsCars
2
+ class Makes < Vehicles
3
+
4
+ base_uri "http://api.edmunds.com/v1/api/vehicle/makerepository"
5
+
6
+ def by_id(make_id)
7
+ self.class.get("/findbyid" , :query => {:id => make_id})
8
+ end
9
+
10
+ def all
11
+ self.class.get("/findall")
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module EdmundsCars
2
+ class Models < Vehicles
3
+
4
+ base_uri "http://api.edmunds.com/v1/api/vehicle"
5
+
6
+ def by_make_model(make, model)
7
+ self.class.get("/vehicle/modelrepository/findmodelbymakemodelname", :query => {:make => make, :model=> model_name })
8
+ end
9
+
10
+ def by_make_model_year(make, model, model_year = Time.now.year)
11
+ self.class.get("/vehicle/#{make}/#{model}/#{model_year}")
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ module EdmundsCars
2
+ class Photos < Vehicles
3
+
4
+ base_uri "http://api.edmunds.com/v1/api/vehiclephoto/service"
5
+
6
+ def by_style_id(style_id)
7
+ self.class.get("/findphotosbystyleid", {:styleId => style_id})
8
+ end
9
+
10
+ end
11
+ end
12
+
@@ -0,0 +1,11 @@
1
+ module EdmundsCars
2
+ class Resale < Vehicles
3
+
4
+ base_uri "http://api.edmunds.com/v1/api/tco"
5
+
6
+ def by_styleid_and_zip(style_id, zip)
7
+ self.class.get("/resalevaluesbystyleidandzip/#{style_id}/#{zip}")
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ module EdmundsCars
2
+ class Styles < Vehicles
3
+
4
+ base_uri "http://api.edmunds.com/v1/api/vehicle/stylerepository"
5
+
6
+ def by_id(id)
7
+ self.class.get("/findbyid", :query => {:id => id})
8
+ end
9
+
10
+ def by_make_model_year(make, model_name, model_year)
11
+ self.class.get("/findstylesbymakemodelyear", :query => {:make=>make, :model=> model_name, :year => model_year})
12
+ end
13
+
14
+ def by_model_year_id(id)
15
+ self.class.get("/findstylebymakemodelyearid", :query => {:modelyearid => id})
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ module EdmundsCars
2
+
3
+ # FROM EDMUNDS DOCUMENTATION
4
+ # The Total Cash Price displayed is the vehicle's True Market Value (TMV) price plus typically equipped options,
5
+ # destination charge, base tax and fees assessed by your state, and, if applicable, gas guzzler tax; less any
6
+ # widely available manufacturer-to-customer cash rebates. (However, we do not account for other types of cash
7
+ # rebates or incentives because of the variability of those offers and their eligibility requirements.
8
+ class TotalCashPrice < Vehicles
9
+
10
+ base_uri "http://api.edmunds.com/v1/api/tco"
11
+
12
+ def new_by_styleid_and_zip(style_id, zip)
13
+ self.class.get("/newtotalcashpricebystyleidandzip/#{style_id}/#{zip}")
14
+ end
15
+
16
+ def used_by_styleid_and_zip(style_id, zip)
17
+ self.class.get("/usedtotalcashpricebystyleidandzip/#{style_id}/#{zip}")
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,34 @@
1
+ module EdmundsCars
2
+ class TrueCostToOwn < Vehicles
3
+
4
+ base_uri "http://api.edmunds.com/v1/api/tco"
5
+
6
+ def new_by_style_id_and_zip(style_id, zip)
7
+ self.class.get("/newtruecosttoownbystyleidandzip/#{style_id}/#{zip}")
8
+ end
9
+
10
+ def used_by_style_id_and_zip(style_id, zip)
11
+ self.class.get("/usedtruecosttoownbystyleidandzip/#{style_id}/#{zip}")
12
+ end
13
+
14
+ def makes_with_data
15
+ self.class.get("/getmakeswithtcodata")
16
+ end
17
+
18
+ def models_with_data(make_id)
19
+ self.class.get("/getmodelswithtcodata", :query => {:makeid => make_id})
20
+ end
21
+
22
+ def styles_with_data_by_submodel(make, model, year, submodel)
23
+ self.class.get("/getstyleswithtcodatabysubmodel", {
24
+ :make => make,
25
+ :model => model,
26
+ :year => year,
27
+ :submodel => submodel
28
+ })
29
+ end
30
+
31
+ end
32
+ end
33
+
34
+
@@ -0,0 +1,28 @@
1
+ module EdmundsCars
2
+ class TrueMarketValue < Vehicles
3
+
4
+ base_uri "http://api.edmunds.com/v1/api/tmv/tmvservice"
5
+
6
+ def typically_equipped(style_id, zip)
7
+ self.class.get("/calculatetypicallyequippedusedtmv", :query => {:styleid => style_id, :zip => zip})
8
+ end
9
+
10
+ def new_base(style_id, zip)
11
+ self.class.get("/calculatenewtmv", :query => {:styleid => style_id, :zip => zip})
12
+ end
13
+
14
+ def used(style_id, condition, mileage, zip)
15
+ self.class.get("/calculateusedtmv", :query => {:styleid => style_id, :condition => condition, :mileage => mileage, :zip => zip})
16
+ end
17
+
18
+ def certified_price_for_style(style_id, zip)
19
+ self.class.get_url("/findcertifiedpriceforstyle", :query => {:styleid => style_id, :zip => zip})
20
+ end
21
+
22
+ def cpo_years_by_make(make_id)
23
+ self.class.get_url("/findcpoyearsbymake", :query => {:makeid => make_id})
24
+ end
25
+
26
+ end
27
+ end
28
+
@@ -0,0 +1,14 @@
1
+ module EdmundsCars
2
+
3
+ class Vehicles
4
+ include HTTParty
5
+
6
+ base_uri "http://api.edmunds.com/v1/api"
7
+ default_params :fmt => "json"
8
+
9
+ def initialize(key)
10
+ self.class.default_params :api_key => key
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module EdmundsCars
2
+ VERSION = "0.2.0"
3
+ end
@@ -0,0 +1,12 @@
1
+ module EdmundsCars
2
+ class Vin < Vehicles
3
+
4
+ base_uri "http://api.edmunds.com/v1/api/toolsrepository"
5
+
6
+ def decode(vin)
7
+ self.class.get("/vindecoder", :query => {:vin => vin})
8
+ end
9
+
10
+ end
11
+ end
12
+
@@ -0,0 +1,110 @@
1
+ require File.expand_path('../../../spec_helper', __FILE__)
2
+
3
+ describe EdmundsCars::Vehicles do
4
+ before do
5
+ @edmunds = EdmundsCars::Vehicles.new( ENV['edmunds_vehicle_api'])
6
+ end
7
+
8
+ describe "default attributes" do
9
+ it "must include httparty methods" do
10
+ EdmundsCars::Vehicles.must_include HTTParty
11
+ end
12
+
13
+ it "must have the base url set to the edmunds api endpoint" do
14
+ EdmundsCars::Vehicles.base_uri.must_equal "http://api.edmunds.com/v1/api"
15
+ end
16
+
17
+ it "must set api key" do
18
+ EdmundsCars::Vehicles.default_params[:api_key].must_equal ENV['edmunds_vehicle_api']
19
+ end
20
+
21
+ it "must set format to json" do
22
+ EdmundsCars::Vehicles.default_params[:fmt].must_equal "json"
23
+ end
24
+
25
+ end
26
+ end
27
+
28
+ describe EdmundsCars::TrueMarketValue do
29
+ before do
30
+ @edmunds = EdmundsCars::TrueMarketValue.new( ENV['edmunds_vehicle_api'] )
31
+ end
32
+
33
+ it "implement all api methods" do
34
+ @edmunds.must_respond_to :new_base
35
+ @edmunds.must_respond_to :typically_equipped
36
+ @edmunds.must_respond_to :used
37
+ end
38
+
39
+ it "get new base" do
40
+ VCR.use_cassette("4Runner_tmv") do
41
+ data = @edmunds.new_base('101351498','01741')
42
+ refute_nil data
43
+ data["tmv"]["nationalBasePrice"]["baseMSRP"].must_equal 36555.0
44
+ end
45
+ end
46
+
47
+ it "get typically_equipped" do
48
+ VCR.use_cassette("4Runner_typical_tmv") do
49
+ data = @edmunds.typically_equipped('101351498','01741')
50
+ refute_nil data
51
+ end
52
+ end
53
+ end
54
+
55
+ describe EdmundsCars::Vin do
56
+ before do
57
+ @edmunds = EdmundsCars::Vin.new( ENV['edmunds_vehicle_api'])
58
+ end
59
+
60
+ it "decode vehicle from a vin" do
61
+ VCR.use_cassette("4Runner_vin") do
62
+ data = @edmunds.decode "JTEBU5JR8B5045387"
63
+ data["styleHolder"][0]["makeName"].must_equal "Toyota"
64
+ end
65
+ end
66
+ end
67
+
68
+ describe EdmundsCars::TrueCostToOwn do
69
+ before do
70
+ @edmunds = EdmundsCars::TrueCostToOwn.new( ENV['edmunds_vehicle_api'])
71
+ end
72
+
73
+ it "get new by style id and zip" do
74
+ VCR.use_cassette("4Runner_new_tco") do
75
+ data = @edmunds.new_by_style_id_and_zip("101351498","01741")
76
+ refute_nil data["value"]
77
+ end
78
+ end
79
+
80
+ it "get used by style id and zip" do
81
+ VCR.use_cassette("4Runner_used_tco") do
82
+ data = @edmunds.used_by_style_id_and_zip("101351498","01741")
83
+ refute_nil data["value"]
84
+ end
85
+ end
86
+
87
+ it "get availabe makes with data" do
88
+ VCR.use_cassette("tco_makes") do
89
+ data = @edmunds.makes_with_data
90
+ refute_nil data["makes"]
91
+ data["makes"]["Acura"]["id"].must_equal 200002038
92
+ data["makes"]["Acura"]["name"].must_equal "Acura"
93
+ data["makes"]["Acura"]["niceName"].must_equal "acura"
94
+ end
95
+ end
96
+
97
+ it "get availabe models with data" do
98
+ make_id = nil
99
+ VCR.use_cassette("tco_makes") do
100
+ make_data = @edmunds.makes_with_data
101
+ make_id = make_data["makes"]["Land Rover"]["id"]
102
+ end
103
+ VCR.use_cassette("tco_models") do
104
+ data = @edmunds.models_with_data( make_id )
105
+ refute_nil data["models"]
106
+ data["models"]["lr2:SUV"]["name"].must_equal "LR2 SUV"
107
+ end
108
+ end
109
+
110
+ end
@@ -0,0 +1,19 @@
1
+ require 'edmunds_cars'
2
+
3
+ require 'turn/autorun'
4
+ require 'webmock/minitest'
5
+ require 'vcr'
6
+ Turn.config do |c|
7
+ # :outline - turn's original case/test outline mode [default]
8
+ c.format = :outline
9
+ # turn on invoke/execute tracing, enable full backtrace
10
+ c.trace = 5
11
+ c.verbose = true
12
+ # use humanized test names (works only with :outline format)
13
+ c.natural = true
14
+ end
15
+ #VCR config
16
+ VCR.configure do |c|
17
+ c.cassette_library_dir = 'spec/fixtures/vehicle_cassettes'
18
+ c.hook_into :webmock
19
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: edmunds_cars
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Conner Wingard
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: jeweler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rdoc
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: httparty
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 0.9.0
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 0.9.0
94
+ description: ! 'Easily query information about cars through the edmunds api. '
95
+ email: conner@connerwingard.com
96
+ executables: []
97
+ extensions: []
98
+ extra_rdoc_files:
99
+ - LICENSE.txt
100
+ - README.md
101
+ files:
102
+ - Gemfile
103
+ - Gemfile.lock
104
+ - LICENSE.txt
105
+ - README.md
106
+ - Rakefile
107
+ - edmunds_cars.gemspec
108
+ - lib/edmunds_cars.rb
109
+ - lib/edmunds_cars/consumer_reviews.rb
110
+ - lib/edmunds_cars/depreciation.rb
111
+ - lib/edmunds_cars/incentives.rb
112
+ - lib/edmunds_cars/maintenance.rb
113
+ - lib/edmunds_cars/make_ids.rb
114
+ - lib/edmunds_cars/makes.rb
115
+ - lib/edmunds_cars/models.rb
116
+ - lib/edmunds_cars/photos.rb
117
+ - lib/edmunds_cars/resale.rb
118
+ - lib/edmunds_cars/styles.rb
119
+ - lib/edmunds_cars/total_cash_price.rb
120
+ - lib/edmunds_cars/true_cost_to_own.rb
121
+ - lib/edmunds_cars/true_market_value.rb
122
+ - lib/edmunds_cars/vehicles.rb
123
+ - lib/edmunds_cars/version.rb
124
+ - lib/edmunds_cars/vin.rb
125
+ - spec/lib/edmunds_cars/vehicle_spec.rb
126
+ - spec/spec_helper.rb
127
+ homepage: http://github.com/ConnerMan/edmunds_cars
128
+ licenses:
129
+ - MIT
130
+ post_install_message:
131
+ rdoc_options: []
132
+ require_paths:
133
+ - lib
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ none: false
136
+ requirements:
137
+ - - ! '>='
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ segments:
141
+ - 0
142
+ hash: -2043660920753879483
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ none: false
145
+ requirements:
146
+ - - ! '>='
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 1.8.24
152
+ signing_key:
153
+ specification_version: 3
154
+ summary: A wrapper for the edmunds.com REST api
155
+ test_files: []