citygrid 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -4
- data/VERSION +1 -1
- data/citygrid.gemspec +57 -0
- data/lib/citygrid.rb +3 -0
- data/lib/citygrid/client.rb +20 -5
- data/pkg/citygrid-0.1.0.gem +0 -0
- metadata +5 -3
data/README.md
CHANGED
@@ -31,11 +31,13 @@ Sign up for a CityGrid API key: [http://developer.citysearch.com/member/register
|
|
31
31
|
|
32
32
|
#### Examples
|
33
33
|
|
34
|
-
>> citygrid.search_locations(:what => "roots coffee", :where => "76180", :rpp => 1)
|
35
|
-
|
34
|
+
>> spot = citygrid.search_locations(:what => "roots coffee", :where => "76180", :rpp => 1)
|
35
|
+
>> spot.results.location.name
|
36
|
+
=> "Roots Coffeehouse"
|
36
37
|
|
37
|
-
>>
|
38
|
-
|
38
|
+
>> profile = citygrid.profile(:listing_id => '613027480', :client_ip => 'any_client_ip')
|
39
|
+
>> profile.locations.location.categories
|
40
|
+
=> <#Hashie::Mash category=<#Hashie::Mash name="Coffeehouses" nameid="1726" parent="Restaurants" parentid="1722">>
|
39
41
|
|
40
42
|
You can search for locations and events, get reviews, and get business profiles.
|
41
43
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/citygrid.gemspec
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{citygrid}
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Johnny Khai Nguyen"]
|
12
|
+
s.date = %q{2010-06-27}
|
13
|
+
s.description = %q{Ruby wrapper for the CityGrid API}
|
14
|
+
s.email = %q{johnnyn@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.md"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"MIT-LICENSE",
|
20
|
+
"README.md",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"citygrid.gemspec",
|
24
|
+
"init.rb",
|
25
|
+
"install.rb",
|
26
|
+
"lib/citygrid.rb",
|
27
|
+
"lib/citygrid/client.rb",
|
28
|
+
"pkg/citygrid-0.1.0.gem",
|
29
|
+
"tasks/citygrid_tasks.rake",
|
30
|
+
"test/citygrid_test.rb",
|
31
|
+
"test/test_helper.rb",
|
32
|
+
"uninstall.rb"
|
33
|
+
]
|
34
|
+
s.homepage = %q{http://github.com/phuphighter/citygrid}
|
35
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = %q{1.3.6}
|
38
|
+
s.summary = %q{Ruby wrapper for the CityGrid API}
|
39
|
+
s.test_files = [
|
40
|
+
"test/citygrid_test.rb",
|
41
|
+
"test/test_helper.rb"
|
42
|
+
]
|
43
|
+
|
44
|
+
if s.respond_to? :specification_version then
|
45
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
|
+
s.specification_version = 3
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0.5.0"])
|
50
|
+
else
|
51
|
+
s.add_dependency(%q<httparty>, [">= 0.5.0"])
|
52
|
+
end
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<httparty>, [">= 0.5.0"])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
data/lib/citygrid.rb
CHANGED
data/lib/citygrid/client.rb
CHANGED
@@ -11,23 +11,23 @@ module Citygrid
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def search_locations(options={})
|
14
|
-
|
14
|
+
mashup(self.class.get("/search/locations", :query => options.merge(self.default_options)))
|
15
15
|
end
|
16
16
|
|
17
17
|
def search_events(options={})
|
18
|
-
|
18
|
+
mashup(self.class.get("/search/events", :query => options.merge(self.default_options)))
|
19
19
|
end
|
20
20
|
|
21
21
|
def profile(options={})
|
22
22
|
if options[:client_ip].nil?
|
23
23
|
puts "Dude, a client_ip is required."
|
24
24
|
else
|
25
|
-
|
25
|
+
mashup(self.class.get("/profile/", :query => options.merge(self.default_options)))
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
def reviews(options={})
|
30
|
-
|
30
|
+
mashup(self.class.get("/reviews/", :query => options.merge(self.default_options)))
|
31
31
|
end
|
32
32
|
|
33
33
|
protected
|
@@ -36,5 +36,20 @@ module Citygrid
|
|
36
36
|
{:api_key => @api_key, :publisher => "acme"}
|
37
37
|
end
|
38
38
|
|
39
|
-
|
39
|
+
def mashup(response)
|
40
|
+
case response.code
|
41
|
+
when 200
|
42
|
+
if response.is_a?(Hash)
|
43
|
+
Hashie::Mash.new(response)
|
44
|
+
else
|
45
|
+
if response.first.is_a?(Hash)
|
46
|
+
response.map{|item| Hashie::Mash.new(item)}
|
47
|
+
else
|
48
|
+
response
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
40
55
|
end
|
Binary file
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Johnny Khai Nguyen
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-06-27 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -44,10 +44,12 @@ files:
|
|
44
44
|
- README.md
|
45
45
|
- Rakefile
|
46
46
|
- VERSION
|
47
|
+
- citygrid.gemspec
|
47
48
|
- init.rb
|
48
49
|
- install.rb
|
49
50
|
- lib/citygrid.rb
|
50
51
|
- lib/citygrid/client.rb
|
52
|
+
- pkg/citygrid-0.1.0.gem
|
51
53
|
- tasks/citygrid_tasks.rake
|
52
54
|
- test/citygrid_test.rb
|
53
55
|
- test/test_helper.rb
|