Class: Ibex::ErrorMessages::Parser
- Inherits:
-
Object
- Object
- Ibex::ErrorMessages::Parser
- Includes:
- ParserV2
- Defined in:
- lib/ibex/error_messages/parser.rb
Overview
Strict line-oriented parser for the ibex-messages v1 and v2 formats.
Constant Summary collapse
- ESCAPES =
{ "\\" => "\\", "n" => "\n", "t" => "\t", "r" => "\r" }.freeze
Instance Method Summary collapse
-
#initialize(source, file:) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(source, file:) ⇒ Parser
Returns a new instance of Parser.
17 18 19 20 21 22 23 |
# File 'lib/ibex/error_messages/parser.rb', line 17 def initialize(source, file:) @file = file text = source.dup.force_encoding(Encoding::UTF_8) fail_at(1, 1, "messages file must be valid UTF-8") unless text.valid_encoding? @lines = text.lines(chomp: true) end |
Instance Method Details
#parse ⇒ Object
26 27 28 29 30 31 |
# File 'lib/ibex/error_messages/parser.rb', line 26 def parse version = validate_header return parse_v2 if version == 2 parse_v1 end |