tcocca-yelp4r 1.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,49 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require File.dirname(__FILE__) + '/../../lib/yelp4r'
3
+
4
+ describe Yelp4r::Categories do
5
+ include Yelp4rSpecHelper
6
+ include Yelp4rCatsSpecHelper
7
+
8
+ before do
9
+ @yelp_cats = Yelp4r::Categories.new
10
+ @yelp_cats.parse_url = File.dirname(__FILE__) + "/../fixtures/categories.html"
11
+ end
12
+
13
+ describe 'initialize' do
14
+ it 'should set the url for the page to parse' do
15
+ @yelp_cats.parse_url.should_not be_blank
16
+ end
17
+ end
18
+
19
+ describe 'list' do
20
+ before do
21
+ @cats = @yelp_cats.list
22
+ end
23
+
24
+ it "should return the list of categies" do
25
+ @cats.should_not be_blank
26
+ @cats.should == yelp4r_test_cats_list
27
+ end
28
+ end
29
+
30
+ describe 'options_from_list' do
31
+ it "should return an array of options" do
32
+ @yelp_cats.options_from_list.should_not be_blank
33
+ @yelp_cats.options_from_list.should == yelp4r_test_cats_opts
34
+ end
35
+
36
+ it "should return an array of options with a single selected value when given a string" do
37
+ @opts = @yelp_cats.options_from_list("gyms")
38
+ @opts.should_not be_blank
39
+ @opts.should == yelp4r_test_cats_opts_single_selected
40
+ end
41
+
42
+ it "should return an array of options with multiple selected values when given a array" do
43
+ @opts = @yelp_cats.options_from_list(["gyms", "autoglass", "appliances"])
44
+ @opts.should_not be_blank
45
+ @opts.should == yelp4r_test_cats_opts_multiple_selected
46
+ end
47
+ end
48
+
49
+ end
@@ -0,0 +1,22 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require File.dirname(__FILE__) + '/../../lib/yelp4r'
3
+ require File.dirname(__FILE__) + '/../../lib/yelp4r/client'
4
+
5
+ describe Yelp4r::Client do
6
+ include Yelp4rSpecHelper
7
+
8
+ describe 'initialize' do
9
+ before do
10
+ @client = yelp4r_client
11
+ end
12
+
13
+ it 'sets the base_uri' do
14
+ @client.class.base_uri.should == 'http://api.yelp.com'
15
+ end
16
+
17
+ it 'sets default params to include the api key' do
18
+ @client.class.default_params.should == {:ywsid => 'jprr4VyNVMGZrd-FARdSQA'}
19
+ end
20
+ end
21
+
22
+ end
@@ -0,0 +1,82 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require File.dirname(__FILE__) + '/../../lib/yelp4r'
3
+ require File.dirname(__FILE__) + '/../../lib/yelp4r/client'
4
+ require File.dirname(__FILE__) + '/../../lib/yelp4r/neighborhood_search'
5
+ require File.dirname(__FILE__) + '/../../lib/yelp4r/response'
6
+
7
+ describe Yelp4r::NeighborhoodSearch do
8
+ include Yelp4rSpecHelper
9
+
10
+ before do
11
+ @client = yelp4r_client
12
+ @neighborhood_search = Yelp4r::NeighborhoodSearch.new(@client)
13
+ end
14
+
15
+ describe 'initialize' do
16
+ it 'set the client' do
17
+ @neighborhood_search.client.class.should == Yelp4r::Client
18
+ end
19
+ end
20
+
21
+ describe 'search_by_geocode' do
22
+ it 'should return results when passed a lat lon' do
23
+ @results = get_neighborhoods(42.3500, -71.0780)
24
+ @results.should be_success
25
+ @results.data.should_not be_blank
26
+ @results.error_message.should be_blank
27
+ end
28
+
29
+ it 'should not return results when given invalid params' do
30
+ @results = get_neighborhoods(42.3500, '')
31
+ @results.should_not be_success
32
+ @results.data.should be_blank
33
+ @results.error_message.should_not be_blank
34
+ end
35
+
36
+ def get_neighborhoods(*params)
37
+ @neighborhood_search.search_by_geocode(*params)
38
+ end
39
+ end
40
+
41
+ describe 'search_by_location' do
42
+ it 'should return results when given a location' do
43
+ @results = get_neighborhoods('1512 Shattuck Ave., Berkely, CA')
44
+ @results.should be_success
45
+ @results.data.should_not be_blank
46
+ @results.error_message.should be_blank
47
+ end
48
+
49
+ it 'should return results when given a location and a country code' do
50
+ @results = get_neighborhoods('1512 Shattuck Ave., Berkely, CA', 'US')
51
+ @results.should be_success
52
+ @results.data.should_not be_blank
53
+ @results.error_message.should be_blank
54
+ end
55
+
56
+ it 'should error when given an invalid country code' do
57
+ @results = get_neighborhoods('Berkely, CA', 'UK')
58
+ @results.should_not be_success
59
+ @results.data.should be_blank
60
+ @results.error_message.should_not be_blank
61
+ end
62
+
63
+ it 'should error when missing a location' do
64
+ @results = get_neighborhoods('')
65
+ @results.should_not be_success
66
+ @results.data.should be_blank
67
+ @results.error_message.should_not be_blank
68
+ end
69
+
70
+ it 'should error when given an invalid params' do
71
+ @results = get_neighborhoods('', 'US')
72
+ @results.should_not be_success
73
+ @results.data.should be_blank
74
+ @results.error_message.should_not be_blank
75
+ end
76
+
77
+ def get_neighborhoods(*params)
78
+ @neighborhood_search.search_by_location(*params)
79
+ end
80
+ end
81
+
82
+ end
@@ -0,0 +1,53 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require File.dirname(__FILE__) + '/../../lib/yelp4r'
3
+
4
+ describe Yelp4r::Neighborhoods do
5
+ include Yelp4rSpecHelper
6
+ include Yelp4rNeighsSpecHelper
7
+
8
+ before do
9
+ @yelp_neighs = Yelp4r::Neighborhoods.new
10
+ @yelp_neighs.parse_url = File.dirname(__FILE__) + "/../fixtures/neighborhoods.html"
11
+ end
12
+
13
+ describe 'initialize' do
14
+ it 'should set the url for the page to parse' do
15
+ @yelp_neighs.parse_url.should_not be_blank
16
+ end
17
+ end
18
+
19
+ describe 'list' do
20
+ before do
21
+ @neighs = @yelp_neighs.list
22
+ end
23
+
24
+ it "should return the list of neighborhoods" do
25
+ @neighs.should_not be_blank
26
+ @neighs.should == yelp4r_test_neighs_list
27
+ end
28
+ end
29
+
30
+ describe 'options_from_collection' do
31
+ it "should return an array of options" do
32
+ @yelp_neighs.options_from_list.should_not be_blank
33
+ @yelp_neighs.options_from_list.should == yelp4r_test_neighs_opts
34
+ end
35
+
36
+ it "should return an array of options with a single selected value when given a string" do
37
+ @opts = @yelp_neighs.options_from_list("Yaletown, Vancouver, BC, Canada")
38
+ @opts.should_not be_blank
39
+ @opts.should == yelp4r_test_neighs_opts_single_selected
40
+ end
41
+
42
+ it "should return an array of options with multiple selected values when given a array" do
43
+ @opts = @yelp_neighs.options_from_list([
44
+ "Yaletown, Vancouver, BC, Canada",
45
+ "New York, NY, USA",
46
+ "Bath Beach, Brooklyn, New York, NY, USA"
47
+ ])
48
+ @opts.should_not be_blank
49
+ @opts.should == yelp4r_test_neighs_opts_multiple_selected
50
+ end
51
+ end
52
+
53
+ end
@@ -0,0 +1,41 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require File.dirname(__FILE__) + '/../../lib/yelp4r'
3
+ require File.dirname(__FILE__) + '/../../lib/yelp4r/client'
4
+ require File.dirname(__FILE__) + '/../../lib/yelp4r/phone_search'
5
+ require File.dirname(__FILE__) + '/../../lib/yelp4r/response'
6
+
7
+ describe Yelp4r::PhoneSearch do
8
+ include Yelp4rSpecHelper
9
+
10
+ before do
11
+ @client = yelp4r_client
12
+ @phone_search = Yelp4r::PhoneSearch.new(@client)
13
+ end
14
+
15
+ describe 'initialize' do
16
+ it 'set the client' do
17
+ @phone_search.client.class.should == Yelp4r::Client
18
+ end
19
+ end
20
+
21
+ describe 'phone_search' do
22
+ it 'should return data on a valid phone number' do
23
+ @results = phone_get('4155463149')
24
+ @results.should be_success
25
+ @results.data.should_not be_blank
26
+ @results.error_message.should be_blank
27
+ end
28
+
29
+ it 'should not return data on an invalid phone number' do
30
+ @results = phone_get('415546314')
31
+ @results.should_not be_success
32
+ @results.data.should be_blank
33
+ @results.error_message.should_not be_blank
34
+ end
35
+
36
+ def phone_get(*params)
37
+ @phone_search.search_by_phone_number(*params)
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,170 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require File.dirname(__FILE__) + '/../../lib/yelp4r'
3
+ require File.dirname(__FILE__) + '/../../lib/yelp4r/client'
4
+ require File.dirname(__FILE__) + '/../../lib/yelp4r/review_search'
5
+ require File.dirname(__FILE__) + '/../../lib/yelp4r/response'
6
+
7
+ describe Yelp4r::NeighborhoodSearch do
8
+ include Yelp4rSpecHelper
9
+
10
+ before do
11
+ @client = yelp4r_client
12
+ @review_search = Yelp4r::ReviewSearch.new(@client)
13
+ end
14
+
15
+ describe 'initialize' do
16
+ it 'set the client' do
17
+ @review_search.client.class.should == Yelp4r::Client
18
+ end
19
+ end
20
+
21
+ describe 'search_by_bounding_box' do
22
+ it 'should return results when given top left and bottom right geocodes' do
23
+ @results = get_businesses(37.788022, -122.399797, 37.9, -122.5)
24
+ @results.should be_success
25
+ @results.data.should_not be_blank
26
+ @results.error_message.should be_blank
27
+ end
28
+
29
+ it 'should return the number of results requested' do
30
+ @results = get_businesses(37.788022, -122.399797, 37.9, -122.5, :num_biz_requested => 5)
31
+ @results.should be_success
32
+ @results.data.should_not be_blank
33
+ @results.data.size.should == 5
34
+ @results.error_message.should be_blank
35
+ end
36
+
37
+ it 'should return max 20 results' do
38
+ @results = get_businesses(37.788022, -122.399797, 37.9, -122.5, :num_biz_requested => 30)
39
+ @results.should be_success
40
+ @results.data.should_not be_blank
41
+ @results.data.size.should == 20
42
+ @results.error_message.should be_blank
43
+ end
44
+
45
+ it 'should return results when given a category term' do
46
+ @results = get_businesses(37.788022, -122.399797, 37.9, -122.5, :term => 'bars')
47
+ @results.should be_success
48
+ @results.data.should_not be_blank
49
+ @results.error_message.should be_blank
50
+ end
51
+
52
+ it 'should error when missing a with bad geocodes' do
53
+ @results = get_businesses(37.788022, -122.399797, 37.9, '')
54
+ @results.should_not be_success
55
+ @results.data.should be_blank
56
+ @results.error_message.should_not be_blank
57
+ end
58
+
59
+ def get_businesses(*params)
60
+ @review_search.search_by_bounding_box(*params)
61
+ end
62
+ end
63
+
64
+ describe 'search_by_geocode_and_radius' do
65
+ it 'should return results when given a geocode' do
66
+ @results = get_businesses(37.788022, -122.399797)
67
+ @results.should be_success
68
+ @results.data.should_not be_blank
69
+ @results.error_message.should be_blank
70
+ end
71
+
72
+ it 'should return results when given a geocode and a radius' do
73
+ @results = get_businesses(37.788022, -122.399797, :radius => 10)
74
+ @results.should be_success
75
+ @results.data.should_not be_blank
76
+ @results.error_message.should be_blank
77
+ end
78
+
79
+ it 'should return the number of results requested' do
80
+ @results = get_businesses(37.788022, -122.399797, :num_biz_requested => 5)
81
+ @results.should be_success
82
+ @results.data.should_not be_blank
83
+ @results.data.size.should == 5
84
+ @results.error_message.should be_blank
85
+ end
86
+
87
+ it 'should return max 20 results' do
88
+ @results = get_businesses(37.788022, -122.399797, :num_biz_requested => 30)
89
+ @results.should be_success
90
+ @results.data.should_not be_blank
91
+ @results.data.size.should == 20
92
+ @results.error_message.should be_blank
93
+ end
94
+
95
+ it 'should return results when given a category term' do
96
+ @results = get_businesses(37.788022, -122.399797, :term => 'bars')
97
+ @results.should be_success
98
+ @results.data.should_not be_blank
99
+ @results.error_message.should be_blank
100
+ end
101
+
102
+ it 'should error when given a bad geocode' do
103
+ @results = get_businesses(37.788022, '')
104
+ @results.should_not be_success
105
+ @results.data.should be_blank
106
+ @results.error_message.should_not be_blank
107
+ end
108
+
109
+ def get_businesses(*params)
110
+ @review_search.search_by_geocode_and_radius(*params)
111
+ end
112
+ end
113
+
114
+ describe 'search_by_location' do
115
+ it 'should return results given a location' do
116
+ @results = get_businesses('Boston, MA')
117
+ @results.should be_success
118
+ @results.data.should_not be_blank
119
+ @results.error_message.should be_blank
120
+ end
121
+
122
+ it 'should return the number of results requested' do
123
+ @results = get_businesses('Boston, MA', :num_biz_requested => 5)
124
+ @results.should be_success
125
+ @results.data.should_not be_blank
126
+ @results.data.size.should == 5
127
+ @results.error_message.should be_blank
128
+ end
129
+
130
+ it 'should return max 20 results' do
131
+ @results = get_businesses('Boston, MA', :num_biz_requested => 30)
132
+ @results.should be_success
133
+ @results.data.should_not be_blank
134
+ @results.data.size.should == 20
135
+ @results.error_message.should be_blank
136
+ end
137
+
138
+ it 'should return results when given a category term' do
139
+ @results = get_businesses('Boston, MA', :term => 'bars')
140
+ @results.should be_success
141
+ @results.data.should_not be_blank
142
+ @results.error_message.should be_blank
143
+ end
144
+
145
+ it 'should return results when given a valid country code' do
146
+ @results = get_businesses('Boston, MA', :cc => 'US')
147
+ @results.should be_success
148
+ @results.data.should_not be_blank
149
+ @results.error_message.should be_blank
150
+ end
151
+
152
+ it 'should error when missing a location' do
153
+ @results = get_businesses('')
154
+ @results.should_not be_success
155
+ @results.data.should be_blank
156
+ @results.error_message.should_not be_blank
157
+ end
158
+
159
+ it 'should error on invalid country code' do
160
+ @results = get_businesses('Boston, MA', :cc => 'UK')
161
+ @results.should_not be_success
162
+ @results.data.should be_blank
163
+ @results.error_message.should_not be_blank
164
+ end
165
+
166
+ def get_businesses(*params)
167
+ @review_search.search_by_location(*params)
168
+ end
169
+ end
170
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tcocca-yelp4r
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Tom Cocca
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-02-18 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: httparty
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: hpricot
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ description: Simple Ruby wrapper for the Yelp API built on HTTParty with parsers for available Neighborhoods and Categories
36
+ email: tom.cocca@gmail.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - README
45
+ - LICENSE
46
+ - Rakefile
47
+ - VERSION.yml
48
+ - lib/yelp4r.rb
49
+ - lib/yelp4r/categories.rb
50
+ - lib/yelp4r/client.rb
51
+ - lib/yelp4r/neighborhood_search.rb
52
+ - lib/yelp4r/neighborhoods.rb
53
+ - lib/yelp4r/phone_search.rb
54
+ - lib/yelp4r/response.rb
55
+ - lib/yelp4r/review_search.rb
56
+ - spec/rcov.opts
57
+ - spec/spec.opts
58
+ - spec/spec_helper.rb
59
+ - spec/fixtures/categories.html
60
+ - spec/fixtures/neighborhoods.html
61
+ - spec/yelp4r/categories_spec.rb
62
+ - spec/yelp4r/client_spec.rb
63
+ - spec/yelp4r/neighborhood_search_spec.rb
64
+ - spec/yelp4r/neighborhoods_spec.rb
65
+ - spec/yelp4r/phone_search_spec.rb
66
+ - spec/yelp4r/review_search_spec.rb
67
+ - examples/yelp.rb
68
+ has_rdoc: true
69
+ homepage: http://github.com/tcocca/yelp4r
70
+ post_install_message:
71
+ rdoc_options:
72
+ - --inline-source
73
+ - --charset=UTF-8
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: "0"
81
+ version:
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: "0"
87
+ version:
88
+ requirements: []
89
+
90
+ rubyforge_project:
91
+ rubygems_version: 1.2.0
92
+ signing_key:
93
+ specification_version: 2
94
+ summary: Yelp API wrapper in Ruby
95
+ test_files: []
96
+