Module: Browserctl
- Defined in:
- lib/browserctl.rb,
lib/browserctl/client.rb,
lib/browserctl/errors.rb,
lib/browserctl/logger.rb,
lib/browserctl/policy.rb,
lib/browserctl/runner.rb,
lib/browserctl/server.rb,
lib/browserctl/version.rb,
lib/browserctl/workflow.rb,
lib/browserctl/constants.rb,
lib/browserctl/detectors.rb,
lib/browserctl/recording.rb,
lib/browserctl/commands/fill.rb,
lib/browserctl/commands/init.rb,
lib/browserctl/commands/click.rb,
lib/browserctl/commands/pause.rb,
lib/browserctl/commands/watch.rb,
lib/browserctl/commands/record.rb,
lib/browserctl/commands/resume.rb,
lib/browserctl/commands/status.rb,
lib/browserctl/commands/inspect.rb,
lib/browserctl/commands/snapshot.rb,
lib/browserctl/commands/open_page.rb,
lib/browserctl/commands/cli_output.rb,
lib/browserctl/commands/screenshot.rb,
lib/browserctl/server/idle_watcher.rb,
lib/browserctl/server/page_session.rb,
lib/browserctl/server/handlers/hitl.rb,
lib/browserctl/commands/export_cookies.rb,
lib/browserctl/commands/import_cookies.rb,
lib/browserctl/server/handlers/cookies.rb,
lib/browserctl/server/snapshot_builder.rb,
lib/browserctl/server/handlers/devtools.rb,
lib/browserctl/server/command_dispatcher.rb,
lib/browserctl/server/handlers/navigation.rb,
lib/browserctl/server/handlers/observation.rb,
lib/browserctl/server/handlers/daemon_control.rb,
lib/browserctl/server/handlers/page_lifecycle.rb
Defined Under Namespace
Modules: Commands, Detectors, Policy
Classes: Client, CommandDispatcher, DomainNotAllowed, Error, IdleWatcher, KeyNotFound, MultiLogger, PageNotFound, PageProxy, PageSession, ParamDef, PathNotAllowed, Recording, RefNotFound, Runner, SelectorNotFound, Server, SnapshotBuilder, StepDef, StepResult, TimeoutError, WorkflowContext, WorkflowDefinition, WorkflowError
Constant Summary
collapse
- LEVEL_MAP =
{
"debug" => ::Logger::DEBUG,
"info" => ::Logger::INFO,
"warn" => ::Logger::WARN,
"error" => ::Logger::ERROR
}.freeze
- VERSION =
"0.5.0"
- BROWSERCTL_DIR =
File.expand_path("~/.browserctl")
- IDLE_TTL =
30 * 60
- PROTOCOL_VERSION =
Increment when a breaking wire protocol change ships (new field names, removed commands, changed response shapes). Clients read this from ‘ping` to verify compatibility before sending commands.
"1"
- SOCKET_PATH =
Backward-compatible constants
socket_path
- PID_PATH =
pid_path
Class Method Summary
collapse
Class Method Details
.build_logger(level_name, log_path: nil) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/browserctl/logger.rb', line 41
def self.build_logger(level_name, log_path: nil)
level = LEVEL_MAP.fetch(level_name.to_s.downcase, ::Logger::INFO)
formatter = proc { |sev, t, prog, msg| "#{t.strftime('%Y-%m-%dT%H:%M:%S')} #{sev[0]} [#{prog}] #{msg}\n" }
stderr_log = make_logger($stderr, level, formatter)
return stderr_log unless log_path
FileUtils.mkdir_p(File.dirname(log_path), mode: 0o700)
FileUtils.touch(log_path)
File.chmod(0o600, log_path)
file_log = make_logger(log_path, level, formatter)
MultiLogger.new(stderr_log, file_log)
end
|
.log_path(name = nil) ⇒ Object
18
19
20
|
# File 'lib/browserctl/constants.rb', line 18
def self.log_path(name = nil)
File.join(BROWSERCTL_DIR, name ? "#{name}.log" : "browserd.log")
end
|
.logger ⇒ Object
33
34
35
|
# File 'lib/browserctl/logger.rb', line 33
def self.logger
@logger ||= build_logger("info")
end
|
.logger=(instance) ⇒ Object
37
38
39
|
# File 'lib/browserctl/logger.rb', line 37
def self.logger=(instance)
@logger = instance
end
|
.lookup_plugin_command(name) ⇒ Object
18
19
20
|
# File 'lib/browserctl.rb', line 18
def self.lookup_plugin_command(name)
@plugin_commands_mutex.synchronize { @plugin_commands[name.to_s] }
end
|
.lookup_workflow(name) ⇒ Object
204
205
206
|
# File 'lib/browserctl/workflow.rb', line 204
def self.lookup_workflow(name)
@registry_mutex.synchronize { @registry[name.to_s] }
end
|
.pid_path(name = nil) ⇒ Object
14
15
16
|
# File 'lib/browserctl/constants.rb', line 14
def self.pid_path(name = nil)
File.join(BROWSERCTL_DIR, name ? "#{name}.pid" : "browserd.pid")
end
|
.plugin_commands_snapshot ⇒ Object
22
23
24
|
# File 'lib/browserctl.rb', line 22
def self.plugin_commands_snapshot
@plugin_commands_mutex.synchronize { @plugin_commands.dup }
end
|
.register_command(name, &block) ⇒ Object
14
15
16
|
# File 'lib/browserctl.rb', line 14
def self.register_command(name, &block)
@plugin_commands_mutex.synchronize { @plugin_commands[name.to_s] = block }
end
|
.registry_snapshot ⇒ Object
208
209
210
|
# File 'lib/browserctl/workflow.rb', line 208
def self.registry_snapshot
@registry_mutex.synchronize { @registry.dup }
end
|
.socket_path(name = nil) ⇒ Object
10
11
12
|
# File 'lib/browserctl/constants.rb', line 10
def self.socket_path(name = nil)
File.join(BROWSERCTL_DIR, name ? "#{name}.sock" : "browserd.sock")
end
|
.workflow(name) ⇒ Object
198
199
200
201
202
|
# File 'lib/browserctl/workflow.rb', line 198
def self.workflow(name, &)
defn = WorkflowDefinition.new(name.to_s)
defn.instance_exec(&)
@registry_mutex.synchronize { @registry[name.to_s] = defn }
end
|