Class: Ibex::Runtime::EventJSONLTracer

Inherits:
Object
  • Object
show all
Defined in:
lib/json5/generated_parser.rb

Overview

Emits schema-v1 immutable runtime events as JSON Lines.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parser, output) ⇒ EventJSONLTracer

Returns a new instance of EventJSONLTracer.

RBS:

  • (Parser parser, _EventTraceOutput output) -> void



9456
9457
9458
9459
9460
# File 'lib/json5/generated_parser.rb', line 9456

def initialize(parser, output)
  @parser = parser
  @output = output
  @subscription = parser.observe { |event| output.puts(JSON.generate(event.to_h)) }
end

Instance Attribute Details

#parserObject (readonly)

RBS:

  • interface _EventTraceOutput
      def puts: (String) -> void
    end


9452
9453
9454
# File 'lib/json5/generated_parser.rb', line 9452

def parser
  @parser
end

#subscriptionObject (readonly)

Signature:

  • Observation::Subscription



9453
9454
9455
# File 'lib/json5/generated_parser.rb', line 9453

def subscription
  @subscription
end

Class Method Details

.attach(parser, io:) ⇒ Object

RBS:

  • [P < Parser] (P parser, io: _EventTraceOutput) -> EventJSONLTracer



9468
9469
9470
# File 'lib/json5/generated_parser.rb', line 9468

def self.attach(parser, io:)
  new(parser, io)
end

Instance Method Details

#detachObject

RBS:

  • () -> bool



9463
9464
9465
# File 'lib/json5/generated_parser.rb', line 9463

def detach
  @parser.unobserve(@subscription)
end