yahoo_web_api 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,21 @@ module YahooWebAPI
9
9
  class BlogSearchService < Client
10
10
  END_POINT = 'http://search.yahooapis.jp/BlogSearchService/V1/blogSearch'
11
11
 
12
+ class << self
13
+ def parse(doc)
14
+ results = super
15
+ result_set = Nokogiri::XML(doc).css('ResultSet')[0]
16
+ klass = (class << results; self; end)
17
+ result_set.keys.each do |key|
18
+ method_name = key.gsub(/([a-z])([A-Z])/) {
19
+ $1 + '_' + $2
20
+ }.downcase
21
+ klass.__send__(:define_method, method_name) {result_set[key].to_i}
22
+ end
23
+ return results
24
+ end
25
+ end
26
+
12
27
  def initialize(args)
13
28
  @parameters = {}
14
29
  @parameters.merge!(args)
@@ -23,6 +23,9 @@ describe YahooWebAPI::BlogSearchService do
23
23
  it {lambda{@blog_search_service.blog_search(:query => 'Yahoo!検索スタッフブログ')}.should_not raise_error }
24
24
  it { should_not be_nil }
25
25
  its(:size) {should == 1}
26
+ its(:total_results_available) { should eql 759629 }
27
+ its(:total_results_returned) { should eql 10 }
28
+ its(:first_result_position) { should eql 1 }
26
29
 
27
30
  context "for Object returned blog_search" do
28
31
  subject {@blog_search_service.blog_search(:query => 'Yahoo!検索スタッフブログ')[0]}
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.0
5
+ version: 0.2.1
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-23 00:00:00 +09:00
13
+ date: 2011-02-24 00:00:00 +09:00
14
14
  default_executable:
15
15
  dependencies: []
16
16