Class: Mxrb::Environment::Parser

Inherits:
Object
  • Object
show all
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

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

#parseObject



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.message), cause: e
end