Class: KuberKit::EnvFileReader::EnvFileParser
- Defined in:
- lib/kuber_kit/env_file_reader/env_file_parser.rb
Constant Summary collapse
- LINE =
Parser is based on: github.com/bkeepers/dotenv/blob/master/lib/dotenv/parser.rb
/ (?:^|\A) # beginning of line \s* # leading whitespace (?:export\s+)? # optional export ([\w\.]+) # key (?:\s*=\s*?|:\s+?) # separator ( # optional value begin \s*'(?:\\'|[^'])*' # single quoted value | # or \s*"(?:\\"|[^"])*" # double quoted value | # or [^\#\r\n]+ # unquoted value )? # value end \s* # trailing whitespace (?:\#.*)? # optional comment (?:$|\z) # end of line /x
Instance Method Summary collapse
Instance Method Details
#call(string) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/kuber_kit/env_file_reader/env_file_parser.rb', line 23 def call(string) hash = {} string.gsub(/\r\n?/, "\n").scan(LINE).each do |key, value| hash[key] = parse_value(value || "") end hash end |