Module: Philiprehberger::EnvDiff::Parser
- Defined in:
- lib/philiprehberger/env_diff/parser.rb
Overview
Parses .env file content into a key-value hash.
Class Method Summary collapse
-
.parse(content) ⇒ Hash{String => String}
Parse a string of env file content into a hash.
-
.parse_file(path:) ⇒ Hash{String => String}
Read a file and parse its content.
Class Method Details
.parse(content) ⇒ Hash{String => String}
Parse a string of env file content into a hash.
11 12 13 14 15 16 17 18 |
# File 'lib/philiprehberger/env_diff/parser.rb', line 11 def self.parse(content) result = {} content.each_line do |line| key, value = parse_line(line.strip) result[key] = value if key end result end |
.parse_file(path:) ⇒ Hash{String => String}
Read a file and parse its content.
25 26 27 |
# File 'lib/philiprehberger/env_diff/parser.rb', line 25 def self.parse_file(path:) parse(File.read(path)) end |