parkwhiz 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -0
- data/CHANGELOG.rdoc +3 -0
- data/Gemfile +2 -0
- data/README.md +6 -0
- data/lib/parkwhiz.rb +1 -0
- data/lib/parkwhiz/search.rb +1 -1
- data/lib/parkwhiz/venue.rb +28 -0
- data/lib/parkwhiz/version.rb +1 -1
- data/spec/responses/venue_search_response.json +1 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/venue_spec.rb +31 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e33174d41e41a7920e8f18a98ab4ffb56f6b926f
|
4
|
+
data.tar.gz: 50539c343492b60794011ae3ac1bfdcf9584e0c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 306115dda84ad8a5b088f84920a8ce0a53e0d581510fd63061ebb0e44dec0e4f1d15151e554441ebaa8e84b6fc846d2f83a15e3eeb66039ad008f359c270b139
|
7
|
+
data.tar.gz: 32f41f062d94d963188b5c9873707b60ccb610878b649682fbbb74fae6ef928a6cec2b9ac18ab3b570ae4eeb887c4ea1e6523029647a0547d246b89e46b60077
|
data/.travis.yml
ADDED
data/CHANGELOG.rdoc
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Parkwhiz
|
2
2
|
|
3
|
+
[![Code Climate](https://codeclimate.com/github/austinrfnd/parkwhiz.png)](https://codeclimate.com/github/austinrfnd/parkwhiz)
|
4
|
+
[![Build Status](https://travis-ci.org/austinrfnd/parkwhiz.svg?branch=master)](https://travis-ci.org/austinrfnd/parkwhiz)
|
5
|
+
[![Test Coverage](https://codeclimate.com/github/austinrfnd/parkwhiz/coverage.png)](https://codeclimate.com/github/austinrfnd/parkwhiz)
|
6
|
+
|
3
7
|
A gem wrapper to Parkwhiz API.
|
4
8
|
|
5
9
|
## Installation
|
@@ -24,7 +28,9 @@ Or install it yourself as:
|
|
24
28
|
Parkwhiz.api_key = "my api key"
|
25
29
|
|
26
30
|
locations = Parkwhiz.search({destination: '1 World Way, Los Angeles, CA 90045'})
|
31
|
+
|
27
32
|
# Array of ParkwhizLocations
|
33
|
+
locations
|
28
34
|
```
|
29
35
|
## Run Specs
|
30
36
|
|
data/lib/parkwhiz.rb
CHANGED
data/lib/parkwhiz/search.rb
CHANGED
@@ -16,7 +16,7 @@ module Parkwhiz
|
|
16
16
|
request.params.merge!(search_parameters)
|
17
17
|
end
|
18
18
|
|
19
|
-
raise SearchError.new(response.body['error']) if response.body['error']
|
19
|
+
raise SearchError.new(response.body['error']) if response.body.kind_of?(Hash) && response.body['error']
|
20
20
|
|
21
21
|
response.body['parking_listings'].collect{|parking_listing_json| Location.new(parking_listing_json)}
|
22
22
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Parkwhiz
|
2
|
+
class Venue
|
3
|
+
include Virtus.model
|
4
|
+
|
5
|
+
attribute :name, String
|
6
|
+
attribute :address, String
|
7
|
+
attribute :city, String
|
8
|
+
attribute :state, String
|
9
|
+
attribute :zip, String
|
10
|
+
attribute :url_fragment, String
|
11
|
+
attribute :distance, Integer
|
12
|
+
attribute :relevancy, Integer
|
13
|
+
|
14
|
+
SEARCH_PATH = "/venue/search/"
|
15
|
+
|
16
|
+
def self.search(search_parameters)
|
17
|
+
response = Parkwhiz.connection.get do |request|
|
18
|
+
request.url SEARCH_PATH
|
19
|
+
request.params['key'] = Parkwhiz.api_key
|
20
|
+
request.params.merge!(search_parameters)
|
21
|
+
end
|
22
|
+
|
23
|
+
raise SearchError.new(response.body['error']) if response.body.kind_of?(Hash) && response.body['error']
|
24
|
+
|
25
|
+
response.body.collect{|venue_json| self.new(venue_json)}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/parkwhiz/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
[{"name":"Lafayette House","address":"109 Washington Street","city":"Foxboro","state":"MA","zip":"02035","url_fragment":"\/lafayette-house-parking\/","distance":517,"relevancy":1},{"name":"Gillette Stadium: Lot 20","address":"Foxborough Norfolk County","city":"Foxborough","state":"MA","zip":"02035","url_fragment":"\/gillette-stadium-lot-20-parking\/","distance":3776,"relevancy":1},{"name":"P10S","address":"1 Patriot Pl","city":"Foxborough","state":"MA","zip":"02035","url_fragment":"\/p10s-parking\/","distance":4210,"relevancy":1},{"name":"Patriot Place","address":"2 Patriot Place","city":"Foxboro","state":"MA","zip":"02035","url_fragment":"\/patriot-place-parking\/","distance":4102,"relevancy":1},{"name":"Renaissance Boston Patriot Place Hotel & Spa","address":"28 Patriot Place","city":"Foxboro","state":"MA","zip":"02035","url_fragment":"\/renaissance-boston-patriot-place-hotel-spa-parking-1\/","distance":4273,"relevancy":1},{"name":"22","address":"Foxborough Norfolk County","city":"Foxborough","state":"MA","zip":"02035","url_fragment":"\/22-parking\/","distance":4608,"relevancy":1},{"name":"Gillette Stadium: Lot 23","address":"1 Foxborough","city":"Foxborough","state":"MA","zip":"02035","url_fragment":"\/gillette-stadium-lot-23-parking\/","distance":5030,"relevancy":1},{"name":"P2","address":"Foxborough Norfolk County","city":"Foxborough","state":"MA","zip":"02035","url_fragment":"\/p2-parking\/","distance":5564,"relevancy":1},{"name":"New England Patriots","address":"1 Patriot Place","city":"Foxboro","state":"MA","zip":"02035","url_fragment":"\/new-england-patriots-parking\/","distance":5250,"relevancy":1},{"name":"Gillette Stadium","address":"60 Washington St.","city":"Foxboro","state":"MA","zip":"02035","url_fragment":"\/gillette-stadium-parking\/","distance":5253,"relevancy":1}]
|
data/spec/spec_helper.rb
CHANGED
data/spec/venue_spec.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
describe "Venue" do
|
2
|
+
let :connection do
|
3
|
+
double(:connection, get: nil)
|
4
|
+
end
|
5
|
+
|
6
|
+
let :venue_search_response do
|
7
|
+
File.read(File.expand_path("spec/responses/venue_search_response.json"))
|
8
|
+
end
|
9
|
+
|
10
|
+
let :invalid_search_response do
|
11
|
+
File.read(File.expand_path("spec/responses/invalid_key_response.json"))
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "search" do
|
15
|
+
it "should return an Array of Parkwhiz::Venues" do
|
16
|
+
Parkwhiz.connection = connection
|
17
|
+
expect(connection).to receive(:get) { double( body: JSON.parse(venue_search_response) ) }
|
18
|
+
venues = Parkwhiz::Venue.search({})
|
19
|
+
expect(venues).to be_kind_of(Array)
|
20
|
+
expect(venues.first).to be_kind_of(Parkwhiz::Venue)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should raise a search error if bad search response" do
|
24
|
+
expect(connection).to receive(:get) { double( body: JSON.parse(invalid_search_response) ) }
|
25
|
+
Parkwhiz.connection = connection
|
26
|
+
expect do
|
27
|
+
Parkwhiz.search({})
|
28
|
+
end.to raise_error(Parkwhiz::SearchError)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parkwhiz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Austin Fonacier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -118,6 +118,7 @@ extra_rdoc_files: []
|
|
118
118
|
files:
|
119
119
|
- ".gitignore"
|
120
120
|
- ".rspec"
|
121
|
+
- ".travis.yml"
|
121
122
|
- CHANGELOG.rdoc
|
122
123
|
- Gemfile
|
123
124
|
- LICENSE.txt
|
@@ -129,13 +130,16 @@ files:
|
|
129
130
|
- lib/parkwhiz/errors.rb
|
130
131
|
- lib/parkwhiz/location.rb
|
131
132
|
- lib/parkwhiz/search.rb
|
133
|
+
- lib/parkwhiz/venue.rb
|
132
134
|
- lib/parkwhiz/version.rb
|
133
135
|
- parkwhiz.gemspec
|
134
136
|
- spec/location_spec.rb
|
135
137
|
- spec/responses/invalid_key_response.json
|
136
138
|
- spec/responses/la_search_response.json
|
139
|
+
- spec/responses/venue_search_response.json
|
137
140
|
- spec/search_spec.rb
|
138
141
|
- spec/spec_helper.rb
|
142
|
+
- spec/venue_spec.rb
|
139
143
|
homepage: http://github.com/austinrfnd/parkwhiz
|
140
144
|
licenses:
|
141
145
|
- MIT
|
@@ -164,5 +168,7 @@ test_files:
|
|
164
168
|
- spec/location_spec.rb
|
165
169
|
- spec/responses/invalid_key_response.json
|
166
170
|
- spec/responses/la_search_response.json
|
171
|
+
- spec/responses/venue_search_response.json
|
167
172
|
- spec/search_spec.rb
|
168
173
|
- spec/spec_helper.rb
|
174
|
+
- spec/venue_spec.rb
|