module Dotenv::Substitutions::Variable

Substitute variables in a value.

HOST=example.com
URL="https://$HOST"

Constants

VARIABLE

Public Class Methods

call(value, env) click to toggle source
# File lib/dotenv/substitutions/variable.rb, line 21
def call(value, env)
  value.gsub(VARIABLE) do |variable|
    match = $LAST_MATCH_INFO

    if match[1] == "\\"
      variable[1..]
    elsif match[3]
      env[match[3]] || ENV[match[3]] || ""
    else
      variable
    end
  end
end