Module: Dotenv
- Defined in:
- lib/dotenv.rb,
lib/dotenv/railtie.rb,
lib/dotenv/version.rb,
lib/dotenv/environment.rb,
lib/dotenv/format_error.rb,
lib/dotenv/substitutions/command.rb,
lib/dotenv/substitutions/variable.rb
Defined Under Namespace
Modules: Substitutions Classes: Environment, FormatError, Railtie
Constant Summary collapse
- VERSION =
'0.10.0'
Class Method Summary collapse
- .load(*filenames) ⇒ Object
-
.load!(*filenames) ⇒ Object
same as ‘load`, but raises Errno::ENOENT if any files don’t exist.
-
.overload(*filenames) ⇒ Object
same as ‘load`, but will override existing values in `ENV`.
Class Method Details
.load(*filenames) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/dotenv.rb', line 4 def self.load(*filenames) default_if_empty(filenames).inject({}) do |hash, filename| filename = File. filename hash.merge(File.exists?(filename) ? Environment.new(filename).apply : {}) end end |
.load!(*filenames) ⇒ Object
same as ‘load`, but raises Errno::ENOENT if any files don’t exist
20 21 22 23 24 25 26 27 |
# File 'lib/dotenv.rb', line 20 def self.load!(*filenames) load( *default_if_empty(filenames).each do |filename| filename = File. filename raise(Errno::ENOENT.new(filename)) unless File.exists?(filename) end ) end |
.overload(*filenames) ⇒ Object
same as ‘load`, but will override existing values in `ENV`
12 13 14 15 16 17 |
# File 'lib/dotenv.rb', line 12 def self.overload(*filenames) default_if_empty(filenames).inject({}) do |hash, filename| filename = File. filename hash.merge(File.exists?(filename) ? Environment.new(filename).apply! : {}) end end |