-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Slow as a baby, steady as a soldier. We'll find those links in need!
- Loading branch information
1 parent
8579a28
commit feb1df2
Showing
12 changed files
with
216 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<html> | ||
<body> | ||
<ul> | ||
<li> | ||
<a href="one-link-away.html">One link away</a> | ||
</li> | ||
<li> | ||
<a href="http://localhost:7654/">External site</a> | ||
</li> | ||
</ul> | ||
|
||
<h2>Sad Paths:</h2> | ||
<ul> | ||
<li> | ||
<a href="some-page-that-does-not-exist.html">Page that does not exist anymore</a> | ||
</li> | ||
</ul> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<html> | ||
<body> | ||
<h2>I exist!</h2> | ||
<ul> | ||
<li> | ||
<a href="some-page-that-does-not-exist.html">Page that does not exist anymore</a> | ||
</li> | ||
<li> | ||
<a href="two-links-away.html">Two links away</a> | ||
</li> | ||
</ul> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<html> | ||
<body> | ||
<h2>I exist!</h2> | ||
<ul> | ||
<li> | ||
<a href="some-page-that-does-not-exist.html">Page that does not exist anymore</a> | ||
</li> | ||
<li> | ||
<a href="four-links-away.html">Four links away</a> | ||
</li> | ||
</ul> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<html> | ||
<body> | ||
<h2>I exist!</h2> | ||
<ul> | ||
<li> | ||
<a href="some-page-that-does-not-exist.html">Page that does not exist anymore</a> | ||
</li> | ||
<li> | ||
<a href="three-links-away.html">Three links away</a> | ||
</li> | ||
</ul> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
<h2>This is an externally hosted guide that may be tangentially related to your documentation</h2> | ||
<html> | ||
<body> | ||
<h2>This is an externally hosted guide that may be related to your documentation, but not maintained by you</h2> | ||
<ul> | ||
<li> | ||
<a href="one-link-away.html">Page that exists</a> | ||
</li> | ||
<li> | ||
<a href="some-page-that-does-not-exist.html">Page that does not exist</a> | ||
</li> | ||
</ul> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<html> | ||
<body> | ||
<h2>I exist!</h2> | ||
<ul> | ||
<li> | ||
<a href="some-page-that-does-not-exist.html">Page that does not exist anymore</a> | ||
</li> | ||
</ul> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
module DocDoc | ||
module Configuration | ||
module Crawling | ||
Options = Struct.new(:boundary, :max_spiderings) | ||
class Options | ||
attr_reader :boundary, :max_spiderings | ||
|
||
def initialize(boundary = nil, max_spiderings = 0) | ||
@boundary = boundary | ||
@max_spiderings = max_spiderings | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
require "test_helper" | ||
require "static_server" | ||
|
||
class CrawlingTest < Minitest::Test | ||
def test_it_does_something_useful | ||
@server = StaticServer.start('example_crawling_start', 0) | ||
@external_server = StaticServer.start('example_external_site', 7654) | ||
|
||
quarantine_entrance = "http://localhost:#{@server.config[:Port]}" | ||
external_site_entrance = "http://localhost:7654" | ||
|
||
config = DocDoc::Configuration::Options.new( | ||
quarantine_entrance, | ||
nil, | ||
DocDoc::Configuration::Crawling::Options.new(nil, 2) | ||
) | ||
prescription = DocDoc.prescription(config) | ||
|
||
assert_equal(expected_prescription(quarantine_entrance, external_site_entrance), JSON.parse(prescription.to_s)) | ||
ensure | ||
@server.shutdown | ||
@external_server.shutdown | ||
end | ||
|
||
private | ||
|
||
def expected_prescription(quarantine_entrance, external_site) | ||
{ | ||
"links" => [ | ||
{ | ||
"page" => quarantine_entrance, | ||
"href" => "#{quarantine_entrance}/some-page-that-does-not-exist.html", | ||
"error" => { | ||
"type" => "http", | ||
"description" => 404 | ||
} | ||
}, { | ||
"page" => "#{quarantine_entrance}/one-link-away.html", | ||
"href" => "#{quarantine_entrance}/some-page-that-does-not-exist.html", | ||
"error" => { | ||
"type" => "http", | ||
"description" => 404 | ||
} | ||
}, { | ||
"page" => "#{quarantine_entrance}/two-links-away.html", | ||
"href" => "#{quarantine_entrance}/some-page-that-does-not-exist.html", | ||
"error" => { | ||
"type" => "http", | ||
"description" => 404 | ||
} | ||
}, { | ||
"page" => "#{external_site}/", | ||
"href" => "#{external_site}/some-page-that-does-not-exist.html", | ||
"error" => { | ||
"type" => "http", | ||
"description" => 404 | ||
} | ||
}, { | ||
"page" => "#{external_site}/one-link-away.html", | ||
"href" => "#{external_site}/some-page-that-does-not-exist.html", | ||
"error" => { | ||
"type" => "http", | ||
"description" => 404 | ||
} | ||
} | ||
] | ||
} | ||
end | ||
end |