Class: Pi::Browser::Taskbar::Rails::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/pi/browser/taskbar/rails.rb

Constant Summary collapse

ENVIRONMENT =
{
  enabled: "PI_BROWSER_TASKBAR_ENABLED",
  allowed_hosts: "PI_BROWSER_TASKBAR_ALLOWED_HOSTS",
  executable: "PI_BROWSER_TASKBAR_EXECUTABLE",
  project_root: "PI_BROWSER_TASKBAR_PROJECT_ROOT",
  task_timeout: "PI_BROWSER_TASKBAR_TASK_TIMEOUT"
}.freeze
DEFAULTS =
{
  enabled: true,
  allowed_hosts: [],
  executable: "pi",
  mount_path: "/dev/pi-browser-taskbar",
  task_timeout: 1_800
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#allowed_hostsObject

Returns the value of attribute allowed_hosts.



21
22
23
# File 'lib/pi/browser/taskbar/rails.rb', line 21

def allowed_hosts
  @allowed_hosts
end

#enabledObject

Returns the value of attribute enabled.



21
22
23
# File 'lib/pi/browser/taskbar/rails.rb', line 21

def enabled
  @enabled
end

#executableObject

Returns the value of attribute executable.



21
22
23
# File 'lib/pi/browser/taskbar/rails.rb', line 21

def executable
  @executable
end

#mount_pathObject

Returns the value of attribute mount_path.



21
22
23
# File 'lib/pi/browser/taskbar/rails.rb', line 21

def mount_path
  @mount_path
end

#project_rootObject

Returns the value of attribute project_root.



21
22
23
# File 'lib/pi/browser/taskbar/rails.rb', line 21

def project_root
  @project_root
end

#task_timeoutObject

Returns the value of attribute task_timeout.



21
22
23
# File 'lib/pi/browser/taskbar/rails.rb', line 21

def task_timeout
  @task_timeout
end

Instance Method Details

#finalize!(default_project_root:) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/pi/browser/taskbar/rails.rb', line 39

def finalize!(default_project_root:)
  @enabled = parse_boolean(setting(:enabled, DEFAULTS[:enabled]), :enabled)
  return freeze unless @enabled

  @allowed_hosts = parse_allowed_hosts(setting(:allowed_hosts, DEFAULTS[:allowed_hosts]))
  @executable = non_empty_string(setting(:executable, DEFAULTS[:executable]), :executable)
  @mount_path = parse_mount_path(setting(:mount_path, DEFAULTS[:mount_path]))
  @project_root = canonical_root(setting(:project_root, default_project_root))
  @task_timeout = parse_timeout(setting(:task_timeout, DEFAULTS[:task_timeout]))
  freeze
end