Class: Asimov::Utils::JsonlValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/asimov/utils/jsonl_validator.rb

Overview

Validates that a file is a JSONL file. Subclassed by more specific file validators.

Instance Method Summary collapse

Instance Method Details

#validate(io) ⇒ Object

Validate that the IO object (typically a File) is properly formatted. Entry method for this class and its subclasses. Required format will depend on the class.

are to be format checked.

Parameters:

  • io (IO)

    IO object, typically a file, whose contents



18
19
20
21
22
23
# File 'lib/asimov/utils/jsonl_validator.rb', line 18

def validate(io)
  io.each_line.with_index { |line, idx| validate_line(line, idx) }
  true
rescue JSON::ParserError
  raise JsonlFileCannotBeParsedError, "Expected file to have the JSONL format."
end