class Grell::Page::VisitedPage
Private class. This is a result page when we successfully got some information back after visiting the page. It delegates most of the information to the @rawpage capybara page. But any transformation or logic is here
Public Class Methods
new(rawpage)
click to toggle source
# File lib/grell/page.rb, line 169 def initialize(rawpage) @rawpage = rawpage end
Public Instance Methods
body()
click to toggle source
# File lib/grell/page.rb, line 177 def body @rawpage.body end
has_selector?(selector)
click to toggle source
# File lib/grell/page.rb, line 203 def has_selector?(selector) @rawpage.has_selector?(selector) end
headers()
click to toggle source
# File lib/grell/page.rb, line 181 def headers @rawpage.headers rescue Capybara::Poltergeist::BrowserError => e #This may happen internally on Poltergeist, they claim is a bug. { grellStatus: 'Error', errorClass: e.class.to_s, errorMessage: e.message } end
host()
click to toggle source
# File lib/grell/page.rb, line 195 def host @rawpage.host end
links()
click to toggle source
# File lib/grell/page.rb, line 191 def links @links ||= all_links end
status()
click to toggle source
# File lib/grell/page.rb, line 173 def status @rawpage.status end
visited?()
click to toggle source
# File lib/grell/page.rb, line 199 def visited? true end
Private Instance Methods
all_links()
click to toggle source
# File lib/grell/page.rb, line 208 def all_links links = @rawpage.all_anchors.map { |anchor| Link.new(anchor) } body_enabled_links = links.reject { |link| link.inside_header? || link.disabled? || link.js_href? } body_enabled_links.map { |link| link.to_url(host) }.uniq.compact rescue Capybara::Poltergeist::ObsoleteNode Grell.logger.warn "We found an obsolete node in #{@url}. Ignoring all links" # Sometimes Javascript and timing may screw this, we lose these links. # TODO: Can we do something more intelligent here? [] end