Class: Rooibos::Message::System::Stream
- Inherits:
-
Data
- Object
- Data
- Rooibos::Message::System::Stream
- Includes:
- Predicates
- Defined in:
- lib/rooibos/message/system/stream.rb
Overview
Streaming message from a system command.
Streaming commands send incremental output instead of batching. Each line is a separate message, followed by a completion message.
This message includes predicates to distinguish stdout, stderr, and completion events for pattern matching workflows.
Use it to handle Command.system(..., stream: true) output.
Example
case msg
in { type: :system_stream, envelope: :build, stream: :stdout, content: }
model.with(log: model[:log] + content)
in { type: :system_stream, envelope: :build, stream: :complete, status: 0 }
model.with(success: true)
end
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#envelope ⇒ Object
readonly
Returns the value of attribute envelope.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
Instance Method Summary collapse
-
#complete? ⇒ Boolean
Returns
truefor complete messages. -
#deconstruct_keys(_keys) ⇒ Object
Deconstructs for pattern matching.
-
#stderr? ⇒ Boolean
Returns
truefor stderr messages. -
#stdout? ⇒ Boolean
Returns
truefor stdout messages. -
#system? ⇒ Boolean
Returns
truefor system stream messages.
Methods included from Predicates
#==, #method_missing, #respond_to_missing?, #to_sym
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Rooibos::Message::Predicates
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content
30 31 32 |
# File 'lib/rooibos/message/system/stream.rb', line 30 def content @content end |
#envelope ⇒ Object (readonly)
Returns the value of attribute envelope
30 31 32 |
# File 'lib/rooibos/message/system/stream.rb', line 30 def envelope @envelope end |
#status ⇒ Object (readonly)
Returns the value of attribute status
30 31 32 |
# File 'lib/rooibos/message/system/stream.rb', line 30 def status @status end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream
30 31 32 |
# File 'lib/rooibos/message/system/stream.rb', line 30 def stream @stream end |
Instance Method Details
#complete? ⇒ Boolean
Returns true for complete messages.
49 50 51 |
# File 'lib/rooibos/message/system/stream.rb', line 49 def complete? stream == :complete end |
#deconstruct_keys(_keys) ⇒ Object
Deconstructs for pattern matching.
Returns a hash with :type, :envelope, :stream, and either :content (for stdout/stderr) or :status (for complete).
57 58 59 60 61 62 63 |
# File 'lib/rooibos/message/system/stream.rb', line 57 def deconstruct_keys(_keys) if complete? { type: :system_stream, envelope:, stream:, status: } else { type: :system_stream, envelope:, stream:, content: } end end |
#stderr? ⇒ Boolean
Returns true for stderr messages.
44 45 46 |
# File 'lib/rooibos/message/system/stream.rb', line 44 def stderr? stream == :stderr end |
#stdout? ⇒ Boolean
Returns true for stdout messages.
39 40 41 |
# File 'lib/rooibos/message/system/stream.rb', line 39 def stdout? stream == :stdout end |
#system? ⇒ Boolean
Returns true for system stream messages.
34 35 36 |
# File 'lib/rooibos/message/system/stream.rb', line 34 def system? true end |