Sha256: 2965461a6f76cc7bb95a5ea7cf8349c2c1da8ce1419f4914fc8bb159dd03eeb4

Contents?: true

Size: 992 Bytes

Versions: 2

Compression:

Stored size: 992 Bytes

Contents

# frozen_string_literal: true

module Mutant
  # The outer world IO objects mutant does interact with
  class World
    include Adamantium::Flat, Anima.new(
      :condition_variable,
      :gem,
      :gem_method,
      :io,
      :json,
      :kernel,
      :load_path,
      :marshal,
      :mutex,
      :object_space,
      :open3,
      :pathname,
      :process,
      :stderr,
      :stdout,
      :thread,
      :warnings
    )

    INSPECT = '#<Mutant::World>'

    private_constant(*constants(false))

    # Object inspection
    #
    # @return [String]
    def inspect
      INSPECT
    end

    # Capture stdout of a command
    #
    # @param [Array<String>] command
    #
    # @return [Either<String,String>]
    def capture_stdout(command)
      stdout, status = open3.capture2(*command, binmode: true)

      if status.success?
        Either::Right.new(stdout)
      else
        Either::Left.new("Command #{command} failed!")
      end
    end
  end # World
end # Mutant

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mutant-0.10.6 lib/mutant/world.rb
mutant-0.10.5 lib/mutant/world.rb