Sha256: f884d27f5002d64ef0c0dd4869fa9d48204774bec0dcbfa06537fbda369798a1
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
require "inifile" class Ppl::Application::Configuration USER_CONFIG = "~/.pplconfig" REPO_CONFIG = "./.ppl/config" def address_book_path default_config = default_configuration user_config = user_configuration path = default_config["address book"]["path"] if !user_config["address book"].nil? && !user_config["address book"]["path"].nil? path = File.expand_path(user_config["address book"]["path"]) end return path end def aliases user_aliases = user_configuration["alias"] default_aliases = default_configuration["alias"] if user_aliases.nil? default_aliases else user_aliases end end private def default_configuration { "alias" => {}, "address book" => { "path" => Dir.pwd }, } end def user_configuration filename = File.expand_path(USER_CONFIG) config = {} if File.exists?(filename) config = IniFile::load(filename).to_h elsif File.exists?(xdg_path) config = IniFile::load(xdg_path).to_h end return config end def repository_configuration {} end def xdg_path default = "~/.config" custom = ENV["XDG_CONFIG_HOME"] if custom.nil? path = File.expand_path(default) else path = File.expand_path(custom) end File.join(path, "ppl", "config") end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ppl-1.14.1 | lib/ppl/application/configuration.rb |