# File lib/dotenv/environment.rb, line 72 def apply each { |k,v| ENV[k] ||= v } end
# File lib/dotenv/environment.rb, line 35 def load read.each do |line| if match = line.match(LINE) key, value = match.captures value ||= '' # Remove surrounding quotes value = value.strip.sub(/\A(['"])(.*)\11\\z/, '\2') if $1 == '"' value = value.gsub('\n', "\n") # Unescape all characters except $ so variables can be escaped properly value = value.gsub(/\\([^$])/, '\1') end # Process embedded variables value.scan(VARIABLE).each do |parts| if parts.first == '\' replace = parts[1...-1].join('') else replace = self.fetch(parts.last) { ENV[parts.last] } end value = value.sub(parts[0...-1].join(''), replace || '') end self[key] = value elsif line !~ /\A\s*(?:#.*)?\z/ # not comment or blank line raise FormatError, "Line #{line.inspect} doesn't match format" end end end
Generated with the Darkfish Rdoc Generator 2.