Sha256: 701f3e2188bcfef1e040e2f019437cd48c42ad0368aec3d0934a91b81c712a5e
Contents?: true
Size: 854 Bytes
Versions: 3
Compression:
Stored size: 854 Bytes
Contents
require 'dotenv/parser' require 'dotenv/environment' module Dotenv def self.load(*filenames) with(*filenames) { |f| Environment.new(f).apply if File.exist?(f) } end # same as `load`, but raises Errno::ENOENT if any files don't exist def self.load!(*filenames) with(*filenames) { |f| Environment.new(f).apply } end # same as `load`, but will override existing values in `ENV` def self.overload(*filenames) with(*filenames) { |f| Environment.new(f).apply! if File.exist?(f) } end # Internal: Helper to expand list of filenames. # # Returns a hash of all the loaded environment variables. def self.with(*filenames, &block) filenames << '.env' if filenames.empty? {}.tap do |hash| filenames.each do |filename| hash.merge! block.call(File.expand_path(filename)) || {} end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dotenv-1.0.2 | lib/dotenv.rb |
dotenv-1.0.1 | lib/dotenv.rb |
dotenv-1.0.0 | lib/dotenv.rb |