yelp 2.0.7 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/yelp/client.rb +1 -2
- data/lib/yelp/endpoint/business.rb +3 -1
- data/lib/yelp/endpoint/phone_search.rb +4 -1
- data/lib/yelp/endpoint/search.rb +5 -3
- data/lib/yelp/responses/base.rb +21 -0
- data/lib/yelp/responses/business.rb +14 -0
- data/lib/yelp/responses/models/business.rb +26 -0
- data/lib/yelp/responses/models/coordinate.rb +11 -0
- data/lib/yelp/responses/models/deal.rb +20 -0
- data/lib/yelp/responses/models/deal_option.rb +12 -0
- data/lib/yelp/responses/models/gift_certificate.rb +18 -0
- data/lib/yelp/responses/models/gift_certificate_option.rb +11 -0
- data/lib/yelp/responses/models/location.rb +19 -0
- data/lib/yelp/responses/models/rating.rb +11 -0
- data/lib/yelp/responses/models/region.rb +20 -0
- data/lib/yelp/responses/models/region_center.rb +11 -0
- data/lib/yelp/responses/models/region_span.rb +11 -0
- data/lib/yelp/responses/models/review.rb +12 -0
- data/lib/yelp/responses/models/user.rb +11 -0
- data/lib/yelp/responses/phone_search.rb +18 -0
- data/lib/yelp/responses/search.rb +18 -0
- data/lib/yelp/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/business.yml +52 -41
- data/spec/fixtures/vcr_cassettes/phone_search.yml +35 -28
- data/spec/fixtures/vcr_cassettes/search.yml +360 -332
- data/spec/fixtures/vcr_cassettes/search_bounding_box.yml +349 -327
- data/spec/fixtures/vcr_cassettes/search_by_coordinates.yml +361 -355
- data/spec/yelp/endpoint/business_spec.rb +2 -2
- data/spec/yelp/endpoint/phone_search_spec.rb +1 -1
- data/spec/yelp/endpoint/search_spec.rb +1 -1
- data/spec/yelp/responses/base_spec.rb +22 -0
- data/tasks/console.rake +2 -2
- data/yelp.gemspec +1 -1
- metadata +24 -7
- data/lib/yelp/burst_struct.rb +0 -63
- data/spec/yelp/burst_struct_spec.rb +0 -155
@@ -14,8 +14,8 @@ describe Yelp::Endpoint::Business do
|
|
14
14
|
end
|
15
15
|
}
|
16
16
|
|
17
|
-
it { should be_a(
|
18
|
-
its(
|
17
|
+
it { should be_a(Yelp::Response::Business) }
|
18
|
+
its('business.name') { should eql('Yelp') }
|
19
19
|
end
|
20
20
|
|
21
21
|
describe 'errors' do
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Yelp::Response::Base do
|
4
|
+
describe '#initialize' do
|
5
|
+
let(:json) { Hash['a' => 10, 'b' => 20] }
|
6
|
+
|
7
|
+
subject(:base) { base = Yelp::Response::Base.new(json) }
|
8
|
+
|
9
|
+
it { should be_a(Yelp::Response::Base) }
|
10
|
+
|
11
|
+
it 'should create variables' do
|
12
|
+
expect(base.instance_variable_get('@a')).to eql 10
|
13
|
+
expect(base.instance_variable_get('@b')).to eql 20
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#initialize nil' do
|
18
|
+
subject(:base) { Yelp::Response::Base.new(nil) }
|
19
|
+
|
20
|
+
it { should be_a(Yelp::Response::Base) }
|
21
|
+
end
|
22
|
+
end
|
data/tasks/console.rake
CHANGED
data/yelp.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ['Tomer Elmalem', 'Justin Cunningham', 'Yelp']
|
10
10
|
spec.email = ['telmalem@gmail.com', 'partnerships@yelp.com']
|
11
11
|
spec.summary = %q{Ruby client library for the Yelp API}
|
12
|
-
spec.description = 'Provides easy way to interact with the Yelp API in any kind of application'
|
12
|
+
spec.description = 'Provides an easy way to interact with the Yelp API in any kind of application'
|
13
13
|
spec.homepage = 'https://github.com/Yelp/yelp-ruby'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yelp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomer Elmalem
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-10-
|
13
|
+
date: 2015-10-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -202,7 +202,7 @@ dependencies:
|
|
202
202
|
- - "~>"
|
203
203
|
- !ruby/object:Gem::Version
|
204
204
|
version: 0.3.1
|
205
|
-
description: Provides easy way to interact with the Yelp API in any kind of application
|
205
|
+
description: Provides an easy way to interact with the Yelp API in any kind of application
|
206
206
|
email:
|
207
207
|
- telmalem@gmail.com
|
208
208
|
- partnerships@yelp.com
|
@@ -220,13 +220,29 @@ files:
|
|
220
220
|
- README.md
|
221
221
|
- Rakefile
|
222
222
|
- lib/yelp.rb
|
223
|
-
- lib/yelp/burst_struct.rb
|
224
223
|
- lib/yelp/client.rb
|
225
224
|
- lib/yelp/configuration.rb
|
226
225
|
- lib/yelp/endpoint/business.rb
|
227
226
|
- lib/yelp/endpoint/phone_search.rb
|
228
227
|
- lib/yelp/endpoint/search.rb
|
229
228
|
- lib/yelp/error.rb
|
229
|
+
- lib/yelp/responses/base.rb
|
230
|
+
- lib/yelp/responses/business.rb
|
231
|
+
- lib/yelp/responses/models/business.rb
|
232
|
+
- lib/yelp/responses/models/coordinate.rb
|
233
|
+
- lib/yelp/responses/models/deal.rb
|
234
|
+
- lib/yelp/responses/models/deal_option.rb
|
235
|
+
- lib/yelp/responses/models/gift_certificate.rb
|
236
|
+
- lib/yelp/responses/models/gift_certificate_option.rb
|
237
|
+
- lib/yelp/responses/models/location.rb
|
238
|
+
- lib/yelp/responses/models/rating.rb
|
239
|
+
- lib/yelp/responses/models/region.rb
|
240
|
+
- lib/yelp/responses/models/region_center.rb
|
241
|
+
- lib/yelp/responses/models/region_span.rb
|
242
|
+
- lib/yelp/responses/models/review.rb
|
243
|
+
- lib/yelp/responses/models/user.rb
|
244
|
+
- lib/yelp/responses/phone_search.rb
|
245
|
+
- lib/yelp/responses/search.rb
|
230
246
|
- lib/yelp/version.rb
|
231
247
|
- spec/fixtures/vcr_cassettes/business.yml
|
232
248
|
- spec/fixtures/vcr_cassettes/phone_search.yml
|
@@ -236,13 +252,13 @@ files:
|
|
236
252
|
- spec/spec_helper.rb
|
237
253
|
- spec/support/request_error.rb
|
238
254
|
- spec/support/shared_configuration.rb
|
239
|
-
- spec/yelp/burst_struct_spec.rb
|
240
255
|
- spec/yelp/client_spec.rb
|
241
256
|
- spec/yelp/configuration_spec.rb
|
242
257
|
- spec/yelp/endpoint/business_spec.rb
|
243
258
|
- spec/yelp/endpoint/phone_search_spec.rb
|
244
259
|
- spec/yelp/endpoint/search_spec.rb
|
245
260
|
- spec/yelp/error_spec.rb
|
261
|
+
- spec/yelp/responses/base_spec.rb
|
246
262
|
- spec/yelp/yelp_spec.rb
|
247
263
|
- tasks/console.rake
|
248
264
|
- yelp.gemspec
|
@@ -266,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
266
282
|
version: '0'
|
267
283
|
requirements: []
|
268
284
|
rubyforge_project:
|
269
|
-
rubygems_version: 2.4.
|
285
|
+
rubygems_version: 2.4.3
|
270
286
|
signing_key:
|
271
287
|
specification_version: 4
|
272
288
|
summary: Ruby client library for the Yelp API
|
@@ -279,11 +295,12 @@ test_files:
|
|
279
295
|
- spec/spec_helper.rb
|
280
296
|
- spec/support/request_error.rb
|
281
297
|
- spec/support/shared_configuration.rb
|
282
|
-
- spec/yelp/burst_struct_spec.rb
|
283
298
|
- spec/yelp/client_spec.rb
|
284
299
|
- spec/yelp/configuration_spec.rb
|
285
300
|
- spec/yelp/endpoint/business_spec.rb
|
286
301
|
- spec/yelp/endpoint/phone_search_spec.rb
|
287
302
|
- spec/yelp/endpoint/search_spec.rb
|
288
303
|
- spec/yelp/error_spec.rb
|
304
|
+
- spec/yelp/responses/base_spec.rb
|
289
305
|
- spec/yelp/yelp_spec.rb
|
306
|
+
has_rdoc:
|
data/lib/yelp/burst_struct.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
module BurstStruct
|
2
|
-
class Burst
|
3
|
-
def initialize(hash = {})
|
4
|
-
@hash = hash
|
5
|
-
end
|
6
|
-
|
7
|
-
def keys
|
8
|
-
@hash.keys
|
9
|
-
end
|
10
|
-
|
11
|
-
def method_missing(method_name, *arguments, &block)
|
12
|
-
key = find_key(method_name)
|
13
|
-
|
14
|
-
if key
|
15
|
-
return_or_build_struct(key)
|
16
|
-
else
|
17
|
-
super
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def respond_to?(method_name, include_private = false)
|
22
|
-
has_key?(method_name) || super
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.convert_array(array)
|
26
|
-
array.map do |item|
|
27
|
-
case item
|
28
|
-
when Hash
|
29
|
-
Burst.new(item)
|
30
|
-
when Array
|
31
|
-
Burst.convert_array(item)
|
32
|
-
else
|
33
|
-
item
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def to_json(options = {})
|
39
|
-
JSON.generate(@hash)
|
40
|
-
end
|
41
|
-
|
42
|
-
def has_key?(method_name)
|
43
|
-
!find_key(method_name).nil?
|
44
|
-
end
|
45
|
-
|
46
|
-
def raw_data
|
47
|
-
@hash
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def return_or_build_struct(method_name)
|
53
|
-
return Burst.new(@hash[method_name]) if @hash[method_name].is_a?(Hash)
|
54
|
-
return Burst.convert_array(@hash[method_name]) if @hash[method_name].is_a?(Array)
|
55
|
-
@hash[method_name]
|
56
|
-
end
|
57
|
-
|
58
|
-
def find_key(method_name)
|
59
|
-
return method_name.to_sym if @hash.keys.include? method_name.to_sym
|
60
|
-
return method_name.to_s if @hash.keys.include? method_name.to_s
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,155 +0,0 @@
|
|
1
|
-
require 'yelp/burst_struct'
|
2
|
-
|
3
|
-
describe BurstStruct::Burst do
|
4
|
-
describe '#keys' do
|
5
|
-
subject(:struct) { BurstStruct::Burst.new(foo: 'bar', baz: 'qux') }
|
6
|
-
|
7
|
-
it 'should return' do
|
8
|
-
expect(struct.keys).to eql [:foo, :baz]
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '#foo' do
|
13
|
-
subject(:struct) { BurstStruct::Burst.new(foo: 'bar') }
|
14
|
-
|
15
|
-
context 'when a key exists' do
|
16
|
-
it 'should return' do
|
17
|
-
expect(struct.foo).to eql 'bar'
|
18
|
-
end
|
19
|
-
|
20
|
-
it { should have_key(:foo) }
|
21
|
-
it { should have_key('foo') }
|
22
|
-
|
23
|
-
it { should respond_to(:foo) }
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'when a key does not exist' do
|
27
|
-
it 'should not respond to it' do
|
28
|
-
expect(struct.respond_to? :super_foo).to eql false
|
29
|
-
end
|
30
|
-
|
31
|
-
it { should_not have_key(:super_foo) }
|
32
|
-
it { should_not have_key('super_foo') }
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'n deep nested hash' do
|
37
|
-
let(:hash) { Hash[ futurama: { characters: { robots: { best: 'bender' } } } ] }
|
38
|
-
|
39
|
-
subject(:struct) { BurstStruct::Burst.new(hash) }
|
40
|
-
|
41
|
-
describe '#foo#bar#baz#biz' do
|
42
|
-
it 'should return' do
|
43
|
-
expect(struct.futurama.characters.robots.best).to eql 'bender'
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'arrays' do
|
49
|
-
let(:hash) { Hash[ businesses: [ { name: 'Yelp', location: 'San Francisco' },
|
50
|
-
{ name: 'Ice Cream', flavor: 'Chocolate' },
|
51
|
-
[ { name: 'Moe', occupation: 'Bartender' } ] ] ] }
|
52
|
-
|
53
|
-
subject(:struct) { BurstStruct::Burst.new(hash) }
|
54
|
-
|
55
|
-
describe '#businesses[0].name' do
|
56
|
-
it 'should return' do
|
57
|
-
expect(struct.businesses[0].name).to eql 'Yelp'
|
58
|
-
expect(struct.businesses[0].location).to eql 'San Francisco'
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe '#business[1].name' do
|
63
|
-
it 'should return' do
|
64
|
-
expect(struct.businesses[1].name).to eql 'Ice Cream'
|
65
|
-
expect(struct.businesses[1].flavor).to eql 'Chocolate'
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe 'nested arrays' do
|
70
|
-
it 'should parse arrays all the way down' do
|
71
|
-
expect(struct.businesses[2][0].name).to eql 'Moe'
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context 'large hash' do
|
77
|
-
let(:hash) do
|
78
|
-
{ foo: 1,
|
79
|
-
bar: {
|
80
|
-
baz: 2,
|
81
|
-
bender: {
|
82
|
-
bending: {
|
83
|
-
rodriguez: true
|
84
|
-
}
|
85
|
-
}
|
86
|
-
},
|
87
|
-
fry: [
|
88
|
-
{past: true},
|
89
|
-
{present: true},
|
90
|
-
{future: true}
|
91
|
-
],
|
92
|
-
turunga: 'leela',
|
93
|
-
'hubert' => 'farnsworth',
|
94
|
-
zoidberg: [
|
95
|
-
'doctor',
|
96
|
-
'homeowner',
|
97
|
-
'moviestar'
|
98
|
-
]
|
99
|
-
}
|
100
|
-
end
|
101
|
-
|
102
|
-
subject(:struct) { BurstStruct::Burst.new(hash) }
|
103
|
-
|
104
|
-
it 'turns top level into a struct' do
|
105
|
-
expect(struct.foo).to eql 1
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'recursively creates structs all the way down the hash' do
|
109
|
-
expect(struct.bar.baz).to equal 2
|
110
|
-
expect(struct.bar.bender.bending.rodriguez).to eql true
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'creates arrays with hashes into new structs' do
|
114
|
-
expect(struct.fry[0].past).to eql true
|
115
|
-
expect(struct.fry[1].present).to eql true
|
116
|
-
expect(struct.fry[2].future).to eql true
|
117
|
-
end
|
118
|
-
|
119
|
-
it 'turns string keys into structs' do
|
120
|
-
expect(struct.hubert).to eql 'farnsworth'
|
121
|
-
end
|
122
|
-
|
123
|
-
it 'should maintain arrays with non hashes' do
|
124
|
-
expect(struct.zoidberg.size).to eql 3
|
125
|
-
expect(struct.zoidberg[0]).to eql 'doctor'
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
context 'deserialize' do
|
130
|
-
let(:hash) do
|
131
|
-
{ name: 'Bender', company: 'Yelp', title: 'Bending Engineer' }
|
132
|
-
end
|
133
|
-
|
134
|
-
subject(:struct) { BurstStruct::Burst.new(hash) }
|
135
|
-
|
136
|
-
it 'should deserialize to the same json' do
|
137
|
-
expect(struct.to_json).to eql hash.to_json
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
context 'struct with string keys' do
|
142
|
-
subject(:struct) { BurstStruct::Burst.new('foo' => 'bar') }
|
143
|
-
|
144
|
-
context 'when a key exists' do
|
145
|
-
it 'should return' do
|
146
|
-
expect(struct.foo).to eql 'bar'
|
147
|
-
end
|
148
|
-
|
149
|
-
it { should have_key(:foo) }
|
150
|
-
it { should have_key('foo') }
|
151
|
-
|
152
|
-
it { should respond_to(:foo) }
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|