lancecarlson-yahoo-se 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,6 +5,10 @@ module Yahoo
5
5
  # backlinks = Yahoo::SE.inlinks("http://rubyskills.com", :results => 100)
6
6
  #
7
7
  # backlinks.results
8
+ #
9
+ # backlinks.next
10
+ #
11
+ # backlinks.results
8
12
  def self.inlinks(domain, options={})
9
13
  Yahoo::SE::Inlinks.new(domain, options)
10
14
  end
@@ -12,16 +16,31 @@ module Yahoo
12
16
  class Inlinks
13
17
  SERVICE_PATH = "#{Yahoo::SE::SERVICE_PATH}/inlinkData"
14
18
 
19
+ attr_reader :request
20
+
15
21
  def initialize(domain, options)
16
22
  @domain = domain
17
23
  @options = options
18
24
  @options[:query] = domain
19
- results
25
+ @options[:results] = @options[:results] ||= 50
26
+ @options[:start] = @options[:start] ||= 1
20
27
  end
21
28
 
22
29
  # Displays the results for inlinks data
23
30
  def results
24
- Yahoo::SE::Request.new(Yahoo::SE::Inlinks::SERVICE_PATH, @options).results
31
+ @request = Yahoo::SE::Request.new(Yahoo::SE::Inlinks::SERVICE_PATH, @options)
32
+ @request.results
33
+ end
34
+
35
+ # The response object from the request
36
+ def response
37
+ @request.response
38
+ end
39
+
40
+ # Reset the start option to the next results
41
+ def next
42
+ @options[:start] = @options[:start] + @options[:results]
43
+ self
25
44
  end
26
45
  end
27
46
  end
@@ -5,6 +5,10 @@ module Yahoo
5
5
  # page_data = Yahoo::SE.pages("http://rubyskills.com", :results => 100)
6
6
  #
7
7
  # page_data.results
8
+ #
9
+ # page_data.next
10
+ #
11
+ # page_data.results
8
12
  def self.pages(domain, options={})
9
13
  Yahoo::SE::Pages.new(domain, options)
10
14
  end
@@ -12,16 +16,31 @@ module Yahoo
12
16
  class Pages
13
17
  SERVICE_PATH = "#{Yahoo::SE::SERVICE_PATH}/pageData"
14
18
 
19
+ attr_reader :request
20
+
15
21
  def initialize(domain, options)
16
22
  @domain = domain
17
23
  @options = options
18
24
  @options[:query] = domain
19
- results
25
+ @options[:results] = @options[:results] ||= 50
26
+ @options[:start] = @options[:start] ||= 1
20
27
  end
21
28
 
22
29
  # Displays the results for pages data
23
30
  def results
24
- Yahoo::SE::Request.new(Yahoo::SE::Pages::SERVICE_PATH, @options).results
31
+ @request = Yahoo::SE::Request.new(Yahoo::SE::Pages::SERVICE_PATH, @options)
32
+ @request.results
33
+ end
34
+
35
+ # The response object from the request
36
+ def response
37
+ @request.response
38
+ end
39
+
40
+ # Reset the start option to the next results
41
+ def next
42
+ @options[:start] = @options[:start] + @options[:results]
43
+ self
25
44
  end
26
45
  end
27
46
  end
@@ -25,7 +25,7 @@ module Yahoo
25
25
 
26
26
  # The response object of the request
27
27
  def response
28
- Yahoo::SE::Response.new(response_body)
28
+ @response = @response ||= Yahoo::SE::Response.new(response_body)
29
29
  end
30
30
 
31
31
  # The response body of the request
@@ -1,5 +1,5 @@
1
1
  module Yahoo
2
2
  module SE
3
- VERSION = "1.0.0" unless defined?(Yahoo::SE::VERSION)
3
+ VERSION = "1.0.1" unless defined?(Yahoo::SE::VERSION)
4
4
  end
5
5
  end
@@ -12,7 +12,17 @@ describe Yahoo::SE::Inlinks do
12
12
 
13
13
  it "should return 100 inlink results" do
14
14
  Yahoo::SE.application_id = "123"
15
- Yahoo::SE::Request.should_receive(:new).with("http://search.yahooapis.com/SiteExplorerService/V1/inlinkData", {:results=>100, :query=>"rubyskills.com"}).and_return(@request)
16
- Yahoo::SE.inlinks("rubyskills.com", :results => 100)
15
+ Yahoo::SE::Request.should_receive(:new).with("http://search.yahooapis.com/SiteExplorerService/V1/inlinkData", {:results=>100, :query=>"http://rubyskills.com", :start => 1}).and_return(@request)
16
+ Yahoo::SE.inlinks("http://rubyskills.com", :results => 100).results
17
+ end
18
+
19
+ it "should return the next 75 inlink results" do
20
+ Yahoo::SE.application_id = "123"
21
+ Yahoo::SE::Request.should_receive(:new).with("http://search.yahooapis.com/SiteExplorerService/V1/inlinkData", {:results=>75, :query=>"http://rubyskills.com", :start => 1}).and_return(@request)
22
+ inlinks = Yahoo::SE.inlinks("http://rubyskills.com", :results => 75)
23
+ inlinks.results
24
+ Yahoo::SE::Request.should_receive(:new).with("http://search.yahooapis.com/SiteExplorerService/V1/inlinkData", {:results=>75, :query=>"http://rubyskills.com", :start => 76}).and_return(@request)
25
+ inlinks.next.should == inlinks
26
+ inlinks.results
17
27
  end
18
28
  end
@@ -12,7 +12,17 @@ describe Yahoo::SE::Pages do
12
12
 
13
13
  it "should return 50 page results" do
14
14
  Yahoo::SE.application_id = "123"
15
- Yahoo::SE::Request.should_receive(:new).with("http://search.yahooapis.com/SiteExplorerService/V1/pageData", {:query=>"erbmicha.com"}).and_return(@request)
16
- Yahoo::SE.pages("erbmicha.com")
15
+ Yahoo::SE::Request.should_receive(:new).with("http://search.yahooapis.com/SiteExplorerService/V1/pageData", {:query=>"erbmicha.com", :results => 50, :start => 1}).and_return(@request)
16
+ Yahoo::SE.pages("erbmicha.com").results
17
+ end
18
+
19
+ it "should return the next 75 inlink results" do
20
+ Yahoo::SE.application_id = "123"
21
+ Yahoo::SE::Request.should_receive(:new).with("http://search.yahooapis.com/SiteExplorerService/V1/pageData", {:results=>75, :query=>"http://rubyskills.com", :start => 1}).and_return(@request)
22
+ pages = Yahoo::SE.pages("http://rubyskills.com", :results => 75)
23
+ pages.results
24
+ Yahoo::SE::Request.should_receive(:new).with("http://search.yahooapis.com/SiteExplorerService/V1/pageData", {:results=>75, :query=>"http://rubyskills.com", :start => 76}).and_return(@request)
25
+ pages.next.should == pages
26
+ pages.results
17
27
  end
18
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lancecarlson-yahoo-se
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lance Carlson