Sha256: 91f74e99522fea1d0e2159f80f0e4caa3f1d2df00e1b897912e3e1a3e7e53ebe

Contents?: true

Size: 451 Bytes

Versions: 5

Compression:

Stored size: 451 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

$LOAD_PATH << '.'
$LOAD_PATH << File.join(__dir__, '../lib')
$LOAD_PATH << File.join(__dir__, '../ext')

require 'oj'

reader, writer = IO.pipe

thread =
  Thread.new do
    5.times do |id|
      Oj.to_stream(writer, { "id" => id })
      sleep(1)
    end

    writer.close
  end

p = Oj::Parser.new(:usual)
p.load(reader) { |data| puts "#{Time.now} -- ID: #{data["id"]}" }

reader.close
thread.join

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
oj-3.16.9 test/foo.rb
oj-3.16.8 test/foo.rb
oj-3.16.7 test/foo.rb
oj-3.16.6 test/foo.rb
oj-3.16.5 test/foo.rb