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.



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

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory.



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

def directory
  @directory
end

#keyObject (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_rootObject (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_rootObject (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

#uidObject (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

#identityObject



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

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

#lock_pathObject



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

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

#metadata_pathObject



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

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

#socket_pathObject



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

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