Class: Mxrb::Environment::Parser
- Inherits:
-
Object
- Object
- Mxrb::Environment::Parser
- Defined in:
- lib/mxrb/environment.rb
Overview
A deliberately non-shell parser: values are read as data and variable, command, or backtick expansion is never performed.
Instance Method Summary collapse
-
#initialize(path) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(path) ⇒ Parser
Returns a new instance of Parser.
157 158 159 |
# File 'lib/mxrb/environment.rb', line 157 def initialize(path) @path = path end |
Instance Method Details
#parse ⇒ Object
161 162 163 164 165 166 167 |
# File 'lib/mxrb/environment.rb', line 161 def parse File.foreach(@path, encoding: 'bom|utf-8').with_index(1).each_with_object({}) do |(line, number), result| parse_line(line, number, result) end rescue ArgumentError, EncodingError => e raise ParseError.new(@path, 1, e.), cause: e end |