citygrid 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{citygrid}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Johnny Khai Nguyen"]
12
- s.date = %q{2010-06-27}
12
+ s.date = %q{2010-08-12}
13
13
  s.description = %q{Ruby wrapper for the CityGrid API}
14
14
  s.email = %q{johnnyn@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -26,9 +26,13 @@ Gem::Specification.new do |s|
26
26
  "lib/citygrid.rb",
27
27
  "lib/citygrid/client.rb",
28
28
  "pkg/citygrid-0.1.0.gem",
29
+ "pkg/citygrid-0.1.1.gem",
29
30
  "tasks/citygrid_tasks.rake",
30
31
  "test/citygrid_test.rb",
31
- "test/test_helper.rb",
32
+ "test/fixtures/profile.xml",
33
+ "test/fixtures/review.xml",
34
+ "test/fixtures/search.xml",
35
+ "test/helper.rb",
32
36
  "uninstall.rb"
33
37
  ]
34
38
  s.homepage = %q{http://github.com/phuphighter/citygrid}
@@ -38,7 +42,7 @@ Gem::Specification.new do |s|
38
42
  s.summary = %q{Ruby wrapper for the CityGrid API}
39
43
  s.test_files = [
40
44
  "test/citygrid_test.rb",
41
- "test/test_helper.rb"
45
+ "test/helper.rb"
42
46
  ]
43
47
 
44
48
  if s.respond_to? :specification_version then
@@ -3,6 +3,7 @@ module Citygrid
3
3
  class Client
4
4
  include HTTParty
5
5
  base_uri "http://api2.citysearch.com"
6
+ format :xml
6
7
 
7
8
  attr_reader :api_key
8
9
 
@@ -37,19 +38,19 @@ module Citygrid
37
38
  end
38
39
 
39
40
  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
41
+ case response.code
42
+ when 200
43
+ if response.is_a?(Hash)
44
+ Hashie::Mash.new(response)
45
+ else
46
+ if response.first.is_a?(Hash)
47
+ response.map{|item| Hashie::Mash.new(item)}
48
+ else
49
+ response
51
50
  end
52
- end
53
- end
51
+ end
52
+ end
53
+ end
54
+ end
54
55
 
55
56
  end
Binary file
@@ -1,8 +1,38 @@
1
- require 'test_helper'
1
+ require 'helper'
2
2
 
3
- class CitygridTest < ActiveSupport::TestCase
4
- # Replace this with your real tests.
5
- test "the truth" do
6
- assert true
3
+ class CitygridTest < Test::Unit::TestCase
4
+
5
+ context "Citygrid API" do
6
+ setup do
7
+ @client = Citygrid::Client.new(:api_key => 'wtf')
8
+ end
9
+
10
+ context "and searching for a place" do
11
+ should "find a specific place" do
12
+ stub_get("http://api2.citysearch.com/search/locations?what=roots%20coffee&api_key=wtf&where=76180&publisher=acme", "search.xml")
13
+ search_result = @client.search_locations(:what => "roots coffee", :where => "76180")
14
+ search_result.results.location.name.should == "Roots Coffeehouse"
15
+ search_result.results.location.address.postalcode.should == "76180"
16
+ end
17
+ end
18
+
19
+ context "and get profile" do
20
+ should "get specific profile data" do
21
+ stub_get("http://api2.citysearch.com/profile/?api_key=wtf&client_ip=127.0.0.1&listing_id=613027480&publisher=acme", "profile.xml")
22
+ profile = @client.profile(:client_ip => "127.0.0.1", :listing_id => 613027480)
23
+ profile.locations.location.name.should == "Roots Coffeehouse"
24
+ profile.locations.location.address.latitude.should == "32.849869"
25
+ end
26
+ end
27
+
28
+ context "and get reviews" do
29
+ should "get specific reviews" do
30
+ stub_get("http://api2.citysearch.com/reviews/?publisher=acme&api_key=wtf&tag_name=restaurant&where=90069", "review.xml")
31
+ restaurant_reviews = @client.reviews(:where => '90069', :tag_name => 'restaurant')
32
+ restaurant_reviews.reviews.first.last.first.business_name.should == "Cafe du Qvondeyz"
33
+ restaurant_reviews.reviews.first.last[1].business_name.should == "Joselito's Mexican Food"
34
+ end
35
+ end
7
36
  end
8
- end
37
+
38
+ end
@@ -0,0 +1,63 @@
1
+ <?xml version="1.0"?>
2
+ <locations>
3
+ <!-- Copyright 2010 Citysearch -->
4
+ <location>
5
+ <id>613027480</id>
6
+ <reference_id>1</reference_id>
7
+ <display_ad>true</display_ad>
8
+ <infousa_id>695618793</infousa_id>
9
+ <name>Roots Coffeehouse</name>
10
+ <teaser/>
11
+ <address>
12
+ <street>9101 Boulevard 26</street>
13
+ <delivery_point/>
14
+ <city>N Richland Hills</city>
15
+ <state>TX</state>
16
+ <postal_code>76180</postal_code>
17
+ <cross_street/>
18
+ <latitude>32.849869</latitude>
19
+ <longitude>-97.193291</longitude>
20
+ </address>
21
+ <contact_info>
22
+ <display_phone>8175037344</display_phone>
23
+ <display_url/>
24
+ </contact_info>
25
+ <markets>
26
+ <market>Fort Worth, TX Metro</market>
27
+ </markets>
28
+ <neighborhoods/>
29
+ <urls>
30
+ <profile_url>http://fortworth.citysearch.com/profile/613027480/n_richland_hills_tx/roots_coffeehouse.html</profile_url>
31
+ <reviews_url>http://fortworth.citysearch.com/review/613027480</reviews_url>
32
+ <video_url/>
33
+ <website_url>http://fortworth.citysearch.com/profile/external/613027480/n_richland_hills_tx/roots_coffeehouse.html</website_url>
34
+ <menu_url/>
35
+ <reservation_url/>
36
+ <map_url>http://fortworth.citysearch.com/profile/map/613027480/n_richland_hills_tx/roots_coffeehouse.html</map_url>
37
+ <send_to_friend_url>http://fortworth.citysearch.com/profile/sendto/613027480/n_richland_hills_tx/roots_coffeehouse.html</send_to_friend_url>
38
+ <email_link>http://fortworth.citysearch.com/profile/email_business/613027480/n_richland_hills_tx/roots_coffeehouse.html</email_link>
39
+ <custom_link_1/>
40
+ <custom_link_2/>
41
+ </urls>
42
+ <customer_content>
43
+ <customer_message/>
44
+ <bullets/>
45
+ <customer_message_url/>
46
+ </customer_content>
47
+ <offers/>
48
+ <categories>
49
+ <category name="Coffeehouses" nameid="1726" parent="Restaurants" parentid="1722"/>
50
+ </categories>
51
+ <attributes/>
52
+ <business_hours/>
53
+ <parking/>
54
+ <tips/>
55
+ <images/>
56
+ <editorials/>
57
+ <reviews>
58
+ <overall_review_rating>NA</overall_review_rating>
59
+ <total_user_reviews/>
60
+ <total_user_reviews_shown/>
61
+ </reviews>
62
+ </location>
63
+ </locations>
@@ -0,0 +1,164 @@
1
+ <?xml version="1.0"?>
2
+ <reviews>
3
+ <!-- Copyright 2010 Citysearch -->
4
+ <review attribution_text="Citysearch" attribution_logo="http://images.citysearch.net/assets/imgdb/custom/ue-357/CS_logo88x31.jpg" attribution_source="5">
5
+ <business_name>Cafe du Qvondeyz</business_name>
6
+ <listing_id>603907992</listing_id>
7
+ <reference_id>1</reference_id>
8
+ <review_id>101170591</review_id>
9
+ <review_url>http://losangeles.citysearch.com/review/603907992</review_url>
10
+ <review_title>Great Lunch Place and Great Service </review_title>
11
+ <review_author>runcty</review_author>
12
+ <review_author_url>http://my.citysearch.com/members/public/profile/runcty</review_author_url>
13
+ <review_text>I had a change to have lunch at Cafe Du Ovondeyz, the food was amazing... I had the PO Boy Sandwiches and a strawberry lemonade... The service was friendly and fast. </review_text>
14
+ <pros/>
15
+ <cons/>
16
+ <review_date>2010-08-10T11:58:04Z</review_date>
17
+ <review_rating>8</review_rating>
18
+ </review>
19
+ <review attribution_text="Citysearch" attribution_logo="http://images.citysearch.net/assets/imgdb/custom/ue-357/CS_logo88x31.jpg" attribution_source="5">
20
+ <business_name>Joselito's Mexican Food</business_name>
21
+ <listing_id>32693642</listing_id>
22
+ <reference_id>1</reference_id>
23
+ <review_id>100404301</review_id>
24
+ <review_url>http://losangeles.citysearch.com/review/32693642</review_url>
25
+ <review_title>An All-Around Favorite!!</review_title>
26
+ <review_author>modeangel</review_author>
27
+ <review_author_url>http://my.citysearch.com/members/public/profile/modeangel</review_author_url>
28
+ <review_text>I have eaten at all the different "big' name Mexican restaurants and that's all they have going for them is their name...and maybe their "big" prices. Joselito's, by far, is the absolute best!! Every meal is fresh to order and always served by warm, friendly servers. All meals are reasonably priced. It's great for a party of one or for a party of 40. Joselito's may be family owned business but every customer is treated like family. </review_text>
29
+ <pros/>
30
+ <cons/>
31
+ <review_date>2010-08-08T17:38:08Z</review_date>
32
+ <review_rating>10</review_rating>
33
+ </review>
34
+ <review attribution_text="Citysearch" attribution_logo="http://images.citysearch.net/assets/imgdb/custom/ue-357/CS_logo88x31.jpg" attribution_source="5">
35
+ <business_name>Joselito's Mexican Food</business_name>
36
+ <listing_id>32693642</listing_id>
37
+ <reference_id>1</reference_id>
38
+ <review_id>100404301</review_id>
39
+ <review_url>http://losangeles.citysearch.com/review/32693642</review_url>
40
+ <review_title>An All-Around Favorite!!</review_title>
41
+ <review_author>Terry Blair</review_author>
42
+ <review_author_url>http://my.citysearch.com/members/public/profile/Terry+Blair</review_author_url>
43
+ <review_text>I have eaten at all the different "big' name Mexican restaurants and that's all they have going for them is their name...and maybe their "big" prices. Joselito's, by far, is the absolute best!! Every meal is fresh to order and always served by warm, friendly servers. All meals are reasonably priced. It's great for a party of one or for a party of 40. Joselito's may be family owned business but every customer is treated like family. </review_text>
44
+ <pros/>
45
+ <cons/>
46
+ <review_date>2010-08-08T17:38:08Z</review_date>
47
+ <review_rating>10</review_rating>
48
+ </review>
49
+ <review attribution_text="Citysearch" attribution_logo="http://images.citysearch.net/assets/imgdb/custom/ue-357/CS_logo88x31.jpg" attribution_source="5">
50
+ <business_name>Juicy Burger</business_name>
51
+ <listing_id>603968882</listing_id>
52
+ <reference_id>1</reference_id>
53
+ <review_id>100197361</review_id>
54
+ <review_url>http://losangeles.citysearch.com/review/603968882</review_url>
55
+ <review_title>I like it</review_title>
56
+ <review_author>Bubuxu</review_author>
57
+ <review_author_url>http://my.citysearch.com/members/public/profile/Bubuxu</review_author_url>
58
+ <review_text>The price is right, the food is delicious, and the people are friendly. </review_text>
59
+ <pros/>
60
+ <cons/>
61
+ <review_date>2010-08-08T04:51:22Z</review_date>
62
+ <review_rating>8</review_rating>
63
+ </review>
64
+ <review attribution_text="Citysearch" attribution_logo="http://images.citysearch.net/assets/imgdb/custom/ue-357/CS_logo88x31.jpg" attribution_source="5">
65
+ <business_name>Joselito's Mexican Food</business_name>
66
+ <listing_id>32693642</listing_id>
67
+ <reference_id>1</reference_id>
68
+ <review_id>100154571</review_id>
69
+ <review_url>http://losangeles.citysearch.com/review/32693642</review_url>
70
+ <review_title>so wonderful food</review_title>
71
+ <review_author>modeangel</review_author>
72
+ <review_author_url>http://my.citysearch.com/members/public/profile/modeangel</review_author_url>
73
+ <review_text>cheese is good ,turkey is good</review_text>
74
+ <pros/>
75
+ <cons/>
76
+ <review_date>2010-08-07T22:06:29Z</review_date>
77
+ <review_rating>4</review_rating>
78
+ </review>
79
+ <review attribution_text="Citysearch" attribution_logo="http://images.citysearch.net/assets/imgdb/custom/ue-357/CS_logo88x31.jpg" attribution_source="5">
80
+ <business_name>Joselito's Mexican Food</business_name>
81
+ <listing_id>32693642</listing_id>
82
+ <reference_id>1</reference_id>
83
+ <review_id>100154571</review_id>
84
+ <review_url>http://losangeles.citysearch.com/review/32693642</review_url>
85
+ <review_title>so wonderful food</review_title>
86
+ <review_author>Bubuxu</review_author>
87
+ <review_author_url>http://my.citysearch.com/members/public/profile/Bubuxu</review_author_url>
88
+ <review_text>cheese is good ,turkey is good</review_text>
89
+ <pros/>
90
+ <cons/>
91
+ <review_date>2010-08-07T22:06:29Z</review_date>
92
+ <review_rating>4</review_rating>
93
+ </review>
94
+ <review attribution_text="Citysearch" attribution_logo="http://images.citysearch.net/assets/imgdb/custom/ue-357/CS_logo88x31.jpg" attribution_source="5">
95
+ <business_name>Joselito's Mexican Food</business_name>
96
+ <listing_id>32693642</listing_id>
97
+ <reference_id>1</reference_id>
98
+ <review_id>100154571</review_id>
99
+ <review_url>http://losangeles.citysearch.com/review/32693642</review_url>
100
+ <review_title>so wonderful food</review_title>
101
+ <review_author>Terry Blair</review_author>
102
+ <review_author_url>http://my.citysearch.com/members/public/profile/Terry+Blair</review_author_url>
103
+ <review_text>cheese is good ,turkey is good</review_text>
104
+ <pros/>
105
+ <cons/>
106
+ <review_date>2010-08-07T22:06:29Z</review_date>
107
+ <review_rating>4</review_rating>
108
+ </review>
109
+ <review attribution_text="Citysearch" attribution_logo="http://images.citysearch.net/assets/imgdb/custom/ue-357/CS_logo88x31.jpg" attribution_source="5">
110
+ <business_name>Juicy Burger</business_name>
111
+ <listing_id>603968882</listing_id>
112
+ <reference_id>1</reference_id>
113
+ <review_id>99609221</review_id>
114
+ <review_url>http://losangeles.citysearch.com/review/603968882</review_url>
115
+ <review_title>Best Burger ever!</review_title>
116
+ <review_author>Ritikita</review_author>
117
+ <review_author_url>http://my.citysearch.com/members/public/profile/Ritikita</review_author_url>
118
+ <review_text>Great Burgers, Great Fries, Great Sauces! and the place is awesome!</review_text>
119
+ <pros/>
120
+ <cons/>
121
+ <review_date>2010-08-06T13:56:58Z</review_date>
122
+ <review_rating>10</review_rating>
123
+ </review>
124
+ <review attribution_text="Citysearch" attribution_logo="http://images.citysearch.net/assets/imgdb/custom/ue-357/CS_logo88x31.jpg" attribution_source="5">
125
+ <business_name>Bombay Cafe</business_name>
126
+ <listing_id>92474</listing_id>
127
+ <reference_id>1</reference_id>
128
+ <review_id>99578431</review_id>
129
+ <review_url>http://losangeles.citysearch.com/review/92474</review_url>
130
+ <review_title>New owners have ruined this spot Stay Away!</review_title>
131
+ <review_author>Melodyman</review_author>
132
+ <review_author_url>http://my.citysearch.com/members/public/profile/Melodyman</review_author_url>
133
+ <review_text>This spot was recommended to us a few years ago and we have eaten there many times and been happy. However, after not visiting there for awhile my wife and I went there to have lunch this week. I should have known something was up when the waitress didnt know whart Saffron Rice was.. said they didnt have it only white Jasmin rice.. even thought we have had it every time we have gone there.. thought it was a new waitress and moved on.. Also, the Chicken Masala used to come with the chicken on the bone but now it was a bunch of chopped up white meat that tasted a bit old and chewy.. As we were leaving we passed another table of people and I heard the father asking for Saffron rice and getting the same answer I got.. It was then it dawned on me and I asked if there had been a recent ownership change,. The owner said yes. There is nothing worse than a restaurant changing owners and pretending everything is the same when it isnt. Its bait n switch, dishonest and reprehensible for them trying to make customers thing they are crazy for ordering something that every Indian restaurant offers and this one used to..
134
+ Shame.. it was a great place.. now off to find a better replacement.. stay away!!!
135
+ </review_text>
136
+ <pros/>
137
+ <cons/>
138
+ <review_date>2010-08-06T12:45:05Z</review_date>
139
+ <review_rating>2</review_rating>
140
+ </review>
141
+ <review attribution_text="Citysearch" attribution_logo="http://images.citysearch.net/assets/imgdb/custom/ue-357/CS_logo88x31.jpg" attribution_source="5">
142
+ <business_name>The India's Tandoori</business_name>
143
+ <listing_id>314039</listing_id>
144
+ <reference_id>1</reference_id>
145
+ <review_id>99309351</review_id>
146
+ <review_url>http://losangeles.citysearch.com/review/314039</review_url>
147
+ <review_title>The Worst Food Ever had in my whole life </review_title>
148
+ <review_author>clarkjesica</review_author>
149
+ <review_author_url>http://my.citysearch.com/members/public/profile/clarkjesica</review_author_url>
150
+ <review_text>I used to love this Indian place when old Punjabi owner was own this place, this is not even close to them, i had a tandoori chicken, totally rubber believe me or not i newer had like this tandoori chicken any where else , chicken tikka masala in the buffet very greasy, all other food was same no flavor at all, began bharta creamy blind flavor , all buffet very cheap quality samosa was too oily,
151
+ sorry to say this is not my choice at all .
152
+
153
+ the server was unpleasant UN experiences,
154
+
155
+ no worth to come here sorry sorry sorry !!!!!!!!
156
+ not recommended at all
157
+
158
+ </review_text>
159
+ <pros/>
160
+ <cons/>
161
+ <review_date>2010-08-05T23:36:19Z</review_date>
162
+ <review_rating>2</review_rating>
163
+ </review>
164
+ </reviews>
@@ -0,0 +1,35 @@
1
+ <?xml version="1.0"?>
2
+ <results queryid="" totalhits="1" lasthit="1" firsthit="1">
3
+ <!-- Copyright 2009 Citysearch -->
4
+ <uri>http://api.citysearch.com/search/locations?what=roots+coffee&amp;where=76180&amp;publisher=acme</uri>
5
+ <region type="postal_code">
6
+ <name>76180</name>
7
+ <latitude>32.86399</latitude>
8
+ <longitude>-97.215194</longitude>
9
+ <defaultradius>4.3600</defaultradius>
10
+ </region>
11
+ <location id="613027480">
12
+ <featured>false</featured>
13
+ <name>Roots Coffeehouse</name>
14
+ <address>
15
+ <street>9101 Boulevard 26</street>
16
+ <city>N Richland Hills</city>
17
+ <state>TX</state>
18
+ <postalcode>76180</postalcode>
19
+ </address>
20
+ <neighborhood/>
21
+ <latitude>32.849869</latitude>
22
+ <longitude>-97.193291</longitude>
23
+ <phonenumber>8175037344</phonenumber>
24
+ <rating/>
25
+ <profile>http://national.citysearch.com/profile/613027480/n_richland_hills_tx/roots_coffeehouse.html</profile>
26
+ <hasvideo>false</hasvideo>
27
+ <hasoffers>false</hasoffers>
28
+ <offers/>
29
+ <userreviewcount>0</userreviewcount>
30
+ <samplecategories>Coffeehouses</samplecategories>
31
+ </location>
32
+ <histogram name="Categories">
33
+ <item name="Coffeehouses" count="1">http://api.citysearch.com/search/locations?what=roots+coffee&amp;tag=1726&amp;where=76180&amp;publisher=acme</item>
34
+ </histogram>
35
+ </results>
@@ -0,0 +1,37 @@
1
+ require 'test/unit'
2
+ require 'pathname'
3
+ require 'rubygems'
4
+
5
+ require 'shoulda'
6
+ require 'matchy'
7
+ require 'fakeweb'
8
+
9
+ begin require 'redgreen'; rescue LoadError; end
10
+
11
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
12
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
13
+ require 'citygrid'
14
+
15
+ # Set the default allow_net_connect option--usually you'll want this off.
16
+ # You don't usually want your test suite to make HTTP connections, do you?
17
+
18
+ FakeWeb.allow_net_connect = false
19
+
20
+ class Test::Unit::TestCase
21
+ end
22
+
23
+ def fixture_file(filename)
24
+ return '' if filename == ''
25
+ file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
26
+ File.read(file_path)
27
+ end
28
+
29
+ def citygrid_url(url, options={})
30
+ url =~ /^http/ ? url : "http://api2.citysearch.com#{url}"
31
+ end
32
+
33
+ def stub_get(url, filename, options={})
34
+ opts = {:body => fixture_file(filename)}.merge(options)
35
+
36
+ FakeWeb.register_uri(:get, citygrid_url(url), opts)
37
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
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-06-27 00:00:00 -05:00
17
+ date: 2010-08-12 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -50,9 +50,13 @@ files:
50
50
  - lib/citygrid.rb
51
51
  - lib/citygrid/client.rb
52
52
  - pkg/citygrid-0.1.0.gem
53
+ - pkg/citygrid-0.1.1.gem
53
54
  - tasks/citygrid_tasks.rake
54
55
  - test/citygrid_test.rb
55
- - test/test_helper.rb
56
+ - test/fixtures/profile.xml
57
+ - test/fixtures/review.xml
58
+ - test/fixtures/search.xml
59
+ - test/helper.rb
56
60
  - uninstall.rb
57
61
  has_rdoc: true
58
62
  homepage: http://github.com/phuphighter/citygrid
@@ -86,4 +90,4 @@ specification_version: 3
86
90
  summary: Ruby wrapper for the CityGrid API
87
91
  test_files:
88
92
  - test/citygrid_test.rb
89
- - test/test_helper.rb
93
+ - test/helper.rb
@@ -1,3 +0,0 @@
1
- require 'rubygems'
2
- require 'active_support'
3
- require 'active_support/test_case'