class Outil::OCS::Config

Constants

CONFIG_PATH
INDEX_PATH

Attributes

params[R]

Public Class Methods

home_path() click to toggle source
# File lib/outil/ocs/config.rb, line 8
def self.home_path
  @home_path ||= File.expand_path(
    File.expand_path(ENV['HOME'] || '~'))
end
new(params={}) click to toggle source
# File lib/outil/ocs/config.rb, line 15
def initialize(params={})
  @params = params
  infer = Proc.new do |key, const|
    @params[key] = "#{self.class.home_path}/#{const}"
  end
  infer.call(:index, INDEX_PATH)
  infer.call(:path, CONFIG_PATH)
end

Public Instance Methods

index() click to toggle source
# File lib/outil/ocs/config.rb, line 39
def index
  @index ||= (
    unless options[:index]
      raise StandardError "Could not locate your Outil Index Path"
    end
    Index.new(:path => options[:index])
  )
end
options() click to toggle source
# File lib/outil/ocs/config.rb, line 24
def options
  @options ||= (
    unless File.exists?(@params[:path])
      raise StandardError "Could not locate your Outil Config File"
    end
    indifference = Proc.new do |hash, x|
      hash[x.first] = x.last
      hash[x.first.to_sym] = x.last
      hash
    end
    YAML.load_file(@params[:path])
      .inject(Hash.new, &indifference)
    )
end