Class: Dhalang::Puppeteer
- Inherits:
-
Object
- Object
- Dhalang::Puppeteer
- Defined in:
- lib/Dhalang/puppeteer.rb
Overview
Contains common logic for interacting with Puppeteer.
Class Method Summary collapse
-
.visit(page_url, script_path, temp_file_path, temp_file_extension, options) ⇒ Object
Launches a new Node process, executing the (Puppeteer) script under the given script_path.
Class Method Details
.visit(page_url, script_path, temp_file_path, temp_file_extension, options) ⇒ Object
Launches a new Node process, executing the (Puppeteer) script under the given script_path.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/Dhalang/puppeteer.rb', line 63 def self.visit(page_url, script_path, temp_file_path, temp_file_extension, ) configuration = create_configuration(page_url, script_path, temp_file_path, temp_file_extension, ) command = "node #{script_path} #{Shellwords.escape(configuration)}" Open3.popen2e(command) do |_stdin, stdouterr, wait| return nil if wait.value.success? output = stdouterr.read.strip output = nil if output == '' = output || "Exited with status #{wait.value.exitstatus}" raise DhalangError, end end |