Class: Opticon::Notifier::IOStream

Inherits:
Object
  • Object
show all
Defined in:
lib/opticon/notifier.rb

Overview

Prints failures to an output stream. By default failures are sent to $stderr, but this can be changed using the :output_stream configuration option.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output_stream = $stderr, options = {}) ⇒ IOStream

Returns a new instance of IOStream.



63
64
65
# File 'lib/opticon/notifier.rb', line 63

def initialize(output_stream = $stderr, options = {})
  @output_stream = output_stream
end

Instance Attribute Details

#output_streamObject

Returns the value of attribute output_stream.



61
62
63
# File 'lib/opticon/notifier.rb', line 61

def output_stream
  @output_stream
end

Instance Method Details

#notify(failures) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/opticon/notifier.rb', line 67

def notify(failures)
  if ARGV.include?("-v")
    puts "Printing #{failures.size} failures to #{output_stream}:"
    failures.each{|f| puts "  #{f.failure_message}"}
  end
  
  failures.each do |f|
    # TODO: make output format configurable
    output_stream.puts "#{Time.now} :: #{f.uri} :: #{f.failure_message}"
  end
end