Sha256: e6b8131a8891a0152b650e1f7160e75b8e04de88f4291d3e66c9c69762ce057f

Contents?: true

Size: 887 Bytes

Versions: 9

Compression:

Stored size: 887 Bytes

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
    aliases = {}
    return aliases
  end

  private

  def default_configuration
    {
      "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
    end
    return config
  end

  def repository_configuration
    {}
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ppl-1.2.0 lib/ppl/application/configuration.rb
ppl-1.1.0 lib/ppl/application/configuration.rb
ppl-1.0.6 lib/ppl/application/configuration.rb
ppl-1.0.5 lib/ppl/application/configuration.rb
ppl-1.0.4 lib/ppl/application/configuration.rb
ppl-1.0.3 lib/ppl/application/configuration.rb
ppl-1.0.1 lib/ppl/application/configuration.rb
ppl-1.0.0 lib/ppl/application/configuration.rb
ppl-0.9.0 lib/ppl/application/configuration.rb