class WebVac::Config

Config object, intended to be used as a singleton.

Constants

ConfigPaths

The sorted list of places where we will look for config files to load.

Defaults

The default config options. See the README.

Public Class Methods

load() click to toggle source

Reads/parses config and instantiates an object

# File lib/webvac.rb, line 40
def self.load
        f = ConfigPaths.find { |f| File.readable?(f) }
        cfg = if f
                JSON.parse File.read(f)
        else
                {}
        end
        new cfg
end
new(cfg) click to toggle source

Takes a config, replaces the defaults with it. Will throw exceptions if you give it a bad config, you should probably just call Config.load.

# File lib/webvac.rb, line 53
def initialize cfg
        Defaults.each { |k,v|
                send("#{k}=", v)
        }
        cfg.each { |k,v|
                send("#{k}=", v)
        }
end

Public Instance Methods

path_fixup(path) click to toggle source
# File lib/webvac.rb, line 62
def path_fixup path
        @_path_rx ||= /^#{Regexp.escape(server_path_strip)}/
        path.sub(@_path_rx, server_path_prepend)
end