support various quoting styles in .env
This commit is contained in:
@@ -213,9 +213,13 @@ private ######################################################################
|
||||
def read_environment(filename)
|
||||
return {} unless File.exists?(filename)
|
||||
|
||||
if line =~ /\A([A-Za-z_0-9]+)=(.*)\z/
|
||||
hash[$1] = $2
|
||||
File.read(filename).split("\n").inject({}) do |hash, line|
|
||||
if line =~ /\A([A-Za-z_0-9]+)=(.*)\z/
|
||||
key, val = [$1, $2]
|
||||
case val
|
||||
when /\A'(.*)'\z/ then hash[key] = $1
|
||||
when /\A"(.*)"\z/ then hash[key] = $1.gsub(/\\(.)/, '\1')
|
||||
else hash[key] = val
|
||||
end
|
||||
end
|
||||
hash
|
||||
|
||||
Reference in New Issue
Block a user