Class: CFTools::Tunnel::StreamLocation
- Inherits:
-
Object
- Object
- CFTools::Tunnel::StreamLocation
- Defined in:
- lib/tools-cf-plugin/tunnel/stream_location.rb
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path, label) ⇒ StreamLocation
constructor
A new instance of StreamLocation.
- #stream_lines(ssh) ⇒ Object
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
#label ⇒ Object (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 |
#path ⇒ Object (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 |