Class: RedQuilt::BrowserLauncher
- Inherits:
-
Object
- Object
- RedQuilt::BrowserLauncher
- Defined in:
- lib/red_quilt/browser_launcher.rb
Overview
Opens a local HTML file in the OS default browser when ‘–open` is set. Best-effort: unsupported platforms or spawn failures are logged but never abort the CLI.
Instance Method Summary collapse
-
#initialize(err:) ⇒ BrowserLauncher
constructor
A new instance of BrowserLauncher.
- #launch(path) ⇒ Object
Constructor Details
#initialize(err:) ⇒ BrowserLauncher
Returns a new instance of BrowserLauncher.
10 11 12 |
# File 'lib/red_quilt/browser_launcher.rb', line 10 def initialize(err:) @err = err end |
Instance Method Details
#launch(path) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/red_quilt/browser_launcher.rb', line 14 def launch(path) command = platform_command unless command @err.puts "redquilt: --open is not supported on this platform; skipping." return end pid = Process.spawn(*command, path, in: :close, out: File::NULL, err: File::NULL) Process.detach(pid) rescue StandardError => e @err.puts "redquilt: failed to open browser: #{e.}" end |