Sha256: d4fd8e9dce3326d4a832fe9aacc191cece63b4ca861d11f0a899de149067ff3e
Contents?: true
Size: 889 Bytes
Versions: 6
Compression:
Stored size: 889 Bytes
Contents
#!/usr/bin/env ruby # frozen_string_literal: true # encoding=utf-8 class StreamsOut attr_accessor :streams def initialize @streams = [] end def append_stream_line(stream, line) @streams << OpenStruct.new(stream: stream, line: line, timestamp: Time.now) end def stream_lines(stream) @streams.select do |v| v[:stream] == stream end.map(&:line) end def write_execution_output_to_file(filespec) FileUtils.mkdir_p File.dirname(filespec) output = @streams.map do |entry| case entry[:stream] when ExecutionStreams::STD_OUT entry[:line] # "OUT: #{entry[:line]}" when ExecutionStreams::STD_ERR entry[:line] # "ERR: #{entry[:line]}" when ExecutionStreams::STD_IN entry[:line] # " IN: #{entry[:line]}" end end.join("\n") File.write(filespec, output) end end
Version data entries
6 entries across 6 versions & 1 rubygems