Class: Pi::Browser::Taskbar::Rails::Broker::Identity
- Inherits:
-
Object
- Object
- Pi::Browser::Taskbar::Rails::Broker::Identity
- Defined in:
- lib/pi/browser/taskbar/rails/broker.rb
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#project_root ⇒ Object
readonly
Returns the value of attribute project_root.
-
#runtime_root ⇒ Object
readonly
Returns the value of attribute runtime_root.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
Instance Method Summary collapse
- #identity ⇒ Object
-
#initialize(project_root, runtime_root: nil) ⇒ Identity
constructor
A new instance of Identity.
- #lock_path ⇒ Object
- #metadata_path ⇒ Object
- #socket_path ⇒ Object
Constructor Details
#initialize(project_root, runtime_root: nil) ⇒ Identity
Returns a new instance of Identity.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 33 def initialize(project_root, runtime_root: nil) @project_root = File.realpath(project_root) @uid = Process.uid @key = Digest::SHA256.hexdigest("#{uid}\0#{@project_root}")[0, 32] @runtime_root = runtime_root || default_runtime_root secure_directory(@runtime_root) @directory = File.join(@runtime_root, key) secure_directory(@directory) rescue SystemCallError => error raise Unavailable, "broker identity is unavailable: #{error.}" end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
31 32 33 |
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 31 def directory @directory end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
31 32 33 |
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 31 def key @key end |
#project_root ⇒ Object (readonly)
Returns the value of attribute project_root.
31 32 33 |
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 31 def project_root @project_root end |
#runtime_root ⇒ Object (readonly)
Returns the value of attribute runtime_root.
31 32 33 |
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 31 def runtime_root @runtime_root end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid.
31 32 33 |
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 31 def uid @uid end |
Instance Method Details
#identity ⇒ Object
45 46 47 |
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 45 def identity "#{uid}:#{project_root}" end |
#lock_path ⇒ Object
49 50 51 |
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 49 def lock_path File.join(directory, "broker.lock") end |
#metadata_path ⇒ Object
57 58 59 |
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 57 def File.join(directory, "endpoint.json") end |
#socket_path ⇒ Object
53 54 55 |
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 53 def socket_path File.join(directory, "broker.sock") end |