Sha256: 96dcabdd0f68e84bc4a0a3c435574629ca8fd279b32c0bf1c7686ac25039ff45

Contents?: true

Size: 832 Bytes

Versions: 2

Compression:

Stored size: 832 Bytes

Contents

class Settings
  CONFIGFILE = "repos.ini"
  INDEXFILENAME = "tt-repo.yaml"
  INFOFILENAME = "tt-info.yaml"
  MAGICNUMBER = 999
  SEPARATOR = ":"

  def self.get(key)
    return @env.get(key) if key.instance_of? String

    @params[key] || "NODATA"
  end

  class Environment
    def initialize(reader = nil)
      @env = ENV
    end

    def get(key)
      @env[key]
    end
  end

  def self.init_params
    @params = {}
    home = get("HOME")
    config_dirpath = File.join(home, ".config", "teuton")
    @params[:config_dirpath] = config_dirpath

    filename = CONFIGFILE
    config_filepath = File.join(config_dirpath, filename)
    @params[:config_filepath] = config_filepath

    cache_dirpath = File.join(config_dirpath, "cache")
    @params[:cache_dirpath] = cache_dirpath
  end

  @env = Environment.new
  init_params
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
teuton-get-0.3.1 lib/teuton-get/settings.rb
teuton-get-0.3.0 lib/teuton-get/settings.rb