3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/env_lint/dot_env_parser.rb', line 3
def parse(text)
= []
variables = text.lines.each_with_object([]) do |line, result|
if match = line.strip.match(ASSIGNMENT)
optional, name, value = match.captures
value ||= ''
value = value.strip.sub(/\A(['"])(.*)\1\z/, '\2')
result << Variable.new(name, value, !!optional, * "\n")
= []
elsif match = line.strip.match()
<< match.captures.first
elsif line.strip.empty?
= []
else
raise(UnrecognizedDotEnvLine.new(line))
end
end
variables
end
|