Sha256: d3e11e2dc5c3ff591ccda6da14df2f07149e0d035476af52988ee65964f6abf2

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

require 'ceedling/constants'

class Streaminator

  constructor :streaminator_helper, :verbosinator, :loginator, :stream_wrapper

  # for those objects for whom the configurator has already been instantiated,
  # Streaminator is a convenience object for handling verbosity and writing to the std streams

  def stdout_puts(string, verbosity=Verbosity::NORMAL)
    if (@verbosinator.should_output?(verbosity))
      @stream_wrapper.stdout_puts(string)
      @stream_wrapper.stdout_flush
    end
    
    # write to log as though Verbosity::OBNOXIOUS
    @loginator.log( string, @streaminator_helper.extract_name($stdout) )
  end

  def stderr_puts(string, verbosity=Verbosity::NORMAL)
    if (@verbosinator.should_output?(verbosity))
      @stream_wrapper.stderr_puts(string)
      @stream_wrapper.stderr_flush
    end

    # write to log as though Verbosity::OBNOXIOUS
    @loginator.log( string, @streaminator_helper.extract_name($stderr) )
  end

  def stream_puts(stream, string, verbosity=Verbosity::NORMAL)
    if (@verbosinator.should_output?(verbosity))
      stream.puts(string)
      stream.flush
    end

    # write to log as though Verbosity::OBNOXIOUS
    @loginator.log( string, @streaminator_helper.extract_name(stream) )
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ceedling-0.29.1 lib/ceedling/streaminator.rb
ceedling-0.29.0 lib/ceedling/streaminator.rb