yahoo-local 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/yahoo_local/client.rb +1 -0
- data/pkg/yahoo-local-0.1.3.gem +0 -0
- data/test/fixtures/search.json +75 -0
- data/test/test_helper.rb +36 -2
- data/test/yahoo_local_test.rb +16 -4
- data/yahoo-local.gemspec +4 -2
- metadata +5 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/lib/yahoo_local/client.rb
CHANGED
Binary file
|
@@ -0,0 +1,75 @@
|
|
1
|
+
|
2
|
+
{
|
3
|
+
"ResultSet":
|
4
|
+
{
|
5
|
+
"totalResultsAvailable":"1596",
|
6
|
+
"totalResultsReturned":"1",
|
7
|
+
"firstResultPosition":"1",
|
8
|
+
"ResultSetMapUrl":"http:\/\/maps.yahoo.com\/broadband\/?q1=Beverly+Hills%2C+CA+90210&tt=pizza&tp=1",
|
9
|
+
"Result":
|
10
|
+
{
|
11
|
+
"id":"20478419",
|
12
|
+
"Title":"California Pizza Kitchen",
|
13
|
+
"Address":"207 S Beverly Dr",
|
14
|
+
"City":"Beverly Hills",
|
15
|
+
"State":"CA",
|
16
|
+
"Phone":"(310) 275-1101",
|
17
|
+
"Latitude":"34.064568",
|
18
|
+
"Longitude":"-118.399254",
|
19
|
+
"Rating":
|
20
|
+
{
|
21
|
+
"AverageRating":"4.5",
|
22
|
+
"TotalRatings":"64",
|
23
|
+
"TotalReviews":"64",
|
24
|
+
"LastReviewDate":"1274998064",
|
25
|
+
"LastReviewIntro":"I had the best BBQ Chicken Salad last night. It was really good and tasted very fresh."
|
26
|
+
},
|
27
|
+
"Distance":"2.07",
|
28
|
+
"Url":"http:\/\/local.yahoo.com\/info-20478419-california-pizza-kitchen-beverly-hills",
|
29
|
+
"ClickUrl":"http:\/\/local.yahoo.com\/info-20478419-california-pizza-kitchen-beverly-hills",
|
30
|
+
"MapUrl":"http:\/\/maps.yahoo.com\/maps_result?q1=207+S+Beverly+Dr+Beverly+Hills+CA&gid1=20478419",
|
31
|
+
"BusinessUrl":"http:\/\/www.cpk.com\/",
|
32
|
+
"BusinessClickUrl":"http:\/\/www.cpk.com\/",
|
33
|
+
"Categories":
|
34
|
+
{
|
35
|
+
"Category":
|
36
|
+
[
|
37
|
+
{
|
38
|
+
"id":"96926057",
|
39
|
+
"content":"All Bars,
|
40
|
+
Pubs,
|
41
|
+
& Clubs"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"id":"96926155",
|
45
|
+
"content":"Californian Restaurants"
|
46
|
+
},
|
47
|
+
{
|
48
|
+
"id":"96926190",
|
49
|
+
"content":"Italian Restaurants"
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"id":"96926225",
|
53
|
+
"content":"Salad Restaurants"
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"id":"96926234",
|
57
|
+
"content":"Carry Out & Take Out"
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"id":"96926236",
|
61
|
+
"content":"Restaurants"
|
62
|
+
},
|
63
|
+
{
|
64
|
+
"id":"96926238",
|
65
|
+
"content":"Sandwiches"
|
66
|
+
},
|
67
|
+
{
|
68
|
+
"id":"96926243",
|
69
|
+
"content":"Pizza"
|
70
|
+
}
|
71
|
+
]
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
data/test/test_helper.rb
CHANGED
@@ -1,3 +1,37 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'pathname'
|
1
3
|
require 'rubygems'
|
2
|
-
|
3
|
-
require '
|
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 'yahoo_local'
|
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 yahoo_local_url(url, options={})
|
30
|
+
url =~ /^http/ ? url : "http://local.yahooapis.com/LocalSearchService/V3#{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, yahoo_local_url(url), opts)
|
37
|
+
end
|
data/test/yahoo_local_test.rb
CHANGED
@@ -1,8 +1,20 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
class YahooLocalTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "Yahoo Local API" do
|
6
|
+
setup do
|
7
|
+
@client = YahooLocal::Client.new(:appid => 'wtf')
|
8
|
+
end
|
9
|
+
|
10
|
+
context "and searching for a place" do
|
11
|
+
should "find a specific place" do
|
12
|
+
stub_get("http://local.yahooapis.com/LocalSearchService/V3/localSearch?query=pizza&zip=90210&results=1&output=json&appid=wtf", "search.json")
|
13
|
+
search_result = @client.search(:query => "pizza", :zip => "90210", :results => 1)
|
14
|
+
search_result["ResultSet"]["Result"]["Title"].should == "California Pizza Kitchen"
|
15
|
+
search_result["ResultSet"]["Result"]["City"].should == "Beverly Hills"
|
16
|
+
end
|
17
|
+
end
|
7
18
|
end
|
19
|
+
|
8
20
|
end
|
data/yahoo-local.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{yahoo-local}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.4"
|
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-
|
12
|
+
s.date = %q{2010-08-12}
|
13
13
|
s.description = %q{Ruby wrapper for the Yahoo! Local Search API}
|
14
14
|
s.email = %q{johnnyn@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -27,7 +27,9 @@ Gem::Specification.new do |s|
|
|
27
27
|
"pkg/yahoo-local-0.1.0.gem",
|
28
28
|
"pkg/yahoo-local-0.1.1.gem",
|
29
29
|
"pkg/yahoo-local-0.1.2.gem",
|
30
|
+
"pkg/yahoo-local-0.1.3.gem",
|
30
31
|
"tasks/yahoo_local_tasks.rake",
|
32
|
+
"test/fixtures/search.json",
|
31
33
|
"test/test_helper.rb",
|
32
34
|
"test/yahoo_local_test.rb",
|
33
35
|
"uninstall.rb",
|
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
|
+
- 4
|
9
|
+
version: 0.1.4
|
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-08-12 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -51,7 +51,9 @@ files:
|
|
51
51
|
- pkg/yahoo-local-0.1.0.gem
|
52
52
|
- pkg/yahoo-local-0.1.1.gem
|
53
53
|
- pkg/yahoo-local-0.1.2.gem
|
54
|
+
- pkg/yahoo-local-0.1.3.gem
|
54
55
|
- tasks/yahoo_local_tasks.rake
|
56
|
+
- test/fixtures/search.json
|
55
57
|
- test/test_helper.rb
|
56
58
|
- test/yahoo_local_test.rb
|
57
59
|
- uninstall.rb
|