# File lib/dotenv/parser.rb, line 36 def call @string.split("\n").inject({}) do |hash, 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 @@substitutions.each do |proc| value = proc.call(value, hash) end hash[key] = value elsif line !~ /\A\s*(?:#.*)?\z/ # not comment or blank line raise FormatError, "Line #{line.inspect} doesn't match format" end hash end end
Generated with the Darkfish Rdoc Generator 2.