Class: Rooibos::Message::System::Stream

Inherits:
Data
  • Object
show all
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

Instance Method Summary collapse

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

#contentObject (readonly)

Returns the value of attribute content

Returns:

  • (Object)

    the current value of content



30
31
32
# File 'lib/rooibos/message/system/stream.rb', line 30

def content
  @content
end

#envelopeObject (readonly)

Returns the value of attribute envelope

Returns:

  • (Object)

    the current value of envelope



30
31
32
# File 'lib/rooibos/message/system/stream.rb', line 30

def envelope
  @envelope
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



30
31
32
# File 'lib/rooibos/message/system/stream.rb', line 30

def status
  @status
end

#streamObject (readonly)

Returns the value of attribute stream

Returns:

  • (Object)

    the current value of 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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


44
45
46
# File 'lib/rooibos/message/system/stream.rb', line 44

def stderr?
  stream == :stderr
end

#stdout?Boolean

Returns true for stdout messages.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


34
35
36
# File 'lib/rooibos/message/system/stream.rb', line 34

def system?
  true
end