class By2::ConfigLoader
Attributes
search_paths[RW]
Public Class Methods
new()
click to toggle source
# File lib/by2/config_loader.rb, line 5 def initialize @search_paths ||= [app_config, user_config] end
Public Instance Methods
load(config_file, required = false)
click to toggle source
# File lib/by2/config_loader.rb, line 9 def load(config_file, required = false) search_paths.each do |path| file = File.expand_path(File.join(path, config_file)) By2.debug("Searching for #{file} in #{path}") if File.exists?(file) By2.debug("Loaded: #{file}") return YAML.load_file(file) end end By2.debug("Could not load: #{config_file}") required ? raise : nil end
Private Instance Methods
app_config()
click to toggle source
# File lib/by2/config_loader.rb, line 26 def app_config @app_config ||= File.expand_path(File.join(::By2.root, "config")) end
user_config()
click to toggle source
# File lib/by2/config_loader.rb, line 30 def user_config @user_config ||= File.expand_path(File.join(ENV['HOME'], ".by2")) end