module ConfDirHelper
ConfDirHelper
- Utility methods for managing configuration
Constants
- CONFIG_DIR
Public Instance Methods
ascend_dir(dir, path = nil, terminate = nil)
click to toggle source
# File lib/core/helpers/conf_dir_helper.rb, line 36 def ascend_dir(dir, path = nil, terminate = nil) dirs = [] Kernel.loop do f_path = "#{dir}/#{path}" dirs.push f_path.gsub "//", "/" result = (dir = File.expand_path("#{dir}/../")) break unless result != terminate && result != "//" end dirs.reverse end
get_conf_paths(path = "")
click to toggle source
# File lib/core/helpers/conf_dir_helper.rb, line 47 def get_conf_paths(path = "") user = user_dir (%W(#{radial_dir}/#{path} #{shared_dir}/#{CONFIG_DIR}/#{path} #{user}/#{CONFIG_DIR}/#{path}) << ascend_dir(working_dir, path, user)) .flatten end
load_config_files(config_files)
click to toggle source
# File lib/core/helpers/conf_dir_helper.rb, line 11 def load_config_files(config_files) config = Confstruct::Configuration.new config_files.each do |config_file| config.configure(YAML.load_file(config_file)) if File.exist?(config_file) end config end
radial_dir()
click to toggle source
# File lib/core/helpers/conf_dir_helper.rb, line 28 def radial_dir File.absolute_path(File.dirname(__FILE__) + "/../../") end
user_dir()
click to toggle source
# File lib/core/helpers/conf_dir_helper.rb, line 24 def user_dir Dir.home end
working_dir()
click to toggle source
# File lib/core/helpers/conf_dir_helper.rb, line 32 def working_dir File.absolute_path(Dir.pwd) end