Class: CapistranoSentinel::OutputStream

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano_sentinel/classes/output_stream.rb

Overview

class used to hook into the output stream

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(real_stdout, stringio) ⇒ OutputStream


15
16
17
18
# File 'lib/capistrano_sentinel/classes/output_stream.rb', line 15

def initialize(real_stdout, stringio)
  self.real = real_stdout
  self.stringio = stringio
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object


29
30
31
# File 'lib/capistrano_sentinel/classes/output_stream.rb', line 29

def method_missing(name, *args, &block)
  @real.send name, *args, &block
end

Instance Attribute Details

#realObject

Returns the value of attribute real


13
14
15
# File 'lib/capistrano_sentinel/classes/output_stream.rb', line 13

def real
  @real
end

#stringioObject

Returns the value of attribute stringio


13
14
15
# File 'lib/capistrano_sentinel/classes/output_stream.rb', line 13

def stringio
  @stringio
end

Class Method Details

.hook(stringio) ⇒ Object


4
5
6
# File 'lib/capistrano_sentinel/classes/output_stream.rb', line 4

def self.hook(stringio)
  $stdout = new($stdout, stringio)
end

.unhookObject


8
9
10
11
# File 'lib/capistrano_sentinel/classes/output_stream.rb', line 8

def self.unhook
  $stdout.finish if $stdout.is_a? CapistranoSentinel::OutputStream
  $stdout = STDOUT
end

Instance Method Details

#finishObject


26
27
# File 'lib/capistrano_sentinel/classes/output_stream.rb', line 26

def finish
end

#write(*args) ⇒ Object


20
21
22
23
24
# File 'lib/capistrano_sentinel/classes/output_stream.rb', line 20

def write(*args)
  @stringio.write(*args)
  @real.write(*args)
  @real.flush
end