carquery 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,70 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://www.carqueryapi.com/api/0.3?cmd=getYears
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 301
13
+ message: Moved Permanently
14
+ headers:
15
+ Date:
16
+ - Sat, 05 Oct 2013 13:15:01 GMT
17
+ Server:
18
+ - Apache/2.2.22 (EL)
19
+ Location:
20
+ - http://www.carqueryapi.com/api/0.3/?cmd=getYears
21
+ Content-Length:
22
+ - '337'
23
+ Connection:
24
+ - close
25
+ Content-Type:
26
+ - text/html; charset=iso-8859-1
27
+ body:
28
+ encoding: UTF-8
29
+ string: |
30
+ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
31
+ <html><head>
32
+ <title>301 Moved Permanently</title>
33
+ </head><body>
34
+ <h1>Moved Permanently</h1>
35
+ <p>The document has moved <a href="http://www.carqueryapi.com/api/0.3/?cmd=getYears">here</a>.</p>
36
+ <hr>
37
+ <address>Apache/2.2.22 (EL) Server at www.carqueryapi.com Port 80</address>
38
+ </body></html>
39
+ http_version:
40
+ recorded_at: Sat, 05 Oct 2013 13:08:35 GMT
41
+ - request:
42
+ method: get
43
+ uri: http://www.carqueryapi.com/api/0.3/?cmd=getYears
44
+ body:
45
+ encoding: US-ASCII
46
+ string: ''
47
+ headers: {}
48
+ response:
49
+ status:
50
+ code: 200
51
+ message: OK
52
+ headers:
53
+ Date:
54
+ - Sat, 05 Oct 2013 13:15:02 GMT
55
+ Server:
56
+ - Apache/2.2.22 (EL)
57
+ X-Powered-By:
58
+ - PHP/5.2.17
59
+ Connection:
60
+ - close
61
+ Transfer-Encoding:
62
+ - chunked
63
+ Content-Type:
64
+ - application/json
65
+ body:
66
+ encoding: UTF-8
67
+ string: "\r\n{ \"Years\": {\"min_year\":\"1940\", \"max_year\":\"2013\"} }"
68
+ http_version:
69
+ recorded_at: Sat, 05 Oct 2013 13:08:35 GMT
70
+ recorded_with: VCR 2.6.0
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Carquery::CarModel do
4
+ describe '.build' do
5
+ subject { described_class.build data }
6
+
7
+ context "when valid data provided" do
8
+ let(:data) { {"model_name"=>"021 C", "model_make_id"=>"ford"} }
9
+
10
+ it { should be_a described_class }
11
+
12
+ its(:title) { should eq "021 C" }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe Carquery::Make do
4
+ describe '.build' do
5
+ subject { described_class.build data }
6
+
7
+ context "when valid data provided" do
8
+ let(:data) { {"make_id"=>"abarth", "make_display"=>"Abarth", "make_is_common"=>"0", "make_country"=>"Italy"} }
9
+
10
+ it { should be_a described_class }
11
+
12
+ its(:code) { should eq "abarth" }
13
+ its(:title) { should eq "Abarth" }
14
+ its(:is_common) { should eq false }
15
+ its(:country) { should eq "Italy" }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe Carquery::Trim do
4
+ describe '.build' do
5
+ subject { described_class.build data }
6
+
7
+ context "when valid data provided" do
8
+ let(:data) { {"model_id"=>"57610", "model_make_id"=>"acura", "model_name"=>"ILX", "model_trim"=>" Hybrid", "model_year"=>"2013", "model_body"=>"Sedan", "model_engine_position"=>"Front", "model_engine_cc"=>"1500", "model_engine_cyl"=>"4", "model_engine_type"=>"in-line", "model_engine_valves_per_cyl"=>"8", "model_engine_power_ps"=>"111", "model_engine_power_rpm"=>"5500", "model_engine_torque_nm"=>"172", "model_engine_torque_rpm"=>"3500", "model_engine_bore_mm"=>"73.0", "model_engine_stroke_mm"=>"89.0", "model_engine_compression"=>"10.8", "model_engine_fuel"=>"Gasoline", "model_top_speed_kph"=>nil, "model_0_to_100_kph"=>nil, "model_drive"=>"Front", "model_transmission_type"=>"CVT ", "model_seats"=>"5", "model_doors"=>"4", "model_weight_kg"=>"1356", "model_length_mm"=>"4550", "model_width_mm"=>"1794", "model_height_mm"=>"1412", "model_wheelbase_mm"=>"2670", "model_lkm_hwy"=>"4.8", "model_lkm_mixed"=>nil, "model_lkm_city"=>"5.0", "model_fuel_cap_l"=>"50", "model_sold_in_us"=>"1", "model_co2"=>nil, "model_make_display"=>nil, "make_display"=>"Acura", "make_country"=>"USA"} }
9
+
10
+ it { should be_a described_class }
11
+
12
+ its(:id) { should eq 57610 }
13
+ its(:title) { should eq "ILX" }
14
+ its(:make_code) { should eq "acura" }
15
+ its(:trim) { should eq "Hybrid" }
16
+ its(:year) { should eq 2013 }
17
+ its(:body) { should eq "Sedan" }
18
+ its(:engine_position) { should eq "Front" }
19
+ its(:engine_cc) { should eq 1500 }
20
+ its(:engine_cyl) { should eq 4 }
21
+ its(:engine_type) { should eq "in-line" }
22
+ its(:engine_valves_per_cyl){ should eq 8 }
23
+ its(:engine_power_ps) { should eq 111 }
24
+ its(:engine_power_rpm) { should eq 5500 }
25
+ its(:engine_torque_nm) { should eq 172 }
26
+ its(:engine_torque_rpm) { should eq 3500 }
27
+ its(:engine_bore_mm) { should eq 73.0 }
28
+ its(:engine_stroke_mm) { should eq 89.0 }
29
+ its(:engine_compression) { should eq 10.8 }
30
+ its(:engine_fuel) { should eq "Gasoline" }
31
+ its(:top_speed_kph) { should be_nil }
32
+ its(:speedup_0_to_100_kph) { should be_nil }
33
+ its(:drive) { should eq "Front" }
34
+ its(:transmission_type) { should eq "CVT" }
35
+ its(:seats) { should eq 5 }
36
+ its(:doors) { should eq 4 }
37
+ its(:weight_kg) { should eq 1356 }
38
+ its(:length_mm) { should eq 4550 }
39
+ its(:width_mm) { should eq 1794 }
40
+ its(:height_mm) { should eq 1412 }
41
+ its(:wheelbase_mm) { should eq 2670 }
42
+ its(:lkm_hwy) { should eq 4.8 }
43
+ its(:lkm_mixed) { should be_nil }
44
+ its(:lkm_city) { should eq 5.0 }
45
+ its(:fuel_cap_l) { should eq 50 }
46
+ its(:sold_in_us) { should eq true }
47
+ its(:co2) { should be_nil }
48
+ its(:make_title) { should eq "Acura" }
49
+ its(:make_country) { should eq "USA" }
50
+
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,17 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rubygems'
4
+ require 'rspec'
5
+ require 'webmock/rspec'
6
+ require 'vcr'
7
+ require 'carquery'
8
+
9
+ Dir["./spec/support/**/*.rb"].each {|f| require f}
10
+
11
+ RSpec.configure do |config|
12
+ config.treat_symbols_as_metadata_keys_with_true_values = true
13
+ config.run_all_when_everything_filtered = true
14
+ config.filter_run :focus
15
+
16
+ config.order = 'random'
17
+ end
@@ -0,0 +1,7 @@
1
+ VCR.configure do |c|
2
+ c.cassette_library_dir = 'spec/fixtures'
3
+ c.configure_rspec_metadata!
4
+ c.hook_into :webmock
5
+ c.default_cassette_options = { record: :new_episodes }
6
+ c.allow_http_connections_when_no_cassette = true
7
+ end
metadata ADDED
@@ -0,0 +1,194 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: carquery
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rustam Sharshenov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: addressable
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: vcr
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: www.carqueryapi.com API client
112
+ email:
113
+ - rustam@sharshenov.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - .rspec
120
+ - Gemfile
121
+ - LICENSE.txt
122
+ - README.md
123
+ - Rakefile
124
+ - carquery.gemspec
125
+ - lib/carquery.rb
126
+ - lib/carquery/dsl/get_makes.rb
127
+ - lib/carquery/dsl/get_models.rb
128
+ - lib/carquery/dsl/get_trim.rb
129
+ - lib/carquery/dsl/get_trims.rb
130
+ - lib/carquery/dsl/get_years_range.rb
131
+ - lib/carquery/errors.rb
132
+ - lib/carquery/request.rb
133
+ - lib/carquery/resources/base_struct.rb
134
+ - lib/carquery/resources/car_model.rb
135
+ - lib/carquery/resources/make.rb
136
+ - lib/carquery/resources/trim.rb
137
+ - lib/carquery/version.rb
138
+ - spec/dsl/get_makes_spec.rb
139
+ - spec/dsl/get_models_spec.rb
140
+ - spec/dsl/get_trim_spec.rb
141
+ - spec/dsl/get_trims_spec.rb
142
+ - spec/dsl/get_years_range_spec.rb
143
+ - spec/fixtures/get_makes/successful.yml
144
+ - spec/fixtures/get_models/successful.yml
145
+ - spec/fixtures/get_trim/not_found.yml
146
+ - spec/fixtures/get_trim/successful.yml
147
+ - spec/fixtures/get_trims/successful.yml
148
+ - spec/fixtures/get_years_range/successful.yml
149
+ - spec/resources/car_model_spec.rb
150
+ - spec/resources/make_spec.rb
151
+ - spec/resources/trim_spec.rb
152
+ - spec/spec_helper.rb
153
+ - spec/support/vcr.rb
154
+ homepage: ''
155
+ licenses:
156
+ - MIT
157
+ metadata: {}
158
+ post_install_message:
159
+ rdoc_options: []
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - '>='
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ requirements: []
173
+ rubyforge_project:
174
+ rubygems_version: 2.0.7
175
+ signing_key:
176
+ specification_version: 4
177
+ summary: Provides DSL for a www.carqueryapi.com API.
178
+ test_files:
179
+ - spec/dsl/get_makes_spec.rb
180
+ - spec/dsl/get_models_spec.rb
181
+ - spec/dsl/get_trim_spec.rb
182
+ - spec/dsl/get_trims_spec.rb
183
+ - spec/dsl/get_years_range_spec.rb
184
+ - spec/fixtures/get_makes/successful.yml
185
+ - spec/fixtures/get_models/successful.yml
186
+ - spec/fixtures/get_trim/not_found.yml
187
+ - spec/fixtures/get_trim/successful.yml
188
+ - spec/fixtures/get_trims/successful.yml
189
+ - spec/fixtures/get_years_range/successful.yml
190
+ - spec/resources/car_model_spec.rb
191
+ - spec/resources/make_spec.rb
192
+ - spec/resources/trim_spec.rb
193
+ - spec/spec_helper.rb
194
+ - spec/support/vcr.rb