Class: Mutant::LogCapture Private

Inherits:
Object
  • Object
show all
Includes:
Unparser::AbstractType
Defined in:
lib/mutant/log_capture.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Captured log output from a worker or forked process.

Raw worker log bytes may or may not be valid UTF-8 — they commonly contain terminal control sequences emitted by test frameworks. This class preserves those bytes unaltered for terminal emission while distinguishing UTF-8 text from arbitrary bytes in the codec representation.

Direct Known Subclasses

Binary, String

Defined Under Namespace

Classes: Binary, String

Constant Summary collapse

CODEC =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Transform::Codec.new(dump_transform: dump, load_transform: load)

Class Method Summary collapse

Class Method Details

.from_binary(bytes) ⇒ LogCapture

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Build the appropriate subclass from raw bytes.

Takes ownership of bytes; encoding is mutated in place.

Parameters:

  • bytes (::String)

Returns:



20
21
22
23
24
25
26
# File 'lib/mutant/log_capture.rb', line 20

def self.from_binary(bytes)
  if bytes.force_encoding(Encoding::UTF_8).valid_encoding?
    String.new(content: bytes)
  else
    Binary.new(content: bytes.force_encoding(Encoding::ASCII_8BIT))
  end
end