class Dry::System::Settings::FileParser
Constants
- LINE
Regex extracted from dotenv gem github.com/bkeepers/dotenv/blob/master/lib/dotenv/parser.rb#L14
Public Instance Methods
call(file)
click to toggle source
# File lib/dry/system/settings/file_parser.rb, line 27 def call(file) File.readlines(file).each_with_object({}) do |line, hash| parse_line(line, hash) end rescue Errno::ENOENT {} end
Private Instance Methods
parse_line(line, hash)
click to toggle source
# File lib/dry/system/settings/file_parser.rb, line 37 def parse_line(line, hash) if (match = line.match(LINE)) key, value = match.captures hash[key] = parse_value(value || "") end hash end
parse_value(value)
click to toggle source
# File lib/dry/system/settings/file_parser.rb, line 45 def parse_value(value) value.strip.sub(/\A(['"])(.*)\1\z/, '\2') end