Sha256: 747bffc13e53c5d618b0e5cebbf0de2c48183ecff1bbfa0f005ea94f4a3e57e3

Contents?: true

Size: 874 Bytes

Versions: 1

Compression:

Stored size: 874 Bytes

Contents

require 'deadly_serious/engine/json_io'

module DeadlySerious
  module Engine

    # @deprecated Simplifying, simplifying, simplifying
    module SimpleJsonProcess

      def run(readers: [], writers: [])
        reader = JsonIo.new(readers.first) unless readers.empty?
        @writer = JsonIo.new(writers.first) unless writers.empty?

        if reader
          reader.each do |packet|
            if packet.is_a? Array
              super(*packet)
            else
              super(packet)
            end
          end
        else
          super()
        end
      rescue Errno::EPIPE
        # Ignore it. We expect that sometimes =)
      end

      # Send a packet to the next process
      def send(*packet)
        raise 'No "writer" defined' unless @writer
        @writer << packet unless packet.empty?
      end

      alias :emit :send
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
deadly_serious-0.12.0 lib/deadly_serious/engine/simple_json_process.rb