class BrowserCrawler::EngineUtilities::LinkScanner
Attributes
link_inspector[R]
Public Class Methods
new(link_inspector:)
click to toggle source
# File lib/browser_crawler/engine_utilities/link_scanner.rb, line 9 def initialize(link_inspector:) @link_inspector = link_inspector end
Public Instance Methods
scan(page:)
click to toggle source
# File lib/browser_crawler/engine_utilities/link_scanner.rb, line 13 def scan(page:) link_inspector.internal_url? ? get_page_links(page: page) : [] end
Private Instance Methods
get_page_links(page:)
click to toggle source
# File lib/browser_crawler/engine_utilities/link_scanner.rb, line 19 def get_page_links(page:) remove_blank_links(link_matcher(page: page)) end
link_matcher(page:)
click to toggle source
return Array consists of links from page if hooks exists when execute them instead of basic behavior
# File lib/browser_crawler/engine_utilities/link_scanner.rb, line 31 def link_matcher(page:) exchange_on_hooks(type: :scan_rules) do page.all('a').map { |a| a['href'] } end end
remove_blank_links(links)
click to toggle source
# File lib/browser_crawler/engine_utilities/link_scanner.rb, line 23 def remove_blank_links(links) links.reject do |link| link.nil? || link.empty? end end