Class: CFTools::Tunnel::StreamLocation

Inherits:
Object
  • Object
show all
Defined in:
lib/tools-cf-plugin/tunnel/stream_location.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, label) ⇒ StreamLocation

Returns a new instance of StreamLocation.



8
9
10
11
# File 'lib/tools-cf-plugin/tunnel/stream_location.rb', line 8

def initialize(path, label)
  @path = path
  @label = label
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



6
7
8
# File 'lib/tools-cf-plugin/tunnel/stream_location.rb', line 6

def label
  @label
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/tools-cf-plugin/tunnel/stream_location.rb', line 6

def path
  @path
end

Instance Method Details

#stream_lines(ssh) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/tools-cf-plugin/tunnel/stream_location.rb', line 13

def stream_lines(ssh)
  ssh.exec("tail -f /var/vcap/sys/log/#@path") do |ch, stream, chunk|
    if pending = ch[:pending]
      chunk = pending + chunk
      ch[:pending] = nil
    end

    chunk.each_line do |line|
      if line.end_with?("\n")
        yield log_entry(line, stream)
      else
        ch[:pending] = line
      end
    end
  end
end