zomato 0.0.1

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,67 @@
1
+ {
2
+ "zones": [
3
+ {
4
+ "zone": {
5
+ "zone_id": 1,
6
+ "name": "Noida",
7
+ "city_id": "1"
8
+ }
9
+ },
10
+ {
11
+ "zone": {
12
+ "zone_id": 2,
13
+ "name": "Gurgaon",
14
+ "city_id": "1"
15
+ }
16
+ },
17
+ {
18
+ "zone": {
19
+ "zone_id": 3,
20
+ "name": "South Delhi",
21
+ "city_id": "1"
22
+ }
23
+ },
24
+ {
25
+ "zone": {
26
+ "zone_id": 4,
27
+ "name": "Central Delhi",
28
+ "city_id": "1"
29
+ }
30
+ },
31
+ {
32
+ "zone": {
33
+ "zone_id": 5,
34
+ "name": "North Delhi",
35
+ "city_id": "1"
36
+ }
37
+ },
38
+ {
39
+ "zone": {
40
+ "zone_id": 6,
41
+ "name": "East Delhi",
42
+ "city_id": "1"
43
+ }
44
+ },
45
+ {
46
+ "zone": {
47
+ "zone_id": 7,
48
+ "name": "West Delhi",
49
+ "city_id": "1"
50
+ }
51
+ },
52
+ {
53
+ "zone": {
54
+ "zone_id": 501,
55
+ "name": "Faridabad",
56
+ "city_id": "1"
57
+ }
58
+ },
59
+ {
60
+ "zone": {
61
+ "zone_id": 600,
62
+ "name": "Ghaziabad",
63
+ "city_id": "1"
64
+ }
65
+ }
66
+ ]
67
+ }
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper.rb')
2
+
3
+ describe Zomato::Restaurant::Collection do
4
+
5
+ before(:each) do
6
+ query = {:city_id => 1, :zone_id => 1}
7
+ response = Zomato::Api.get('/search').parsed_response
8
+ @zomato_restaurant_collection = Zomato::Restaurant::Collection.new(response, query)
9
+ end
10
+
11
+ it 'should handle pages correctly' do
12
+ @zomato_restaurant_collection.total_pages.should == 10
13
+ @zomato_restaurant_collection.has_next_page?.should be_true
14
+ @zomato_restaurant_collection.has_previous_page?.should be_false
15
+ @zomato_restaurant_collection.next_page!
16
+ @zomato_restaurant_collection.should_receive(:results_found).at_least(1).times.and_return(100)
17
+ @zomato_restaurant_collection.should_receive(:results_start).at_least(1).times.and_return(11)
18
+ @zomato_restaurant_collection.should_receive(:results_shown).at_least(1).times.and_return(10)
19
+ @zomato_restaurant_collection.results_start.should == 11
20
+ @zomato_restaurant_collection.has_previous_page?.should be_true
21
+ @zomato_restaurant_collection.has_next_page?.should be_true
22
+ end
23
+ end
@@ -0,0 +1,51 @@
1
+ require 'rubygems'
2
+ require 'fakeweb'
3
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/zomato.rb')
4
+
5
+ FakeWeb.allow_net_connect = %r[^https?://localhost]
6
+ FakeWeb.register_uri(
7
+ :get, "https://api.zomato.com/v1/cities?format=json",
8
+ :body => File.open(File.dirname(__FILE__) + '/responses/cities.json').read
9
+ )
10
+ FakeWeb.register_uri(
11
+ :get, "https://api.zomato.com/v1/geocodes?format=json&lat=28.557706&lon=77.205879",
12
+ :body => File.open(File.dirname(__FILE__) + '/responses/locality.json').read
13
+ )
14
+ FakeWeb.register_uri(
15
+ :get, "https://api.zomato.com/v1/zones?format=json&city_id=1",
16
+ :body => File.open(File.dirname(__FILE__) + '/responses/zones.json').read
17
+ )
18
+ FakeWeb.register_uri(
19
+ :get, %r|https://api.zomato.com/v1/subzones*|,
20
+ :body => File.open(File.dirname(__FILE__) + '/responses/subzones.json').read
21
+ )
22
+ FakeWeb.register_uri(
23
+ :get, %r|https://api.zomato.com/v1/search?.*|,
24
+ :body => File.open(File.dirname(__FILE__) + '/responses/restaurants.json').read
25
+ )
26
+ FakeWeb.register_uri(
27
+ :get, %r|https://api.zomato.com/v1/cuisines*|,
28
+ :body => File.open(File.dirname(__FILE__) + '/responses/cuisines.json').read
29
+ )
30
+ FakeWeb.register_uri(
31
+ :get, %r|https://api.zomato.com/v1/restaurant/*|,
32
+ :body => File.open(File.dirname(__FILE__) + '/responses/restaurant.json').read
33
+ )
34
+ FakeWeb.register_uri(
35
+ :get, %r|https://api.zomato.com/v1/reviews/.*/user*|,
36
+ :body => File.open(File.dirname(__FILE__) + '/responses/reviews.json').read
37
+ )
38
+ FakeWeb.register_uri(
39
+ :post, %r|https://api.zomato.com/v1/contact*|,
40
+ :body => File.open(File.dirname(__FILE__) + '/responses/report_error.json').read
41
+ )
42
+ FakeWeb.register_uri(
43
+ :get, "https://api.zomato.com/v1/search/near?city_id=1&cuisine_id=1&format=json&lat=28.557706&lon=77.205879&random=true",
44
+ :body => File.open(File.dirname(__FILE__) + '/responses/restaurant.json').read
45
+ )
46
+
47
+
48
+
49
+
50
+
51
+
@@ -0,0 +1,195 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper.rb')
2
+
3
+ describe Zomato do
4
+
5
+ before(:each) do
6
+ @zomato = Zomato::Base.new('4e9991c4a7f431322011964e9991c4a7')
7
+ end
8
+
9
+ it 'should fetch all the cities that zomato supports currently' do
10
+ city = @zomato.cities.first
11
+ city.id.should == 1
12
+ city.name.should == 'Delhi NCR'
13
+ city.longitude.should == '77.210276'
14
+ city.latitude.should == '28.625789'
15
+ city.has_nightlife.should be_true
16
+ city.show_zones.should be_true
17
+ end
18
+
19
+ it 'should fetch a locality based on latitude and logitude' do
20
+ locality = @zomato.locality('28.557706', '77.205879')
21
+ locality.name.should == 'Green Park'
22
+ locality.city_name.should == 'Delhi'
23
+ locality.city_id.should == 1
24
+ end
25
+
26
+ describe 'city' do
27
+
28
+ before(:each) do
29
+ @city = @zomato.cities.first
30
+ end
31
+
32
+ it 'should fetch all the zones in a city' do
33
+ zone = @city.zones.first
34
+ zone.id.should == 1
35
+ zone.name.should == 'Noida'
36
+ zone.city_id.should == 1
37
+ end
38
+
39
+ it 'should fetch all the subzones in a city' do
40
+ @id=316, @name="Alaknanda", @zone_id="3", @city_id=1
41
+ subzone = @city.localities.first
42
+ subzone.id.should == 316
43
+ subzone.name.should == "Alaknanda"
44
+ subzone.zone_id.should == 3
45
+ subzone.city_id.should == 1
46
+ end
47
+
48
+ it 'should fetch all cuisines in a city' do
49
+ cuisine = @city.cuisines.first
50
+ cuisine.id.should == 1
51
+ cuisine.name.should == 'American'
52
+ cuisine.city_id.should == 1
53
+ end
54
+
55
+ describe 'cuisine' do
56
+
57
+ before(:each) do
58
+ @cuisine = @city.cuisines.first
59
+ end
60
+
61
+ it 'should search a restaurant based on cuisine' do
62
+ restaurants = @cuisine.restaurants
63
+ restaurants.results_found.should == 100
64
+ restaurants.results_start.should == 0
65
+ restaurants.results_shown.should == 10
66
+ restaurants.restaurants.size.should == 10
67
+ restaurant = restaurants.first
68
+ restaurant.id.should == 2760
69
+ restaurant.name.should == "Vapour"
70
+ restaurant.address.should == "2nd Floor, MGF Mega City Mall, MG Road, Gurgaon"
71
+ restaurant.locality.should == "MG Road"
72
+ restaurant.city.should == "Gurgaon"
73
+ restaurant.cuisines.should == "Continental, Asian, North Indian, Lounge, Chinese"
74
+ restaurant.rating_editor_overall.should == 4
75
+ restaurant.cost_for_two.should == 1500
76
+ restaurant.has_discount.should be_false
77
+ restaurant.has_citibank_discount.should be_false
78
+ end
79
+
80
+ end
81
+
82
+ describe 'zone' do
83
+
84
+ before(:each) do
85
+ @zone = @city.zones[2]
86
+ end
87
+
88
+ it 'should fetch all subzones in a zone' do
89
+ subzone = @zone.subzones.first
90
+ subzone.id.should == 316
91
+ subzone.name.should == "Alaknanda"
92
+ subzone.zone_id.should == 3
93
+ subzone.city_id.should == 1
94
+ end
95
+
96
+ it 'should fetch all restaurants in a zone' do
97
+ restaurants = @zone.restaurants
98
+ restaurants.results_found.should == 100
99
+ restaurants.results_start.should == 0
100
+ restaurants.results_shown.should == 10
101
+ restaurants.restaurants.size.should == 10
102
+ restaurant = restaurants.first
103
+ restaurant.id.should == 2760
104
+ restaurant.name.should == "Vapour"
105
+ restaurant.address.should == "2nd Floor, MGF Mega City Mall, MG Road, Gurgaon"
106
+ restaurant.locality.should == "MG Road"
107
+ restaurant.city.should == "Gurgaon"
108
+ restaurant.cuisines.should == "Continental, Asian, North Indian, Lounge, Chinese"
109
+ restaurant.rating_editor_overall.should == 4
110
+ restaurant.cost_for_two.should == 1500
111
+ restaurant.has_discount.should be_false
112
+ restaurant.has_citibank_discount.should be_false
113
+ end
114
+
115
+ describe 'subzone' do
116
+ before(:each) do
117
+ @subzone = @zone.subzones.first
118
+ end
119
+
120
+ it 'should fetch all restaurants in a subzone' do
121
+ restaurants = @subzone.restaurants
122
+ restaurants.results_found.should == 100
123
+ restaurants.results_start.should == 0
124
+ restaurants.results_shown.should == 10
125
+ restaurants.restaurants.size.should == 10
126
+ restaurant = restaurants.first
127
+ restaurant.id.should == 2760
128
+ restaurant.name.should == "Vapour"
129
+ restaurant.address.should == "2nd Floor, MGF Mega City Mall, MG Road, Gurgaon"
130
+ restaurant.locality.should == "MG Road"
131
+ restaurant.city.should == "Gurgaon"
132
+ restaurant.cuisines.should == "Continental, Asian, North Indian, Lounge, Chinese"
133
+ restaurant.rating_editor_overall.should == 4
134
+ restaurant.cost_for_two.should == 1500
135
+ restaurant.has_discount.should be_false
136
+ restaurant.has_citibank_discount.should be_false
137
+ end
138
+ end
139
+ end
140
+
141
+ describe 'restaurant' do
142
+
143
+ before(:each) do
144
+ @restaurant = @zomato.cities.first.localities.first.restaurants.first
145
+ end
146
+
147
+ it 'should show details of a restaurant' do
148
+ @restaurant.details.should be_a Hash
149
+ end
150
+
151
+ it 'should show reviews of a restaurant' do
152
+ @restaurant.reviews.should be_a Hash
153
+ end
154
+
155
+ it 'should report error' do
156
+ @restaurant.report_error("There was an error").should == true
157
+ end
158
+
159
+ it 'should search for restaurants' do
160
+ restaurants = Zomato::Restaurant.search(1, 'search term')
161
+ restaurants.results_found.should == 100
162
+ restaurants.results_start.should == 0
163
+ restaurants.results_shown.should == 10
164
+ restaurants.restaurants.size.should == 10
165
+ restaurant = restaurants.first
166
+ restaurant.id.should == 2760
167
+ restaurant.name.should == "Vapour"
168
+ restaurant.address.should == "2nd Floor, MGF Mega City Mall, MG Road, Gurgaon"
169
+ restaurant.locality.should == "MG Road"
170
+ restaurant.city.should == "Gurgaon"
171
+ restaurant.cuisines.should == "Continental, Asian, North Indian, Lounge, Chinese"
172
+ restaurant.rating_editor_overall.should == 4
173
+ restaurant.cost_for_two.should == 1500
174
+ restaurant.has_discount.should be_false
175
+ restaurant.has_citibank_discount.should be_false
176
+ end
177
+
178
+ it 'should search for random restaurant near given geocodes' do
179
+ restaurant = Zomato::Restaurant.near('28.557706', '77.205879', :city_id => 1, :cuisine_id => 1)
180
+ restaurant.id.should == 315
181
+ restaurant.name.should == "Sagar Ratna"
182
+ restaurant.address.should == "B-1, A-11 Mohan Co-operative Ind Area, Mathura Road, New Delhi"
183
+ restaurant.locality.should == "Mathura Road"
184
+ restaurant.city.should == "Delhi"
185
+ restaurant.cuisines.should == "South Indian"
186
+ restaurant.rating_editor_overall.should == 3
187
+ restaurant.cost_for_two.should == 450
188
+ restaurant.has_discount.should be_false
189
+ restaurant.has_citibank_discount.should be_false
190
+ end
191
+
192
+ end
193
+ end
194
+ end
195
+
@@ -0,0 +1,20 @@
1
+ $:.push File.dirname(__FILE__) + '/lib'
2
+ require 'zomato.rb'
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = %q{zomato}
6
+ gem.authors = ["Chirantan Rajhans"]
7
+ gem.date = %q{2011-10-22}
8
+ gem.description = %q{Ruby wrapper over Zomato API}
9
+ gem.summary = "Ruby wrapper over Zomato API"
10
+ gem.email = %q{chirantan.rajhans@gmail.com}
11
+ gem.homepage = 'http://www.zomato.com/'
12
+
13
+ gem.add_runtime_dependency 'httparty'
14
+
15
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
+ gem.files = `git ls-files`.split("\n")
17
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ gem.require_paths = ['lib']
19
+ gem.version = '0.0.1'
20
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zomato
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Chirantan Rajhans
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-10-22 00:00:00 +05:30
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: httparty
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ description: Ruby wrapper over Zomato API
28
+ email: chirantan.rajhans@gmail.com
29
+ executables: []
30
+
31
+ extensions: []
32
+
33
+ extra_rdoc_files: []
34
+
35
+ files:
36
+ - .gitignore
37
+ - Gemfile
38
+ - MIT-LICENSE
39
+ - README.md
40
+ - Rakefile
41
+ - lib/zomato.rb
42
+ - lib/zomato/api.rb
43
+ - lib/zomato/base.rb
44
+ - lib/zomato/city.rb
45
+ - lib/zomato/cuisine.rb
46
+ - lib/zomato/locality.rb
47
+ - lib/zomato/restaurant.rb
48
+ - lib/zomato/subzone.rb
49
+ - lib/zomato/zone.rb
50
+ - spec/responses/cities.json
51
+ - spec/responses/cuisines.json
52
+ - spec/responses/locality.json
53
+ - spec/responses/report_error.json
54
+ - spec/responses/restaurant.json
55
+ - spec/responses/restaurants.json
56
+ - spec/responses/reviews.json
57
+ - spec/responses/subzones.json
58
+ - spec/responses/zones.json
59
+ - spec/restaurant_collection_spec.rb
60
+ - spec/spec_helper.rb
61
+ - spec/zomato_spec.rb
62
+ - zomato.gemspec
63
+ has_rdoc: true
64
+ homepage: http://www.zomato.com/
65
+ licenses: []
66
+
67
+ post_install_message:
68
+ rdoc_options: []
69
+
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: "0"
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "0"
84
+ requirements: []
85
+
86
+ rubyforge_project:
87
+ rubygems_version: 1.5.3
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Ruby wrapper over Zomato API
91
+ test_files: []
92
+