lib/host_config.rb in host_config-0.0.1 vs lib/host_config.rb in host_config-0.0.2

- old
+ new

@@ -1,15 +1,16 @@ require 'ostruct' require 'socket' module HostConfig - VERSION = "0.0.1" + VERSION = "0.0.2" class MissingConfigFile < StandardError; end class << self def init!( opts={} ) + @base_path = opts[:base_path] || Rails.root @logger = opts[:logger] || Rails.logger @hostname = opts[:hostname] || Socket.gethostname.split('.').shift @config = {} @config[:hostname] = opts[:hostname] @logger.debug "Loading host config #{@hostname}" @@ -18,10 +19,10 @@ private def load_config( file ) begin - path = "#{Rails.root}/config/hosts/#{file}.yml" + path = File.join( @base_path, 'config', 'hosts', "#{file}.yml" ) data = File.read(path) YAML.load( data ) rescue Errno::ENOENT raise MissingConfigFile.new( "Missing config file '#{path}', could not setup HostConfig!" ) end