Module: Stagehand::Local
- Defined in:
- lib/stagehand/local.rb
Defined Under Namespace
Modules: Binary, ClientPatch, SessionsPatch
Classes: ServerManager
Constant Summary
collapse
- STAGEHAND_REPO =
"browserbase/stagehand"
- DEFAULT_USER_AGENT =
"stagehand-ruby/local"
- DEFAULT_HOST =
"127.0.0.1"
- DEFAULT_READY_TIMEOUT_S =
30.0
- DOWNLOAD_TIMEOUT_S =
600
Class Method Summary
collapse
Class Method Details
.browser_type_from_params(params) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/stagehand/local.rb', line 28
def self.browser_type_from_params(params)
return nil unless params.is_a?(Hash)
browser = params[:browser] || params["browser"]
return nil if browser.nil?
type =
case browser
when Hash
browser[:type] || browser["type"]
else
browser.respond_to?(:type) ? browser.type : nil
end
type&.to_sym
end
|
.download_mutex ⇒ Object
20
21
22
|
# File 'lib/stagehand/local.rb', line 20
def self.download_mutex
@download_mutex
end
|
.ensure_browserbase_credentials!(client:, params:) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/stagehand/local.rb', line 45
def self.ensure_browserbase_credentials!(client:, params:)
return unless local_mode?(client)
browser_type = browser_type_from_params(params)
return if browser_type == :local
missing = []
missing << "browserbase_api_key" if client.browserbase_api_key.to_s.empty?
return if missing.empty?
message =
"Browserbase credentials are required when launching a Browserbase browser: " \
"missing #{missing.join(', ')}."
raise ArgumentError, message
end
|
.local_mode?(client) ⇒ Boolean
24
25
26
|
# File 'lib/stagehand/local.rb', line 24
def self.local_mode?(client)
client.instance_variable_get(:@server_mode).to_s == "local"
end
|
.macos? ⇒ Boolean
65
66
67
|
# File 'lib/stagehand/local.rb', line 65
def self.macos?
RbConfig::CONFIG["host_os"] =~ /darwin/i
end
|
.windows? ⇒ Boolean
61
62
63
|
# File 'lib/stagehand/local.rb', line 61
def self.windows?
RbConfig::CONFIG["host_os"] =~ /mswin|mingw|cygwin/i
end
|