Sha256: a5bf3a62750130166c8450bcc5dee6373d17b2d4ab9a985a02002624a994a467

Contents?: true

Size: 501 Bytes

Versions: 3

Compression:

Stored size: 501 Bytes

Contents

module Econfig
  class YAML
    def initialize(path)
      @path = path
    end

    def get(key)
      options[key]
    end

    def init
      require "yaml"
      require "erb"
      if File.exist?(path)
        @options = ::YAML.load(::ERB.new(File.read(path)).result)[Econfig.env]
      else
        @options = {}
      end
    end

  private

    def path
      File.expand_path(@path, Econfig.root)
    end

    def options
      @options or raise Econfig::UninitializedError
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
econfig-1.0.2 lib/econfig/yaml.rb
econfig-1.0.1 lib/econfig/yaml.rb
econfig-1.0.0 lib/econfig/yaml.rb