Skip to content

Commit

Permalink
Update version parsing method reference
Browse files Browse the repository at this point in the history
  • Loading branch information
jemelyah committed Jan 16, 2024
1 parent d0ca1e5 commit 486105e
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions lib/ferrum/browser/jruby_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,11 @@ def start
begin
process_builder = java.lang.ProcessBuilder.new(*@command.to_a)
# unless user directory is on a Windows UNC path
unless @user_data_dir =~ %r{\A//}
process_builder.directory(java.io.File.new(@user_data_dir))
end
process_builder.directory(java.io.File.new(@user_data_dir)) unless @user_data_dir =~ %r{\A//}
process_builder.redirectErrorStream(true)
output_file = File.expand_path("chrome_output.log", @user_data_dir)
process_builder.redirectOutput(java.lang.ProcessBuilder::Redirect.appendTo(java.io.File.new(output_file)))

# TODO: Handle new process group creation
# process_options[:pgroup] = true unless Ferrum::Utils::Platform.windows?

environment = process_builder.environment
# Clear the environment to avoid setting e.g. RUBYOPT from the initial environment
environment.clear
Expand All @@ -36,19 +31,19 @@ def start
@pid = @process.pid

parse_ws_url(output_file, @process_timeout)
parse_browser_versions
parse_json_version(ws_url)
end
end

private

def parse_ws_url(output_file, timeout)
output = ''
output = ""
start = Utils::ElapsedTime.monotonic_time
max_time = start + timeout
regexp = %r{DevTools listening on (ws://.*)}
while Utils::ElapsedTime.monotonic_time < max_time
File.open(output_file, 'r+') do |file|
File.open(output_file, "r+") do |file|
file.each_line { |line| output += line }
file.rewind
file.truncate(0)
Expand Down

0 comments on commit 486105e

Please sign in to comment.