Class: Docker::Messages
- Inherits:
-
Object
- Object
- Docker::Messages
- Defined in:
- lib/docker/messages.rb
Overview
This class represents all the messages either received by chunks from attach
Instance Attribute Summary collapse
-
#all_messages ⇒ Object
Returns the value of attribute all_messages.
-
#buffer ⇒ Object
Returns the value of attribute buffer.
-
#stderr_messages ⇒ Object
Returns the value of attribute stderr_messages.
-
#stdout_messages ⇒ Object
Returns the value of attribute stdout_messages.
Instance Method Summary collapse
- #add_message(source, message) ⇒ Object
- #append(messages) ⇒ Object
- #clear ⇒ Object
-
#decipher_messages(body) ⇒ Object
Method to break apart application/vnd.docker.raw-stream headers.
- #get_message(raw_text) ⇒ Object
-
#initialize(stdout_messages = [], stderr_messages = [], all_messages = [], buffer = "") ⇒ Messages
constructor
A new instance of Messages.
Constructor Details
#initialize(stdout_messages = [], stderr_messages = [], all_messages = [], buffer = "") ⇒ Messages
Returns a new instance of Messages.
6 7 8 9 10 11 12 13 14 |
# File 'lib/docker/messages.rb', line 6 def initialize(=[], =[], =[], buffer="") @stdout_messages = @stderr_messages = @all_messages = @buffer = buffer end |
Instance Attribute Details
#all_messages ⇒ Object
Returns the value of attribute all_messages.
4 5 6 |
# File 'lib/docker/messages.rb', line 4 def @all_messages end |
#buffer ⇒ Object
Returns the value of attribute buffer.
4 5 6 |
# File 'lib/docker/messages.rb', line 4 def buffer @buffer end |
#stderr_messages ⇒ Object
Returns the value of attribute stderr_messages.
4 5 6 |
# File 'lib/docker/messages.rb', line 4 def @stderr_messages end |
#stdout_messages ⇒ Object
Returns the value of attribute stdout_messages.
4 5 6 |
# File 'lib/docker/messages.rb', line 4 def @stdout_messages end |
Instance Method Details
#add_message(source, message) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/docker/messages.rb', line 16 def (source, ) case source when 1 << when 2 << end << end |
#append(messages) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/docker/messages.rb', line 42 def append() @stdout_messages += . @stderr_messages += . @all_messages += . .clear @all_messages end |
#clear ⇒ Object
51 52 53 54 55 |
# File 'lib/docker/messages.rb', line 51 def clear .clear .clear .clear end |
#decipher_messages(body) ⇒ Object
Method to break apart application/vnd.docker.raw-stream headers
58 59 60 61 62 63 64 65 66 |
# File 'lib/docker/messages.rb', line 58 def (body) raw_text = buffer + body.dup = Docker::Messages.new while !raw_text.empty? .(raw_text) end end |
#get_message(raw_text) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/docker/messages.rb', line 26 def (raw_text) header = raw_text.slice!(0,8) if header.length < 8 @buffer = header return end type, length = header.unpack("CxxxN") = raw_text.slice!(0,length) if .length < length @buffer = header + else (type, ) end end |