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.
8 9 10 11 12 13 14 15 16 |
# File 'lib/docker/messages.rb', line 8 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.
6 7 8 |
# File 'lib/docker/messages.rb', line 6 def @all_messages end |
#buffer ⇒ Object
Returns the value of attribute buffer.
6 7 8 |
# File 'lib/docker/messages.rb', line 6 def buffer @buffer end |
#stderr_messages ⇒ Object
Returns the value of attribute stderr_messages.
6 7 8 |
# File 'lib/docker/messages.rb', line 6 def @stderr_messages end |
#stdout_messages ⇒ Object
Returns the value of attribute stdout_messages.
6 7 8 |
# File 'lib/docker/messages.rb', line 6 def @stdout_messages end |
Instance Method Details
#add_message(source, message) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/docker/messages.rb', line 18 def (source, ) case source when 1 << when 2 << end << end |
#append(messages) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/docker/messages.rb', line 44 def append() @stdout_messages += . @stderr_messages += . @all_messages += . .clear @all_messages end |
#clear ⇒ Object
53 54 55 56 57 |
# File 'lib/docker/messages.rb', line 53 def clear .clear .clear .clear end |
#decipher_messages(body) ⇒ Object
Method to break apart application/vnd.docker.raw-stream headers
60 61 62 63 64 65 66 67 68 |
# File 'lib/docker/messages.rb', line 60 def (body) raw_text = buffer + body.dup = Docker::Messages.new while !raw_text.empty? .(raw_text) end end |
#get_message(raw_text) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/docker/messages.rb', line 28 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 |