Sha256: 5de1105b540b130bf6e894a1176d57373257e02ebe420511e071447d79f5c362

Contents?: true

Size: 632 Bytes

Versions: 10

Compression:

Stored size: 632 Bytes

Contents

module Dotenv
  # A `.env` file that will be read and parsed into a Hash
  class Environment < Hash
    attr_reader :filename, :overwrite

    # Create a new Environment
    #
    # @param filename [String] the path to the file to read
    # @param overwrite [Boolean] whether the parser should assume existing values will be overwritten
    def initialize(filename, overwrite: false)
      super()
      @filename = filename
      @overwrite = overwrite
      load
    end

    def load
      update Parser.call(read, overwrite: overwrite)
    end

    def read
      File.open(@filename, "rb:bom|utf-8", &:read)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
dotenv-3.1.4 lib/dotenv/environment.rb
dotenv-3.1.3 lib/dotenv/environment.rb
dotenv-3.1.2 lib/dotenv/environment.rb
dotenv-3.1.1 lib/dotenv/environment.rb
dotenv-3.1.0 lib/dotenv/environment.rb
dotenv-3.0.3 lib/dotenv/environment.rb
dotenv-3.0.2 lib/dotenv/environment.rb
dotenv-3.0.1 lib/dotenv/environment.rb
dotenv-3.0.0 lib/dotenv/environment.rb
dotenv-3.0.0.beta lib/dotenv/environment.rb