class AutoConsul::Local::FileSystemState
Constants
- VALID_MODES
Public Class Methods
determine_mode(mode_file)
click to toggle source
# File lib/auto-consul/local.rb, line 41 def self.determine_mode mode_file if File.file? mode_file value = File.open(mode_file, 'r') {|f| f.read } VALID_MODES[value] else nil end end
new(path)
click to toggle source
# File lib/auto-consul/local.rb, line 6 def initialize path unless File.directory? path FileUtils.mkdir_p path end @path = path end
Public Instance Methods
agent?()
click to toggle source
# File lib/auto-consul/local.rb, line 61 def agent? mode == 'agent' end
data_path()
click to toggle source
# File lib/auto-consul/local.rb, line 65 def data_path if not (m = mode).nil? File.join(path, mode) else nil end end
mode()
click to toggle source
# File lib/auto-consul/local.rb, line 50 def mode if @mode.nil? @mode = self.class.determine_mode mode_path end @mode end
mode_path()
click to toggle source
# File lib/auto-consul/local.rb, line 18 def mode_path File.join(path, 'mode') end
path()
click to toggle source
# File lib/auto-consul/local.rb, line 14 def path @path end
server?()
click to toggle source
# File lib/auto-consul/local.rb, line 57 def server? mode == 'server' end
set_agent!()
click to toggle source
# File lib/auto-consul/local.rb, line 26 def set_agent! set_mode 'agent' end
set_mode(mode)
click to toggle source
# File lib/auto-consul/local.rb, line 30 def set_mode mode File.open(mode_path, 'w') do |f| f.write mode end end
set_server!()
click to toggle source
# File lib/auto-consul/local.rb, line 22 def set_server! set_mode 'server' end