Sha256: 78f49af41221ea2414adf989eb3f60ae3ecacdc33f5c63cdf14909de3638d862

Contents?: true

Size: 903 Bytes

Versions: 4

Compression:

Stored size: 903 Bytes

Contents

require 'tempfile'

module Chronicle
  module ETL
    module Loaders
      module Helpers
        module StdoutHelper
          # TODO: let users use "stdout" as an option for the `output` setting
          # Assume we're using stdout if no output is specified
          def output_to_stdout?
            !@config.output
          end

          def create_stdout_temp_file
            file = Tempfile.new('chronicle-stdout')
            file.unlink
            file
          end

          def write_to_stdout_from_temp_file(file)
            file.rewind
            write_to_stdout(file.read)
          end

          def write_to_stdout(output)
            # We .dup because rspec overwrites $stdout (in helper #capture) to
            # capture output.
            stdout = $stdout.dup
            stdout.write(output)
            stdout.flush
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chronicle-etl-0.5.5 lib/chronicle/etl/loaders/helpers/stdout_helper.rb
chronicle-etl-0.5.4 lib/chronicle/etl/loaders/helpers/stdout_helper.rb
chronicle-etl-0.5.3 lib/chronicle/etl/loaders/helpers/stdout_helper.rb
chronicle-etl-0.5.2 lib/chronicle/etl/loaders/helpers/stdout_helper.rb