Class Webby::LinkValidator
In: lib/webby/link_validator.rb
Parent: Object

The Webby LinkValidator class is used to validate the hyperlinks of all the HTML files in the output directory. By default, only links to other pages in the output directory are checked. However, setting the :external flag to true will cause hyperlinks to external web sites to be validated as well.

Methods

Attributes

validate_externals  [RW] 

Public Class methods

Creates a new LinkValidator object. The only supported option is the :external flag. When set to true, the link validator will also check out links to external websites. This is done by opening a connection to the remote site and pulling down the page specified in the hyperlink. Use with caution.

A lazy man‘s method that will instantiate a new link validator and run the validations.

Public Instance methods

Check the given file (identified by its filename {fn for short here}) by iterating through all the configured xpaths and validating that those hyperlinks ae valid.

Iterate over all the HTML files in the output directory and validate the hyperlinks.

Validate that the anchor fragment of the URI exists in the given document. The document is an Hpricot document object.

Returns true if the anchor exists in the document and false if it does not.

Validate that an external URI can be opened

Validate that the file pointed to by the relative URI exists in the output directory. If the URI has an anchor, validate that the anchor exists as well.

Validate the the page the uri refers to actually exists. The directory of the current page being processed is needed in order to resolve relative paths.

If the uri is a relative path, then the output directory is searched for the appropriate page. If the uri is an absolute path, then the remote server is contacted and the page requested from the server. This will only take place if the LinkValidator was created with the :external flag set to true.

[Validate]