class Tzispa::Env

Public Class Methods

new(env: ENV) click to toggle source
# File lib/tzispa/env.rb, line 8
def initialize(env: ENV)
  @env = env
end

Public Instance Methods

[](key) click to toggle source
# File lib/tzispa/env.rb, line 12
def [](key)
  @env[key]
end
[]=(key, value) click to toggle source
# File lib/tzispa/env.rb, line 16
def []=(key, value)
  @env[key] = value
end
key?(key) click to toggle source
# File lib/tzispa/env.rb, line 20
def key?(key)
  @env.key? key
end
load!(path) click to toggle source
# File lib/tzispa/env.rb, line 24
def load!(path)
  return unless defined?(Dotenv)

  contents = ::File.open(path, 'rb:bom|utf-8', &:read)
  parsed   = Dotenv::Parser.call(contents)

  parsed.each do |k, v|
    next if @env.key?(k)
    @env[k] = v
  end
  nil
end