Class: Bookbinder::Spider
- Inherits:
-
Object
- Object
- Bookbinder::Spider
- Defined in:
- lib/bookbinder/spider.rb,
lib/bookbinder/stabilimentum.rb
Defined Under Namespace
Classes: Result, Stabilimentum
Class Method Summary collapse
Instance Method Summary collapse
- #find_broken_links(port, broken_link_exclusions: /(?!.*)/) ⇒ Object
-
#initialize(app_dir: nil) ⇒ Spider
constructor
A new instance of Spider.
Constructor Details
#initialize(app_dir: nil) ⇒ Spider
Returns a new instance of Spider.
38 39 40 |
# File 'lib/bookbinder/spider.rb', line 38 def initialize(app_dir: nil) @app_dir = app_dir || raise('Spiders must be initialized with an app directory.') end |
Class Method Details
.prepend_location(location, url) ⇒ Object
34 35 36 |
# File 'lib/bookbinder/spider.rb', line 34 def self.prepend_location(location, url) "#{URI(location).path} => #{url}" end |
Instance Method Details
#find_broken_links(port, broken_link_exclusions: /(?!.*)/) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/bookbinder/spider.rb', line 42 def find_broken_links(port, broken_link_exclusions: /(?!.*)/) temp_host = "localhost:#{port}" sieve = Sieve.new domain: "http://#{temp_host}" links = crawl_from "http://#{temp_host}/index.html", sieve broken_links = links.first public_broken_links = broken_links.reject {|l| l.match(broken_link_exclusions)} Result.new(public_broken_links) end |