11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/ace/demo/atoms/cast_file_parser.rb', line 11
def parse(path)
raise CastParseError, "Cast file not found: #{path}" unless File.exist?(path)
= nil
events = []
File.foreach(path).with_index(1) do |line, line_number|
stripped = line.strip
next if stripped.empty?
json = JSON.parse(stripped)
if .nil?
= (json, path: path)
else
events << parse_event(json, path: path, line_number: line_number)
end
rescue JSON::ParserError => e
raise CastParseError, "Invalid JSON in #{path}:#{line_number}: #{e.message}"
end
raise CastParseError, "Missing cast header in #{path}" if .nil?
Models::CastRecording.new(header: , events: events)
end
|