yahoo-search 1.1.1 → 2.0.0

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.
@@ -1,3 +1,8 @@
1
+ = 2.0.0
2
+
3
+ * New maintainer: davidw@dedasys.com
4
+ * Depend on rc-rest >= 3.0.0 and utilize Nokogiri
5
+
1
6
  = 1.1.1
2
7
 
3
8
  * Upgraded to rc-rest 2.0.0 and yahoo 1.1.1
@@ -1,4 +1,5 @@
1
- Copyright 2006 Eric Hodel, The Robot Co-op. All rights reserved.
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
@@ -1,12 +1,12 @@
1
1
  = yahoo-search
2
2
 
3
- Rubyforge Project:
3
+ Github Project:
4
4
 
5
- http://rubyforge.org/projects/rctools/
5
+ http://github.com/davidw/yahoo-search-gem
6
6
 
7
7
  Documentation:
8
8
 
9
- http://dev.robotcoop.com/Libraries/yahoo-search/
9
+ FIXME
10
10
 
11
11
  == About
12
12
 
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 = 'Eric Hodel'
11
- p.email = 'drbrain@segment7.net'
12
- p.url = "http://dev.robotcoop.com/#{DEV_DOC_PATH}"
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', '>= 1.1.1']
16
+ p.extra_deps << ['yahoo', '>= 2.0.0']
17
17
  end
18
18
 
19
19
  SPEC = hoe.spec
@@ -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 xml.elements['ResultSet/ResultSetMapUrl'].text
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 xml
64
+ parse_result_info(xml)
65
65
 
66
- xml.elements['ResultSet'].each do |r|
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.attributes['id'].to_i
71
- sr.title = r.elements['Title'].text
72
- sr.address = r.elements['Address'].text
73
- sr.city = r.elements['City'].text
74
- sr.state = r.elements['State'].text
75
- sr.phone = r.elements['Phone'].text
76
- sr.latitude = r.elements['Latitude'].text.to_f
77
- sr.longitude = r.elements['Longitude'].text.to_f
78
-
79
- rating = r.elements['Rating']
80
- sr.average_rating = rating.elements['AverageRating'].text.to_f
81
- sr.total_ratings = rating.elements['TotalRatings'].text.to_i
82
- sr.total_reviews = rating.elements['TotalReviews'].text.to_i
83
- sr.last_review_date = Time.at rating.elements['LastReviewDate'].text.to_i
84
- sr.last_review_intro = rating.elements['LastReviewIntro'].text
85
-
86
- sr.distance = r.elements['Distance'].text.to_f
87
- sr.url = URI.parse r.elements['Url'].text
88
- sr.click_url = URI.parse r.elements['ClickUrl'].text
89
- sr.map_url = URI.parse r.elements['MapUrl'].text
90
- sr.business_url = URI.parse r.elements['BusinessUrl'].text
91
- sr.business_click_url = URI.parse r.elements['BusinessClickUrl'].text
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.elements['Categories'].each do |c|
95
- sr.categories[c.text] = c.attributes['id'].to_i
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
@@ -5,17 +5,17 @@ require 'yahoo'
5
5
 
6
6
  class Yahoo::Search < Yahoo
7
7
 
8
- VERSION = '1.1.1'
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.elements['ResultSet']
16
- total_results_available = rs.attributes['totalResultsAvailable'].to_i
17
- total_results_returned = rs.attributes['totalResultsReturned'].to_i
18
- first_result_position = rs.attributes['firstResultPosition'].to_i
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
@@ -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.elements['ResultSet'].each do |r|
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.elements['Title'].text
45
- result.summary = r.elements['Summary'].text
46
- result.url = URI.parse r.elements['Url'].text
47
- result.click_url = URI.parse r.elements['ClickUrl'].text
48
- result.mime_type = r.elements['MimeType'].text
49
- result.modification_date = Time.at r.elements['ModificationDate'].text.to_i
50
- result.cache_url = URI.parse r.elements['Cache/Url'].text
51
- result.cache_size = r.elements['Cache/Size'].text.to_i
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
@@ -1,4 +1,5 @@
1
1
  require 'test/unit'
2
+ require 'rubygems'
2
3
  require 'rc_rest/uri_stub'
3
4
  require 'yahoo/web_search'
4
5
 
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: 1.1.1
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
- files:
32
- - History.txt
33
- - LICENSE.txt
34
- - Manifest.txt
35
- - README.txt
36
- - Rakefile
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::Version::Requirement
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::Version::Requirement
29
+ version_requirements: !ruby/object:Gem::Requirement
69
30
  requirements:
70
31
  - - ">="
71
32
  - !ruby/object:Gem::Version
72
- version: 1.1.1
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