Class: Dry::System::Settings::FileParser
- Inherits:
-
Object
- Object
- Dry::System::Settings::FileParser
- Defined in:
- lib/dry/system/settings/file_parser.rb
Constant Summary collapse
- LINE =
Regex extracted from dotenv gem github.com/bkeepers/dotenv/blob/master/lib/dotenv/parser.rb#L14
%r( \A \s* (?:export\s+)? # optional export ([\w\.]+) # key (?:\s*=\s*|:\s+?) # separator ( # optional value begin '(?:\'|[^'])*' # single quoted value | # or "(?:\"|[^"])*" # double quoted value | # or [^#\n]+ # unquoted value )? # value end \s* (?:\#.*)? # optional comment \z )x
Instance Method Summary collapse
Instance Method Details
#call(file) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/dry/system/settings/file_parser.rb', line 25 def call(file) File.readlines(file).each_with_object({}) do |line, hash| parse_line(line, hash) end rescue Errno::ENOENT {} end |