class Dotenv::Environment

A ‘.env` file that will be read and parsed into a Hash

Attributes

filename[R]
overwrite[R]

Public Class Methods

new(filename, overwrite: false) click to toggle source

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

Calls superclass method
# File lib/dotenv/environment.rb, line 10
def initialize(filename, overwrite: false)
  super()
  @filename = filename
  @overwrite = overwrite
  load
end

Public Instance Methods

load() click to toggle source
# File lib/dotenv/environment.rb, line 17
def load
  update Parser.call(read, overwrite: overwrite)
end
read() click to toggle source
# File lib/dotenv/environment.rb, line 21
def read
  File.open(@filename, "rb:bom|utf-8", &:read)
end