class Backdat::Config

The configuration object for backdat.

Public Class Methods

from_file(filename, parser="ruby") click to toggle source

Loads a given file and passes it to the appropriate parser.

@raise [ IOError ] Any IO Exceptions that occur.

@param [ String ] filename The filename to read.

# File lib/backdat/config.rb, line 19
def self.from_file(filename, parser="ruby")
  send("from_file_#{parser}".to_sym, filename)
end
from_file_json(filename) click to toggle source

Loads a given json file and merges the current context configuration with the updated hash.

@raise [ IOError ] Any IO Exceptions that occur. @raise [ Yajl::ParseError ] Raises Yajl Parsing error on improper json.

@param [ String ] filename The file to read.

# File lib/backdat/config.rb, line 40
def self.from_file_json(filename)
  self.from_stream_json(IO.read(filename))
end
from_file_ruby(filename) click to toggle source

Loads a given ruby file and runs instance_eval against it in the context of the current object.

@raise [ IOError ] Any IO Exceptions that occur.

@param [ String ] filename The file to read.

# File lib/backdat/config.rb, line 29
def self.from_file_ruby(filename)
  self.instance_eval(IO.read(filename), filename, 1)
end
from_stream_json(input) click to toggle source

Loads a given json input and merges the current context configuration with the updated hash.

@raise [ IOError ] Any IO Exceptions that occur. @raise [ Yajl::ParseError ] Raises Yajl Parsing error on improper json.

@param [ String ] input The json configuration input.

# File lib/backdat/config.rb, line 51
def self.from_stream_json(input)
  parser = Yajl::Parser.new(:symbolize_keys => true)
  configuration.merge!(parser.parse(input))
end
inspect() click to toggle source

Return the configuration itself upon inspection.

# File lib/backdat/config.rb, line 10
def self.inspect
  configuration.inspect
end