Class: Configy::ConfigFile

Inherits:
Object
  • Object
show all
Defined in:
lib/configy/config_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, section) ⇒ ConfigFile

Returns a new instance of ConfigFile.



7
8
9
10
# File 'lib/configy/config_file.rb', line 7

def initialize(path, section)
  @path    = Pathname.new(path)
  @section = section
end

Instance Method Details

#configObject



12
13
14
# File 'lib/configy/config_file.rb', line 12

def config
  ConfigStore.new(load_file).compile(@section)
end

#load_fileObject



16
17
18
19
20
# File 'lib/configy/config_file.rb', line 16

def load_file
  YAML::load( ERB.new(@path.read).result )
rescue Errno::ENOENT
  {}
end

#mtimeObject



22
23
24
25
26
# File 'lib/configy/config_file.rb', line 22

def mtime
  @path.mtime
rescue Errno::ENOENT
  Time.at(0)
end