Class: GemInstaller::OutputListener

Inherits:
Object
  • Object
show all
Defined in:
lib/geminstaller/output_listener.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOutputListener

Returns a new instance of OutputListener.



8
9
10
11
# File 'lib/geminstaller/output_listener.rb', line 8

def initialize
  @messages = []
  @output_filter = nil
end

Instance Attribute Details

#output_filter=(value) ⇒ Object (writeonly)

Sets the attribute output_filter

Parameters:

  • value

    the value to set the attribute output_filter to.



6
7
8
# File 'lib/geminstaller/output_listener.rb', line 6

def output_filter=(value)
  @output_filter = value
end

Instance Method Details

#notify(msg, stream = :stdout) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/geminstaller/output_listener.rb', line 13

def notify(msg, stream = :stdout)
  @messages.push(msg)
  return unless @output_filter
  if stream == :stdout or stream == :stderr
    @output_filter.rubygems_output(stream, msg)
  else
    raise GemInstaller::GemInstallerError.new("Invalid stream specified: #{@stream}")
  end
end

#readObject



23
24
25
# File 'lib/geminstaller/output_listener.rb', line 23

def read
  @messages.dup
end

#read!Object



27
28
29
30
31
# File 'lib/geminstaller/output_listener.rb', line 27

def read!
  messages = @messages.dup
  @messages.clear
  messages
end