Class: Mystro::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/mystro/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/mystro/config.rb', line 11

def initialize
  f = "#{Mystro.directory}/config.yml"
  d = File.exists?(f) ? YAML.load_file(f) : {}
  c = Hashie::Mash.new(d)

  if c.logging?
    c.logging.each do |level, dest|
      Mystro::Log.add(level.to_sym, dest)
    end
  end

  Mystro::Log.debug "loading plugins from configuration"
  Mystro::Plugin.load(c[:plugins]) if c[:plugins]
  @raw = c
  @data = Hashie::Mash.new(c)
  @data.directory = Mystro.directory
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



9
10
11
# File 'lib/mystro/config.rb', line 9

def data
  @data
end

Class Method Details

.instanceObject



4
5
6
# File 'lib/mystro/config.rb', line 4

def instance
  @instance ||= self.new
end