Sha256: 3ef50a84c4ffad454c8fb17611f808e87b1d5b44947dabde8a11bcac4315fb89

Contents?: true

Size: 496 Bytes

Versions: 4

Compression:

Stored size: 496 Bytes

Contents

module Dotenv
  # This class inherits from Hash and represents the environemnt into which
  # Dotenv will load key value pairs from a file.
  class Environment < Hash
    attr_reader :filename

    def initialize(filename)
      @filename = filename
      load
    end

    def load
      update Parser.call(read)
    end

    def read
      File.read(@filename)
    end

    def apply
      each { |k, v| ENV[k] ||= v }
    end

    def apply!
      each { |k, v| ENV[k] = v }
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/dotenv-2.0.2/lib/dotenv/environment.rb
dotenv-2.0.2 lib/dotenv/environment.rb
dotenv-2.0.1 lib/dotenv/environment.rb
dotenv-2.0.0 lib/dotenv/environment.rb