Class: Pi::Browser::Taskbar::Rails::Broker::Identity

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_root, runtime_root: nil) ⇒ Identity

Returns a new instance of Identity.



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 34

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.message}"
end

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory.



32
33
34
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 32

def directory
  @directory
end

#keyObject (readonly)

Returns the value of attribute key.



32
33
34
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 32

def key
  @key
end

#project_rootObject (readonly)

Returns the value of attribute project_root.



32
33
34
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 32

def project_root
  @project_root
end

#runtime_rootObject (readonly)

Returns the value of attribute runtime_root.



32
33
34
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 32

def runtime_root
  @runtime_root
end

#uidObject (readonly)

Returns the value of attribute uid.



32
33
34
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 32

def uid
  @uid
end

Instance Method Details

#identityObject



46
47
48
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 46

def identity
  "#{uid}:#{project_root}"
end

#lock_pathObject



50
51
52
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 50

def lock_path
  File.join(directory, "broker.lock")
end

#metadata_pathObject



58
59
60
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 58

def 
  File.join(directory, "endpoint.json")
end

#socket_pathObject



54
55
56
# File 'lib/pi/browser/taskbar/rails/broker.rb', line 54

def socket_path
  File.join(directory, "broker.sock")
end