Class: Cucumber::Messages::NdjsonToMessageEnumerator

Inherits:
Enumerator
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages/ndjson_to_message_enumerator.rb

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ NdjsonToMessageEnumerator

Returns a new instance of NdjsonToMessageEnumerator.



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages/ndjson_to_message_enumerator.rb', line 6

def initialize(io)
  super() do |yielder|
    io.each_line do |line|
      next if line.strip.empty?
      begin
        m = Envelope.from_json(line)
      rescue => e
        raise "Not JSON: #{line.strip}"
      end
      yielder.yield(m)
    end
  end
end