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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: daf3fa24873048348de4cec14e569370581adaab
4
- data.tar.gz: edc81c594b145791c5bef3c3ccc0bc23d792f901
3
+ metadata.gz: e33174d41e41a7920e8f18a98ab4ffb56f6b926f
4
+ data.tar.gz: 50539c343492b60794011ae3ac1bfdcf9584e0c6
5
5
  SHA512:
6
- metadata.gz: b6bf8d75505ee5774fe0ee0ce302cd7b3f38dea73f007332a0373323eb8c71abbd059c8a324ba2fd9fc31f8849d3c5a023cee343677a75f61d7ffce648a29959
7
- data.tar.gz: d50f7b902666ee84b364230dd29322e37ed7332b88154df8a5f77983d45d720dd08a1804532fe0351be86b4f8b6c565627e282dd0949fd332173786cd5ee9b03
6
+ metadata.gz: 306115dda84ad8a5b088f84920a8ce0a53e0d581510fd63061ebb0e44dec0e4f1d15151e554441ebaa8e84b6fc846d2f83a15e3eeb66039ad008f359c270b139
7
+ data.tar.gz: 32f41f062d94d963188b5c9873707b60ccb610878b649682fbbb74fae6ef928a6cec2b9ac18ab3b570ae4eeb887c4ea1e6523029647a0547d246b89e46b60077
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
6
+ - 2.1.1
7
+ addons:
8
+ code_climate:
9
+ repo_token: df035fb6d493ca2464c3c8e39becde1c101cab90f887692f9199fa1b0472def3
@@ -1,2 +1,5 @@
1
+ === 0.2.0
2
+ - Venue search endpoint
3
+
1
4
  === 0.1.0
2
5
  - Search API endpoint
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in parkwhiz.gemspec
4
4
  gemspec
5
+
6
+ gem "codeclimate-test-reporter", group: :test, require: nil
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
 
@@ -7,6 +7,7 @@ require 'parkwhiz/configuration'
7
7
  require 'parkwhiz/connection'
8
8
  require 'parkwhiz/location'
9
9
  require 'parkwhiz/search'
10
+ require 'parkwhiz/venue'
10
11
 
11
12
  module Parkwhiz
12
13
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Parkwhiz
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -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}]
@@ -1,2 +1,4 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
1
3
  require 'parkwhiz'
2
4
  require 'json'
@@ -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.1.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-24 00:00:00.000000000 Z
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