mapquest 0.0.1 → 0.0.2

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.
@@ -0,0 +1,61 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe MapQuest do
4
+
5
+ subject { MapQuest }
6
+
7
+ describe '.new' do
8
+
9
+ context "without api_key" do
10
+
11
+ it 'should raise ArgumentError' do
12
+ expect { subject.new }.to raise_error(ArgumentError)
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+
19
+ describe "instance" do
20
+
21
+ let(:key) { 'xxx' }
22
+ subject(:instance) { MapQuest.new(key) }
23
+
24
+ it { should be_an_instance_of MapQuest }
25
+
26
+ its(:api_key) { should == key }
27
+
28
+ describe '#geocoding' do
29
+ subject(:geocoding) { instance.geocoding }
30
+ it { should be_an_instance_of MapQuest::Services::Geocoding }
31
+ its(:mapquest) { should == instance }
32
+
33
+ end
34
+
35
+ describe '#directions' do
36
+ subject(:directions) { instance.directions }
37
+ it { should be_an_instance_of MapQuest::Services::Directions }
38
+ its(:mapquest) { should == instance }
39
+
40
+ end
41
+
42
+ describe '#request' do
43
+ api_method = {:location => :geocoding, :version => 1, :call => 'address' }
44
+ subject(:request) { instance.request api_method, { :location => 'London, UK' }, MapQuest::Response }
45
+
46
+ fixture = fixture 'geocoding/location_only'
47
+ query = {
48
+ :key => 'xxx',
49
+ :location => 'London, UK'
50
+ }
51
+
52
+ stub_request(:get, 'www.mapquestapi.com/geocoding/v1/address').
53
+ with(:query => query).
54
+ to_return(:body => fixture)
55
+
56
+ it { should be_an_instance_of MapQuest::Response }
57
+ end
58
+
59
+ end
60
+
61
+ end
@@ -0,0 +1,14 @@
1
+ require 'mapquest'
2
+ require 'webmock'
3
+
4
+ RSpec.configure do |config|
5
+ include WebMock::API
6
+ config.treat_symbols_as_metadata_keys_with_true_values = true
7
+ config.run_all_when_everything_filtered = true
8
+ config.filter_run :focus
9
+
10
+ def fixture(filename)
11
+ File.open(File.dirname(__FILE__) + '/fixtures/' + filename + '.json', 'r').read
12
+ end
13
+
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mapquest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-11 00:00:00.000000000 Z
12
+ date: 2013-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &17780900 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,15 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
24
+ version_requirements: *17780900
30
25
  - !ruby/object:Gem::Dependency
31
26
  name: rest-client
32
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &17780480 !ruby/object:Gem::Requirement
33
28
  none: false
34
29
  requirements:
35
30
  - - ! '>='
@@ -37,47 +32,43 @@ dependencies:
37
32
  version: '0'
38
33
  type: :runtime
39
34
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
35
+ version_requirements: *17780480
46
36
  - !ruby/object:Gem::Dependency
47
37
  name: rspec
48
- requirement: !ruby/object:Gem::Requirement
38
+ requirement: &17779980 !ruby/object:Gem::Requirement
49
39
  none: false
50
40
  requirements:
51
41
  - - ~>
52
42
  - !ruby/object:Gem::Version
53
- version: 2.8.0
43
+ version: '2.8'
54
44
  type: :development
55
45
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: 2.8.0
46
+ version_requirements: *17779980
62
47
  - !ruby/object:Gem::Dependency
63
48
  name: bundler
64
- requirement: !ruby/object:Gem::Requirement
49
+ requirement: &17779480 !ruby/object:Gem::Requirement
65
50
  none: false
66
51
  requirements:
67
52
  - - ~>
68
53
  - !ruby/object:Gem::Version
69
- version: '1.3'
54
+ version: '1.0'
70
55
  type: :development
71
56
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
57
+ version_requirements: *17779480
58
+ - !ruby/object:Gem::Dependency
59
+ name: webmock
60
+ requirement: &17779020 !ruby/object:Gem::Requirement
73
61
  none: false
74
62
  requirements:
75
63
  - - ~>
76
64
  - !ruby/object:Gem::Version
77
- version: '1.3'
65
+ version: '1.11'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *17779020
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rake
80
- requirement: !ruby/object:Gem::Requirement
71
+ requirement: &17778640 !ruby/object:Gem::Requirement
81
72
  none: false
82
73
  requirements:
83
74
  - - ! '>='
@@ -85,12 +76,7 @@ dependencies:
85
76
  version: '0'
86
77
  type: :development
87
78
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
79
+ version_requirements: *17778640
94
80
  description: Retrieve data from various MapQuest web services
95
81
  email:
96
82
  - me@ggordan.com
@@ -99,6 +85,7 @@ extensions: []
99
85
  extra_rdoc_files: []
100
86
  files:
101
87
  - .gitignore
88
+ - .rspec
102
89
  - .travis.yml
103
90
  - Gemfile
104
91
  - LICENSE.txt
@@ -112,12 +99,21 @@ files:
112
99
  - lib/mapquest/services/geocoding.rb
113
100
  - lib/mapquest/version.rb
114
101
  - mapquest.gemspec
115
- - test/directions_spec.rb
116
- - test/fixtures/invalid_key.json
117
- - test/fixtures/no_data.json
118
- - test/fixtures/results.json
119
- - test/geocoding_spec.rb
120
- - test/spec_helper.rb
102
+ - spec/directions_spec.rb
103
+ - spec/fixtures/directions/invalid_key.json
104
+ - spec/fixtures/directions/invalid_value.json
105
+ - spec/fixtures/directions/route_only.json
106
+ - spec/fixtures/directions/valid_route.json
107
+ - spec/fixtures/geocoding/illegal_argument.json
108
+ - spec/fixtures/geocoding/invalid_key.json
109
+ - spec/fixtures/geocoding/location_maxResults.json
110
+ - spec/fixtures/geocoding/location_only.json
111
+ - spec/fixtures/geocoding/location_thumbMaps.json
112
+ - spec/fixtures/geocoding/location_thumbMaps_maxResults.json
113
+ - spec/fixtures/geocoding/reverse_location.json
114
+ - spec/geocoding_spec.rb
115
+ - spec/mapquest_spec.rb
116
+ - spec/spec_helper.rb
121
117
  homepage: ''
122
118
  licenses:
123
119
  - MIT
@@ -139,15 +135,23 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
135
  version: '0'
140
136
  requirements: []
141
137
  rubyforge_project:
142
- rubygems_version: 1.8.23
138
+ rubygems_version: 1.8.11
143
139
  signing_key:
144
140
  specification_version: 3
145
141
  summary: Retrieve data from various MapQuest web services
146
142
  test_files:
147
- - test/directions_spec.rb
148
- - test/fixtures/invalid_key.json
149
- - test/fixtures/no_data.json
150
- - test/fixtures/results.json
151
- - test/geocoding_spec.rb
152
- - test/spec_helper.rb
153
- has_rdoc:
143
+ - spec/directions_spec.rb
144
+ - spec/fixtures/directions/invalid_key.json
145
+ - spec/fixtures/directions/invalid_value.json
146
+ - spec/fixtures/directions/route_only.json
147
+ - spec/fixtures/directions/valid_route.json
148
+ - spec/fixtures/geocoding/illegal_argument.json
149
+ - spec/fixtures/geocoding/invalid_key.json
150
+ - spec/fixtures/geocoding/location_maxResults.json
151
+ - spec/fixtures/geocoding/location_only.json
152
+ - spec/fixtures/geocoding/location_thumbMaps.json
153
+ - spec/fixtures/geocoding/location_thumbMaps_maxResults.json
154
+ - spec/fixtures/geocoding/reverse_location.json
155
+ - spec/geocoding_spec.rb
156
+ - spec/mapquest_spec.rb
157
+ - spec/spec_helper.rb
@@ -1,21 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "MapQuest::Services::Directions" do
4
-
5
- before :all do
6
- init
7
- end
8
-
9
- describe '.new' do
10
- it 'should be an instance of' do
11
- @mapquest.directions.should be_an_instance_of MapQuest::Services::Directions
12
- end
13
- end
14
-
15
- describe '#get' do
16
- it 'raise an error if :from and :to are missing' do
17
- expect { @mapquest.directions.get }.to raise_error
18
- end
19
- end
20
-
21
- end
@@ -1 +0,0 @@
1
- {"results":[{"locations":[{"latLng":{"lng":-99.141968,"lat":39.527596},"adminArea4":"","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"","street":"","adminArea1":"US","adminArea3":"","type":"s","displayLatLng":{"lng":-99.141968,"lat":39.527596},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"COUNTRY","geocodeQualityCode":"A1XAX","mapUrl":"http://www.mapquestapi.com/staticmap/v4/getmap?key=Fmjtd|luub2d6ynu,7a=o5-9u22gr&type=map&size=225,160&pois=purple-1,39.527596,-99.141968,0,0|&center=39.527596,-99.141968&zoom=2&rand=-1587667519","adminArea3Type":"State"}],"providedLocation":{"location":"adsddhasuidy3289asda"}}],"options":{"ignoreLatLngInput":false,"maxResults":-1,"thumbMaps":true},"info":{"copyright":{"text":"© 2013 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"© 2013 MapQuest, Inc."},"statuscode":0,"messages":[]}}
@@ -1 +0,0 @@
1
- {"results":[{"locations":[{"latLng":{"lng":-0.12766,"lat":51.507276},"adminArea4":"London","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"London","street":"","adminArea1":"GB","adminArea3":"England","type":"s","displayLatLng":{"lng":-0.12766,"lat":51.507276},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"CITY","geocodeQualityCode":"A5XAX","mapUrl":"http://www.mapquestapi.com/staticmap/v4/getmap?key=Fmjtd|luub2d6ynu,7a=o5-9u22gr&type=map&size=225,160&pois=purple-1,51.5072759,-0.1276597,0,0|&center=51.5072759,-0.1276597&zoom=12&rand=-1536541888","adminArea3Type":"State"},{"latLng":{"lng":-0.08729,"lat":51.514624},"adminArea4":"City of London","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"","street":"","adminArea1":"GB","adminArea3":"England","type":"s","displayLatLng":{"lng":-0.08729,"lat":51.514624},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"COUNTY","geocodeQualityCode":"A4XXX","mapUrl":"http://www.mapquestapi.com/staticmap/v4/getmap?key=Fmjtd|luub2d6ynu,7a=o5-9u22gr&type=map&size=225,160&pois=purple-2,51.5146237,-0.0872901,0,0|&center=51.5146237,-0.0872901&zoom=9&rand=-1536541888","adminArea3Type":"State"},{"latLng":{"lng":-3.049338,"lat":59.135418},"adminArea4":"Rousay","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"London","street":"","adminArea1":"GB","adminArea3":"Scotland","type":"s","displayLatLng":{"lng":-3.049338,"lat":59.135418},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"CITY","geocodeQualityCode":"A5XAX","mapUrl":"http://www.mapquestapi.com/staticmap/v4/getmap?key=Fmjtd|luub2d6ynu,7a=o5-9u22gr&type=map&size=225,160&pois=purple-3,59.1354177,-3.0493379,0,0|&center=59.1354177,-3.0493379&zoom=12&rand=-1536541888","adminArea3Type":"State"},{"latLng":{"lng":-0.141158,"lat":51.517561},"adminArea4":"London","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"City of Westminster","street":"Mortimer Street","adminArea1":"GB","adminArea3":"England","type":"s","displayLatLng":{"lng":-0.141158,"lat":51.517561},"linkId":0,"postalCode":"W1B 3DG","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"ADDRESS","geocodeQualityCode":"L1XXX","mapUrl":"http://www.mapquestapi.com/staticmap/v4/getmap?key=Fmjtd|luub2d6ynu,7a=o5-9u22gr&type=map&size=225,160&pois=purple-4,51.5175614698645,-0.141158489226213,0,0|&center=51.5175614698645,-0.141158489226213&zoom=15&rand=-1536541888","adminArea3Type":"State"},{"latLng":{"lng":-2.978759,"lat":51.350317},"adminArea4":"North Somerset","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"Weston-super-Mare","street":"Waterloo Street","adminArea1":"GB","adminArea3":"England","type":"s","displayLatLng":{"lng":-2.978759,"lat":51.350317},"linkId":0,"postalCode":"","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"ADDRESS","geocodeQualityCode":"L1XXX","mapUrl":"http://www.mapquestapi.com/staticmap/v4/getmap?key=Fmjtd|luub2d6ynu,7a=o5-9u22gr&type=map&size=225,160&pois=purple-5,51.3503173,-2.9787593,0,0|&center=51.3503173,-2.9787593&zoom=15&rand=-1536541888","adminArea3Type":"State"},{"latLng":{"lng":-0.132185,"lat":51.516195},"adminArea4":"London","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"City of Westminster","street":"47 Oxford Street","adminArea1":"GB","adminArea3":"England","type":"s","displayLatLng":{"lng":-0.132185,"lat":51.516195},"linkId":0,"postalCode":"W1D 2DU","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"ADDRESS","geocodeQualityCode":"L1XXX","mapUrl":"http://www.mapquestapi.com/staticmap/v4/getmap?key=Fmjtd|luub2d6ynu,7a=o5-9u22gr&type=map&size=225,160&pois=purple-6,51.5161952,-0.1321849,0,0|&center=51.5161952,-0.1321849&zoom=15&rand=-1536541888","adminArea3Type":"State"},{"latLng":{"lng":-0.111696,"lat":51.601489},"adminArea4":"London","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"London Borough of Haringey","street":"Canning Crescent","adminArea1":"GB","adminArea3":"England","type":"s","displayLatLng":{"lng":-0.111696,"lat":51.601489},"linkId":0,"postalCode":"N22 8LE","sideOfStreet":"N","dragPoint":false,"adminArea1Type":"Country","geocodeQuality":"ADDRESS","geocodeQualityCode":"L1XXX","mapUrl":"http://www.mapquestapi.com/staticmap/v4/getmap?key=Fmjtd|luub2d6ynu,7a=o5-9u22gr&type=map&size=225,160&pois=purple-7,51.6014893,-0.1116958,0,0|&center=51.6014893,-0.1116958&zoom=15&rand=-1536541888","adminArea3Type":"State"}],"providedLocation":{"location":"London, UK"}}],"options":{"ignoreLatLngInput":false,"maxResults":-1,"thumbMaps":true},"info":{"copyright":{"text":"© 2013 MapQuest, Inc.","imageUrl":"http://api.mqcdn.com/res/mqlogo.gif","imageAltText":"© 2013 MapQuest, Inc."},"statuscode":0,"messages":[]}}
@@ -1,78 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe 'MapQuest::Services::Geocoding' do
4
-
5
- context 'when valid request' do
6
-
7
- before :all do
8
- @mapquest = MapQuest.new 'xxx'
9
- @response = MapQuest::Services::Geocoding::Response.new fixture 'results'
10
- @response.valid.should == true
11
- end
12
-
13
- describe '.new' do
14
- it 'should be an instance of' do
15
- @mapquest.geocoding.should be_an_instance_of MapQuest::Services::Geocoding
16
- end
17
- end
18
-
19
- describe '#decode' do
20
- it 'should raise an error' do
21
- expect { @mapquest.geocoding.decode }.to raise_error
22
- end
23
- it 'should be an instance of' do
24
- @response.should be_an_instance_of MapQuest::Services::Geocoding::Response
25
- end
26
- end
27
-
28
- describe '#Request' do
29
- it 'should return 0' do
30
- @response.status[:code].should == 0
31
- end
32
- it 'should be empty' do
33
- @response.status[:messages].should == []
34
- end
35
- it 'should return locations' do
36
- @response.locations.should_not == {}
37
- end
38
- end
39
-
40
- end
41
-
42
- context 'when invalid request' do
43
-
44
- before :all do
45
- @mapquest = MapQuest.new 'xxx'
46
- @response = @mapquest.geocoding.decode :location => "London, UK"
47
- @response.valid.should == false
48
- end
49
-
50
- describe '.new' do
51
- it 'should be an instance of' do
52
- @mapquest.geocoding.should be_an_instance_of MapQuest::Services::Geocoding
53
- end
54
- end
55
-
56
- describe '#decode' do
57
- it 'should raise an error' do
58
- expect { @mapquest.geocoding.decode }.to raise_error
59
- end
60
- it 'should be an instance of' do
61
- @response.should be_an_instance_of MapQuest::Services::Geocoding::Response
62
- end
63
- end
64
-
65
- describe '#Request' do
66
- it 'should not return 0' do
67
- @response.status[:code].should_not == 0
68
- end
69
- it 'should not be empty' do
70
- @response.status[:messages].should_not == []
71
- end
72
- it 'should not return 0' do
73
- @response.locations[:code].should_not == 0
74
- end
75
- end
76
-
77
- end
78
- end
@@ -1,13 +0,0 @@
1
- require 'mapquest'
2
-
3
- RSpec.configure do |config|
4
-
5
- def fixture(filename)
6
- File.open(File.dirname(__FILE__) + '/fixtures/' + filename + '.json', 'r').read
7
- end
8
-
9
- def init
10
- @mapquest = MapQuest.new 'xxx'
11
- end
12
-
13
- end