Module: Segue::Paths

Defined in:
lib/segue/paths.rb

Overview

Everything segue writes to disk lives under a single directory so that it can run alongside other players without fighting over state.

Class Method Summary collapse

Class Method Details

.historyObject



22
23
24
# File 'lib/segue/paths.rb', line 22

def history
  File.join(home, "history")
end

.homeObject



12
13
14
15
16
# File 'lib/segue/paths.rb', line 12

def home
  File.expand_path(ENV.fetch("SEGUE_HOME", "~/.segue")).tap do |path|
    FileUtils.mkdir_p path
  end
end

.preferencesObject



18
19
20
# File 'lib/segue/paths.rb', line 18

def preferences
  File.join(home, "preferences.yml")
end

.queueObject



26
27
28
# File 'lib/segue/paths.rb', line 26

def queue
  File.join(home, "queue").tap { |path| FileUtils.mkdir_p path }
end

.socket(name) ⇒ Object

Sockets are scoped to the running player so a crashed one can't leave a stale path behind that the next player would try to talk to.



32
33
34
# File 'lib/segue/paths.rb', line 32

def socket(name)
  File.join(Dir.tmpdir, "segue-#{name}-#{Process.pid}.sock")
end