parseOne method

  1. @visibleForTesting
Map<String, String> parseOne(
  1. String line, {
  2. Map<String, String> env = const {},
})

Parses a single line into a key-value pair.

Implementation

@visibleForTesting
Map<String, String> parseOne(String line,
    {Map<String, String> env = const {}}) {
  var stripped = strip(line);
  if (!_isValid(stripped)) return {};

  var idx = stripped.indexOf('=');
  var lhs = stripped.substring(0, idx);
  var k = swallow(lhs);
  if (k.isEmpty) return {};

  var rhs = stripped.substring(idx + 1, stripped.length).trim();
  var quotChar = surroundingQuote(rhs);
  var v = unquote(rhs);

  if (quotChar == _singleQuot) {
    return {k: v};
  }

  return {k: interpolate(v, env)};
}