Class: Ocular::Settings

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/ocular/settings.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSettings

Returns a new instance of Settings.



11
12
# File 'lib/ocular/settings.rb', line 11

def initialize()
end

Instance Attribute Details

#settingsObject

Returns the value of attribute settings.



7
8
9
# File 'lib/ocular/settings.rb', line 7

def settings
  @settings
end

Class Method Details

.find_settings_file_from_system(filename) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ocular/settings.rb', line 14

def self.find_settings_file_from_system(filename)
    if ENV['OCULAR_SETTINGS'] != nil
        filename = File.expand_path(ENV['OCULAR_SETTINGS'])
    end

    if !filename or !File.exists?(filename)
        filename = File.expand_path('~/.ocular.yaml')
    end

    if !filename or !File.exists?(filename)
        filename = File.expand_path('/etc/ocular.yaml')
    end

    return filename
end

.get(key) ⇒ Object



35
36
37
# File 'lib/ocular/settings.rb', line 35

def self.get(key)
    return @settings[key]
end

.load_from_file(filename) ⇒ Object



30
31
32
33
# File 'lib/ocular/settings.rb', line 30

def self.load_from_file(filename)
    ::Ocular.logger.debug "Loaded settings from #{filename}"
    @settings = ::Ocular::deep_symbolize(YAML::load_file(filename))
end