Class: Ferrum::Browser::Options::Base
- Inherits:
-
Object
- Object
- Ferrum::Browser::Options::Base
- Includes:
- Singleton
- Defined in:
- lib/ferrum/browser/options/base.rb
Overview
Abstract base for browser-specific default option builders. Subclasses
(e.g. Chrome, Firefox) declare their own
DEFAULT_OPTIONS and PLATFORM_PATH constants and implement
#merge_required/#merge_default to produce the final CLI flags used
by Command.
Class Method Summary collapse
-
.options ⇒ Base
Singleton instance holding the browser's default options.
-
.version ⇒ String?
The installed browser's version string, obtained by running its binary with
--version.
Instance Method Summary collapse
-
#detect_path ⇒ String?
Locates the browser executable on the system.
-
#except(*keys) ⇒ Hash{String => Object}
Default CLI flags excluding the given keys.
-
#merge_default(flags, options) ⇒ Hash{String => Object}
Merges this browser's default CLI flags (see #to_h) into
flags, unlessoptions.ignore_default_browser_optionsis set. -
#merge_required(flags, options, user_data_dir) ⇒ Hash{String => Object}
Merges the CLI flags that are always required to drive the browser over CDP (e.g. remote debugging port, user data dir) into
flags. -
#to_h ⇒ Hash{String => Object}
Default CLI flags for the browser.
Class Method Details
.options ⇒ Base
Singleton instance holding the browser's default options.
24 25 26 |
# File 'lib/ferrum/browser/options/base.rb', line 24 def self. instance end |
.version ⇒ String?
The installed browser's version string, obtained by running its
binary with --version.
33 34 35 36 37 38 |
# File 'lib/ferrum/browser/options/base.rb', line 33 def self.version out, = Open3.capture2(instance.detect_path, "--version") out.strip rescue Errno::ENOENT nil end |
Instance Method Details
#detect_path ⇒ String?
Locates the browser executable on the system.
67 68 69 |
# File 'lib/ferrum/browser/options/base.rb', line 67 def detect_path Binary.find(self.class::PLATFORM_PATH[Utils::Platform.platform_name]) end |
#except(*keys) ⇒ Hash{String => Object}
Default CLI flags excluding the given keys.
57 58 59 |
# File 'lib/ferrum/browser/options/base.rb', line 57 def except(*keys) to_h.except(*keys) end |
#merge_default(flags, options) ⇒ Hash{String => Object}
107 108 109 |
# File 'lib/ferrum/browser/options/base.rb', line 107 def merge_default(flags, ) raise NotImplementedError end |
#merge_required(flags, options, user_data_dir) ⇒ Hash{String => Object}
88 89 90 |
# File 'lib/ferrum/browser/options/base.rb', line 88 def merge_required(flags, , user_data_dir) raise NotImplementedError end |
#to_h ⇒ Hash{String => Object}
Default CLI flags for the browser.
45 46 47 |
# File 'lib/ferrum/browser/options/base.rb', line 45 def to_h self.class::DEFAULT_OPTIONS end |