yahoo_web_api 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,15 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'net/http'
4
+ require 'nokogiri'
5
+
3
6
  module YahooWebAPI
4
7
  class Client
5
8
  class << self
6
- def parse(doc)
9
+ def parse(doc, selector)
7
10
  results = []
8
11
  xml_doc = Nokogiri::XML(doc)
9
- xml_doc.css('ResultSet Result').each do |doc|
12
+ xml_doc.css(selector).each do |doc|
10
13
  results << make_response_object(doc)
11
14
  end
12
15
  results
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  libs = %w(
2
3
  image_search
3
4
  blog_search
@@ -1,6 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'net/http'
4
3
  require 'nokogiri'
5
4
 
6
5
  require 'yahoo_web_api/client'
@@ -10,7 +9,7 @@ module YahooWebAPI
10
9
  END_POINT = 'http://search.yahooapis.jp/BlogSearchService/V1/blogSearch'
11
10
 
12
11
  class << self
13
- def parse(doc)
12
+ def parse(doc, selector)
14
13
  results = super
15
14
  result_set = Nokogiri::XML(doc).css('ResultSet')[0]
16
15
  klass = (class << results; self; end)
@@ -33,7 +32,7 @@ module YahooWebAPI
33
32
  params = @parameters.merge(params)
34
33
  res = get(END_POINT, params)
35
34
  if res.code == '200'
36
- results = self.class.parse(res.body.to_s)
35
+ results = self.class.parse(res.body.to_s, 'ResultSet Result')
37
36
  return results
38
37
  else
39
38
  raise Exception, Nokogiri::XML(res.body).css('Error Message').inner_text
@@ -1,6 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'net/http'
4
3
  require 'nokogiri'
5
4
 
6
5
  require 'yahoo_web_api/client'
@@ -18,7 +17,7 @@ module YahooWebAPI
18
17
  params = @parameters.merge(params)
19
18
  res = post(END_POINT, params)
20
19
  if res.code == '200'
21
- results = self.class.parse(res.body.to_s)
20
+ results = self.class.parse(res.body.to_s, 'ResultSet Result')
22
21
  return results
23
22
  else
24
23
  raise Exception, Nokogiri::XML(res.body).css('Error Message').inner_text
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: yahoo_web_api
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.1
5
+ version: 0.2.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Tatsuya Sato
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-02-24 00:00:00 +09:00
13
+ date: 2011-03-23 00:00:00 +09:00
14
14
  default_executable:
15
15
  dependencies: []
16
16