Module: Dotenv

### Home Classes Methods

### In Files

- lib/dotenv.rb
- lib/dotenv/cli.rb
- lib/dotenv/environment.rb
- lib/dotenv/parser.rb
- lib/dotenv/substitutions/command.rb
- lib/dotenv/substitutions/variable.rb
- lib/dotenv/version.rb

### Namespace

- MODULE Dotenv::Substitutions
- CLASS Dotenv::CLI
- CLASS Dotenv::Environment
- CLASS Dotenv::FormatError
- CLASS Dotenv::Parser

### Methods

- #ignoring_nonexistent_files
- #instrument
- #load
- #load!
- #overload
- #with

### Class/Module Index

Quicksearch

- Dotenv
- Dotenv::CLI
- Dotenv::Environment
- Dotenv::FormatError
- Dotenv::Parser
- Dotenv::Substitutions
- Dotenv::Substitutions::Command
- Dotenv::Substitutions::Variable

No matching classes.

# Dotenv

The top level Dotenv module. The entrypoint for the application logic.

### Constants

VERSION

### Attributes

instrumenter[RW]

### Public Instance Methods

ignoring_nonexistent_files() click to toggle source

    # File lib/dotenv.rb, line 58
    def ignoring_nonexistent_files
      yield
    rescue Errno::ENOENT
    end

instrument(name, payload = {}, &block) click to toggle source

    # File lib/dotenv.rb, line 50
    def instrument(name, payload = {}, &block)
      if instrumenter
        instrumenter.instrument(name, payload, &block)
      else
        block.call
      end
    end

load(*filenames) click to toggle source

    # File lib/dotenv.rb, line 12
    def load(*filenames)
      with(*filenames) do |f|
        ignoring_nonexistent_files do
          env = Environment.new(f)
          instrument("dotenv.load", :env => env) { env.apply }
        end
      end
    end

load!(*filenames) click to toggle source

same as `load`, but raises Errno::ENOENT if any files don't exist

    # File lib/dotenv.rb, line 22
    def load!(*filenames)
      with(*filenames) do |f|
        env = Environment.new(f)
        instrument("dotenv.load", :env => env) { env.apply }
      end
    end

overload(*filenames) click to toggle source

same as `load`, but will override existing values in `ENV`

    # File lib/dotenv.rb, line 30
    def overload(*filenames)
      with(*filenames) do |f|
        ignoring_nonexistent_files do
          env = Environment.new(f)
          instrument("dotenv.overload", :env => env) { env.apply! }
        end
      end
    end

with(*filenames, &block) click to toggle source

Internal: Helper to expand list of filenames.

Returns a hash of all the loaded environment variables.

    # File lib/dotenv.rb, line 42
    def with(*filenames, &block)
      filenames << ".env" if filenames.empty?

      filenames.reduce({}) do |hash, filename|
        hash.merge! block.call(File.expand_path(filename)) || {}
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.