Class: Zt::Conf

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/zt/conf.rb

Overview

Create initial config if it is not present already

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConf

Returns a new instance of Conf.



15
16
17
18
# File 'lib/zt/conf.rb', line 15

def initialize
  raise Errors::ZtConfDiskError unless ensure_config_on_disk
  raise Errors::ZtConfSyntaxError unless read_config
end

Instance Attribute Details

#confObject

Returns the value of attribute conf.



13
14
15
# File 'lib/zt/conf.rb', line 13

def conf
  @conf
end

Instance Method Details

#save!(*sections) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/zt/conf.rb', line 20

def save!(*sections)
  sections = %i[domains networks nodes zt] if sections.empty?
  sections.each do |section|
    File.open(full_path_for_section(section), 'w') do |f|
      YAML.dump(@conf[section], f)
    end
  end
end