lancecarlson-yahoo-se 1.0.0 → 1.0.1
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.
- data/lib/yahoo-se/inlinks.rb +21 -2
- data/lib/yahoo-se/pages.rb +21 -2
- data/lib/yahoo-se/request.rb +1 -1
- data/lib/yahoo-se/version.rb +1 -1
- data/spec/yahoo-se/inlinks_spec.rb +12 -2
- data/spec/yahoo-se/pages_spec.rb +12 -2
- metadata +1 -1
data/lib/yahoo-se/inlinks.rb
CHANGED
@@ -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)
|
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
|
data/lib/yahoo-se/pages.rb
CHANGED
@@ -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)
|
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
|
data/lib/yahoo-se/request.rb
CHANGED
data/lib/yahoo-se/version.rb
CHANGED
@@ -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
|
data/spec/yahoo-se/pages_spec.rb
CHANGED
@@ -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
|