Class: Terminalwire::Client::Entitlement::Policy::Root

Inherits:
Base
  • Object
show all
Defined in:
lib/terminalwire/client/entitlement/policy.rb

Constant Summary collapse

AUTHORITY =
"terminalwire.com".freeze
BINARY_PATH_FILE_MODE =

Ensure the binary stubs are executable. This increases the file mode entitlement so that stubs created in ./bin are executable.

0o755

Instance Attribute Summary

Attributes inherited from Base

#authority, #environment_variables, #paths, #schemes

Instance Method Summary collapse

Methods inherited from Base

#authority_path, #root_path, #serialize, #storage_path, #storage_pattern

Constructor Details

#initializeRoot

Returns a new instance of Root.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/terminalwire/client/entitlement/policy.rb', line 59

def initialize(*, **, &)
  # Make damn sure the authority is set to Terminalwire.
  super(*, authority: AUTHORITY, **, &)

  # Now setup special permitted paths.
  @paths.permit root_path
  @paths.permit root_pattern
  # Permit the dotfiles so terminalwire can install the binary stubs.
  Terminalwire::Shells::All..each do |path|
    @paths.permit path
  end

  # Permit terminalwire to grant execute permissions to the binary stubs.
  @paths.permit binary_pattern, mode: BINARY_PATH_FILE_MODE

  # Used to check if terminalwire is setup in the user's PATH environment variable.
  @environment_variables.permit "PATH"

  # Permit the shell environment variable so we can detect the user's shell.
  @environment_variables.permit "SHELL"
end

Instance Method Details

#binary_pathObject

Path where the terminalwire binary stubs are stored.



88
89
90
# File 'lib/terminalwire/client/entitlement/policy.rb', line 88

def binary_path
  root_path.join("bin").freeze
end

#binary_patternObject

Pattern for the binary path.



93
94
95
# File 'lib/terminalwire/client/entitlement/policy.rb', line 93

def binary_pattern
  binary_path.join("*").freeze
end

#root_patternObject

Grant access to the ‘~/.terminalwire/*/` path so users can install terminalwire apps via `terminalwire install svbtle`, etc.



83
84
85
# File 'lib/terminalwire/client/entitlement/policy.rb', line 83

def root_pattern
  root_path.join("**/*").freeze
end