Class: Phut::Setting

Inherits:
Object
  • Object
show all
Defined in:
lib/phut/setting.rb

Overview

Central configuration repository.

Constant Summary collapse

DEFAULTS =
{
  root: File.expand_path(File.join(File.dirname(__FILE__), '..', '..')),
  pid_dir: Dir.tmpdir,
  log_dir: Dir.tmpdir,
  socket_dir: Dir.tmpdir
}

Instance Method Summary collapse

Constructor Details

#initializeSetting

Returns a new instance of Setting.



14
15
16
# File 'lib/phut/setting.rb', line 14

def initialize
  @options = DEFAULTS.dup
end

Instance Method Details

#log_dirObject



31
32
33
# File 'lib/phut/setting.rb', line 31

def log_dir
  @options.fetch :log_dir
end

#log_dir=(path) ⇒ Object



35
36
37
38
# File 'lib/phut/setting.rb', line 35

def log_dir=(path)
  fail "No such directory: #{path}" unless FileTest.directory?(path)
  @options[:log_dir] = File.expand_path(path)
end

#pid_dirObject



22
23
24
# File 'lib/phut/setting.rb', line 22

def pid_dir
  @options.fetch :pid_dir
end

#pid_dir=(path) ⇒ Object



26
27
28
29
# File 'lib/phut/setting.rb', line 26

def pid_dir=(path)
  fail "No such directory: #{path}" unless FileTest.directory?(path)
  @options[:pid_dir] = File.expand_path(path)
end

#rootObject



18
19
20
# File 'lib/phut/setting.rb', line 18

def root
  @options.fetch :root
end

#socket_dirObject



40
41
42
# File 'lib/phut/setting.rb', line 40

def socket_dir
  @options.fetch :socket_dir
end

#socket_dir=(path) ⇒ Object



44
45
46
47
# File 'lib/phut/setting.rb', line 44

def socket_dir=(path)
  fail "No such directory: #{path}" unless FileTest.directory?(path)
  @options[:socket_dir] = File.expand_path(path)
end