yahoo-search 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/LICENSE.txt +2 -1
- data/README.txt +3 -3
- data/Rakefile +4 -4
- data/lib/yahoo/local_search.rb +27 -28
- data/lib/yahoo/search.rb +5 -5
- data/lib/yahoo/web_search.rb +12 -10
- data/test/test_web_search.rb +1 -0
- metadata +62 -51
data/History.txt
CHANGED
data/LICENSE.txt
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
Copyright 2006 Eric Hodel, The Robot Co-op.
|
1
|
+
Copyright 2006 Eric Hodel, The Robot Co-op.
|
2
|
+
Copyright 2010 David N. Welton, DedaSys LLC.
|
2
3
|
|
3
4
|
Redistribution and use in source and binary forms, with or without
|
4
5
|
modification, are permitted provided that the following conditions
|
data/README.txt
CHANGED
data/Rakefile
CHANGED
@@ -7,13 +7,13 @@ DEV_DOC_PATH = 'Libraries/yahoo-search'
|
|
7
7
|
hoe = Hoe.new 'yahoo-search', Yahoo::Search::VERSION do |p|
|
8
8
|
p.summary = 'A Ruby Yahoo Search API Implementation'
|
9
9
|
p.description = 'An interface to Yahoo\'s Search services.'
|
10
|
-
p.author = '
|
11
|
-
p.email = '
|
12
|
-
p.url = "http://
|
10
|
+
p.author = 'David N. Welton'
|
11
|
+
p.email = 'davidw@dedasys.com'
|
12
|
+
p.url = "http://github.com/davidw/yahoo-search-gem"
|
13
13
|
p.changes = File.read('History.txt').scan(/\A(=.*?)^=/m).first.first
|
14
14
|
p.rubyforge_name = 'rctools'
|
15
15
|
|
16
|
-
p.extra_deps << ['yahoo', '>=
|
16
|
+
p.extra_deps << ['yahoo', '>= 2.0.0']
|
17
17
|
end
|
18
18
|
|
19
19
|
SPEC = hoe.spec
|
data/lib/yahoo/local_search.rb
CHANGED
@@ -59,40 +59,39 @@ class Yahoo::LocalSearch < Yahoo::Search
|
|
59
59
|
def parse_response(xml) # :nodoc:
|
60
60
|
search_results = []
|
61
61
|
|
62
|
-
result_set_map_url = URI.parse
|
62
|
+
result_set_map_url = URI.parse(xml.at_xpath('//xmlns:ResultSetMapUrl').content)
|
63
63
|
total_results_available, total_results_returned, first_result_position =
|
64
|
-
parse_result_info
|
64
|
+
parse_result_info(xml)
|
65
65
|
|
66
|
-
xml.
|
67
|
-
next unless r.name == 'Result'
|
66
|
+
xml.xpath('//xmlns:Result').each do |r|
|
68
67
|
sr = Result.new
|
69
68
|
|
70
|
-
sr.id = r
|
71
|
-
sr.title = r.
|
72
|
-
sr.address = r.
|
73
|
-
sr.city = r.
|
74
|
-
sr.state = r.
|
75
|
-
sr.phone = r.
|
76
|
-
sr.latitude = r.
|
77
|
-
sr.longitude = r.
|
78
|
-
|
79
|
-
rating = r.
|
80
|
-
sr.average_rating = rating.
|
81
|
-
sr.total_ratings = rating.
|
82
|
-
sr.total_reviews = rating.
|
83
|
-
sr.last_review_date = Time.at rating.
|
84
|
-
sr.last_review_intro = rating.
|
85
|
-
|
86
|
-
sr.distance = r.
|
87
|
-
sr.url = URI.parse r.
|
88
|
-
sr.click_url = URI.parse r.
|
89
|
-
sr.map_url = URI.parse r.
|
90
|
-
sr.business_url = URI.parse r.
|
91
|
-
sr.business_click_url = URI.parse r.
|
69
|
+
sr.id = r['id'].to_i
|
70
|
+
sr.title = r.at_xpath('xmlns:Title').content
|
71
|
+
sr.address = r.at_xpath('xmlns:Address').content
|
72
|
+
sr.city = r.at_xpath('xmlns:City').content
|
73
|
+
sr.state = r.at_xpath('xmlns:State').content
|
74
|
+
sr.phone = r.at_xpath('xmlns:Phone').content
|
75
|
+
sr.latitude = r.at_xpath('xmlns:Latitude').content.to_f
|
76
|
+
sr.longitude = r.at_xpath('xmlns:Longitude').content.to_f
|
77
|
+
|
78
|
+
rating = r.at_xpath('xmlns:Rating')
|
79
|
+
sr.average_rating = rating.at_xpath('xmlns:AverageRating').content.to_f
|
80
|
+
sr.total_ratings = rating.at_xpath('xmlns:TotalRatings').content.to_i
|
81
|
+
sr.total_reviews = rating.at_xpath('xmlns:TotalReviews').content.to_i
|
82
|
+
sr.last_review_date = Time.at rating.at_xpath('xmlns:LastReviewDate').content.to_i
|
83
|
+
sr.last_review_intro = rating.at_xpath('xmlns:LastReviewIntro').content
|
84
|
+
|
85
|
+
sr.distance = r.at_xpath('xmlns:Distance').content.to_f
|
86
|
+
sr.url = URI.parse r.at_xpath('xmlns:Url').content
|
87
|
+
sr.click_url = URI.parse r.at_xpath('xmlns:ClickUrl').content
|
88
|
+
sr.map_url = URI.parse r.at_xpath('xmlns:MapUrl').content
|
89
|
+
sr.business_url = URI.parse r.at_xpath('xmlns:BusinessUrl').content
|
90
|
+
sr.business_click_url = URI.parse r.at_xpath('xmlns:BusinessClickUrl').content
|
92
91
|
|
93
92
|
sr.categories = {}
|
94
|
-
r.
|
95
|
-
sr.categories[c.
|
93
|
+
r.xpath('.//xmlns:Category').each do |c|
|
94
|
+
sr.categories[c.content] = c['id'].to_i
|
96
95
|
end
|
97
96
|
|
98
97
|
search_results << sr
|
data/lib/yahoo/search.rb
CHANGED
@@ -5,17 +5,17 @@ require 'yahoo'
|
|
5
5
|
|
6
6
|
class Yahoo::Search < Yahoo
|
7
7
|
|
8
|
-
VERSION = '
|
8
|
+
VERSION = '2.0.0'
|
9
9
|
|
10
10
|
##
|
11
11
|
# Returns the total results available, returned, and first result position
|
12
12
|
# for the returned results.
|
13
13
|
|
14
14
|
def parse_result_info(xml) # :nodoc:
|
15
|
-
rs = xml.
|
16
|
-
total_results_available = rs
|
17
|
-
total_results_returned = rs
|
18
|
-
first_result_position = rs
|
15
|
+
rs = xml.at_xpath('//xmlns:ResultSet')
|
16
|
+
total_results_available = rs['totalResultsAvailable'].to_i
|
17
|
+
total_results_returned = rs['totalResultsReturned'].to_i
|
18
|
+
first_result_position = rs['firstResultPosition'].to_i
|
19
19
|
|
20
20
|
return total_results_available, total_results_returned,
|
21
21
|
first_result_position
|
data/lib/yahoo/web_search.rb
CHANGED
@@ -37,18 +37,20 @@ class Yahoo::WebSearch < Yahoo::Search
|
|
37
37
|
total_results_available, total_results_returned, first_result_position =
|
38
38
|
parse_result_info xml
|
39
39
|
|
40
|
-
xml.
|
41
|
-
next if REXML::Text === r
|
40
|
+
xml.xpath('//xmlns:Result').each do |r|
|
42
41
|
result = Result.new
|
43
42
|
|
44
|
-
result.title = r.
|
45
|
-
result.summary = r.
|
46
|
-
result.url = URI.parse
|
47
|
-
result.click_url = URI.parse
|
48
|
-
result.mime_type = r.
|
49
|
-
result.modification_date = Time.at
|
50
|
-
|
51
|
-
|
43
|
+
result.title = r.at_xpath('xmlns:Title').content
|
44
|
+
result.summary = r.at_xpath('xmlns:Summary').content
|
45
|
+
result.url = URI.parse(r.at_xpath('xmlns:Url').content)
|
46
|
+
result.click_url = URI.parse(r.at_xpath('xmlns:ClickUrl').content)
|
47
|
+
result.mime_type = r.at_xpath('xmlns:MimeType').content
|
48
|
+
result.modification_date = Time.at(r.at_xpath('xmlns:ModificationDate').content.to_i)
|
49
|
+
cacheurl = r.at_xpath('xmlns:Cache/xmlns:Url')
|
50
|
+
if cacheurl
|
51
|
+
result.cache_url = URI.parse(cacheurl.content)
|
52
|
+
result.cache_size = r.at_xpath('xmlns:Cache/xmlns:Size').content.to_i
|
53
|
+
end
|
52
54
|
|
53
55
|
search_results << result
|
54
56
|
end
|
data/test/test_web_search.rb
CHANGED
metadata
CHANGED
@@ -1,62 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.0.6
|
3
|
-
specification_version: 1
|
4
2
|
name: yahoo-search
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version:
|
7
|
-
date: 2006-11-27 00:00:00 -08:00
|
8
|
-
summary: A Ruby Yahoo Search API Implementation
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: drbrain@segment7.net
|
12
|
-
homepage: http://dev.robotcoop.com/Libraries/yahoo-search
|
13
|
-
rubyforge_project: rctools
|
14
|
-
description: An interface to Yahoo's Search services.
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 2.0.0
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Eric Hodel
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
-
|
36
|
-
|
37
|
-
- lib/yahoo/local_search.rb
|
38
|
-
- lib/yahoo/search.rb
|
39
|
-
- lib/yahoo/web_search.rb
|
40
|
-
- test/test_local_search.rb
|
41
|
-
- test/test_web_search.rb
|
42
|
-
test_files:
|
43
|
-
- test/test_local_search.rb
|
44
|
-
- test/test_web_search.rb
|
45
|
-
rdoc_options: []
|
46
|
-
|
47
|
-
extra_rdoc_files: []
|
48
|
-
|
49
|
-
executables: []
|
50
|
-
|
51
|
-
extensions: []
|
52
|
-
|
53
|
-
requirements: []
|
54
|
-
|
8
|
+
- David N. Welton
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain:
|
12
|
+
date: 2010-01-13 00:00:00 +01:00
|
13
|
+
default_executable:
|
55
14
|
dependencies:
|
56
15
|
- !ruby/object:Gem::Dependency
|
57
16
|
name: hoe
|
17
|
+
type: :runtime
|
58
18
|
version_requirement:
|
59
|
-
version_requirements: !ruby/object:Gem::
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
20
|
requirements:
|
61
21
|
- - ">="
|
62
22
|
- !ruby/object:Gem::Version
|
@@ -64,10 +24,61 @@ dependencies:
|
|
64
24
|
version:
|
65
25
|
- !ruby/object:Gem::Dependency
|
66
26
|
name: yahoo
|
27
|
+
type: :runtime
|
67
28
|
version_requirement:
|
68
|
-
version_requirements: !ruby/object:Gem::
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
30
|
requirements:
|
70
31
|
- - ">="
|
71
32
|
- !ruby/object:Gem::Version
|
72
|
-
version:
|
33
|
+
version: 2.0.0
|
73
34
|
version:
|
35
|
+
description: An interface to Yahoo's Search services.
|
36
|
+
email: davidw@dedasys.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
43
|
+
files:
|
44
|
+
- History.txt
|
45
|
+
- LICENSE.txt
|
46
|
+
- Manifest.txt
|
47
|
+
- README.txt
|
48
|
+
- Rakefile
|
49
|
+
- lib/yahoo/local_search.rb
|
50
|
+
- lib/yahoo/search.rb
|
51
|
+
- lib/yahoo/web_search.rb
|
52
|
+
- test/test_local_search.rb
|
53
|
+
- test/test_web_search.rb
|
54
|
+
has_rdoc: true
|
55
|
+
homepage: http://github.com/davidw/yahoo-search-gem
|
56
|
+
licenses: []
|
57
|
+
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.0.0
|
68
|
+
version:
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
|
+
version:
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project: rctools
|
78
|
+
rubygems_version: 1.3.5
|
79
|
+
signing_key:
|
80
|
+
specification_version: 1
|
81
|
+
summary: A Ruby Yahoo Search API Implementation
|
82
|
+
test_files:
|
83
|
+
- test/test_local_search.rb
|
84
|
+
- test/test_web_search.rb
|