Class: BrowserCrawler::EngineUtilities::PageInspector
- Inherits:
-
Object
- Object
- BrowserCrawler::EngineUtilities::PageInspector
- Includes:
- HooksOperator, Capybara::DSL
- Defined in:
- lib/browser_crawler/engine_utilities/page_inspector.rb
Instance Attribute Summary collapse
-
#capybara_session ⇒ Object
Returns the value of attribute capybara_session.
-
#link_inspector ⇒ Object
Returns the value of attribute link_inspector.
-
#link_scanner ⇒ Object
Returns the value of attribute link_scanner.
-
#report_store ⇒ Object
Returns the value of attribute report_store.
-
#scan_result ⇒ Object
Returns the value of attribute scan_result.
Instance Method Summary collapse
- #before_page_scan ⇒ Object
-
#initialize(link_inspector:, capybara_session:, report_store:) ⇒ PageInspector
constructor
A new instance of PageInspector.
- #save_to_report(screenshot_operator: nil) ⇒ Object
- #visit_page ⇒ Object
Methods included from HooksOperator
#exchange_on_hooks, #with_hooks_for
Constructor Details
#initialize(link_inspector:, capybara_session:, report_store:) ⇒ PageInspector
Returns a new instance of PageInspector.
17 18 19 20 21 22 23 |
# File 'lib/browser_crawler/engine_utilities/page_inspector.rb', line 17 def initialize(link_inspector:, capybara_session:, report_store:) @link_inspector = link_inspector @capybara_session = @report_store = report_store @scan_result = [] @link_scanner = LinkScanner.new(link_inspector: link_inspector) end |
Instance Attribute Details
#capybara_session ⇒ Object
Returns the value of attribute capybara_session.
11 12 13 |
# File 'lib/browser_crawler/engine_utilities/page_inspector.rb', line 11 def @capybara_session end |
#link_inspector ⇒ Object
Returns the value of attribute link_inspector.
11 12 13 |
# File 'lib/browser_crawler/engine_utilities/page_inspector.rb', line 11 def link_inspector @link_inspector end |
#link_scanner ⇒ Object
Returns the value of attribute link_scanner.
11 12 13 |
# File 'lib/browser_crawler/engine_utilities/page_inspector.rb', line 11 def link_scanner @link_scanner end |
#report_store ⇒ Object
Returns the value of attribute report_store.
11 12 13 |
# File 'lib/browser_crawler/engine_utilities/page_inspector.rb', line 11 def report_store @report_store end |
#scan_result ⇒ Object
Returns the value of attribute scan_result.
11 12 13 |
# File 'lib/browser_crawler/engine_utilities/page_inspector.rb', line 11 def scan_result @scan_result end |
Instance Method Details
#before_page_scan ⇒ Object
48 |
# File 'lib/browser_crawler/engine_utilities/page_inspector.rb', line 48 def before_page_scan; end |
#save_to_report(screenshot_operator: nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/browser_crawler/engine_utilities/page_inspector.rb', line 36 def save_to_report(screenshot_operator: nil) screenshot_path = save_screenshot(screenshot_operator) report_store.record_page_visit( page: link_inspector.full_url, extracted_links: scan_result, screenshot_filename: screenshot_path, external: link_inspector.external_url?, code: .status_code ) end |
#visit_page ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/browser_crawler/engine_utilities/page_inspector.rb', line 25 def visit_page uri = link_inspector.uri Capybara.app_host = "#{uri.scheme}://#{uri.host}:#{uri.port}" visit link_inspector.full_url with_hooks_for(type: :each) do @scan_result = scanning end end |