class SiteChecker::IO::ContentFromFileSystem
Public Class Methods
new(visit_references, root)
click to toggle source
# File lib/site_checker/io/content_from_file_system.rb, line 5 def initialize(visit_references, root) @visit_references = visit_references @root = root end
Public Instance Methods
get(link)
click to toggle source
# File lib/site_checker/io/content_from_file_system.rb, line 10 def get(link) begin location = create_absolute_reference(link.url) if link.local_page? content = File.open(add_index_html(location)).read elsif link.local_image? File.open(location) elsif @visit_references open(link.url) end rescue Errno::ENOENT => e raise "(404 Not Found)" rescue => e raise "(#{e.message.strip})" end content end
Private Instance Methods
add_index_html(path)
click to toggle source
# File lib/site_checker/io/content_from_file_system.rb, line 29 def add_index_html(path) path = $1 if path.match(/(.+)#/) path.end_with?(".html") ? path : File.join(path, "index.html") end
create_absolute_reference(link)
click to toggle source
# File lib/site_checker/io/content_from_file_system.rb, line 34 def create_absolute_reference(link) if !link.eql?(@root) File.join(@root, link) else @root end end