Sha256: 23552b8712f9bb4d2ffd615559cec58bd4601ce0323833707890e5cd39cdc553

Contents?: true

Size: 1.35 KB

Versions: 48

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

module Mutant
  class Reporter
    # Reporter that reports in human readable format
    class CLI < self
      include Concord.new(:output, :format)

      # Build reporter
      #
      # @param [IO] output
      #
      # @return [Reporter::CLI]
      def self.build(output)
        new(
          output,
          Format::Progressive.new(output.respond_to?(:tty?) && output.tty?)
        )
      end

      # Report start
      #
      # @param [Env] env
      #
      # @return [self]
      def start(env)
        write(format.start(env))
        self
      end

      # Report progress object
      #
      # @param [Parallel::Status] status
      #
      # @return [self]
      def progress(status)
        write(format.progress(status))
        self
      end

      # Report delay in seconds
      #
      # @return [Float]
      def delay
        format.delay
      end

      # Report warning
      #
      # @param [String] message
      #
      # @return [self]
      def warn(message)
        output.puts(message)
        self
      end

      # Report env
      #
      # @param [Result::Env] env
      #
      # @return [self]
      def report(env)
        Printer::EnvResult.call(output, env)
        self
      end

    private

      def write(frame)
        output.write(frame)
      end

    end # CLI
  end # Reporter
end # Mutant

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
mutant-0.11.18 lib/mutant/reporter/cli.rb
mutant-0.11.17 lib/mutant/reporter/cli.rb
mutant-0.11.16 lib/mutant/reporter/cli.rb
mutant-0.11.15 lib/mutant/reporter/cli.rb
mutant-0.11.14 lib/mutant/reporter/cli.rb
mutant-0.11.13 lib/mutant/reporter/cli.rb
mutant-0.11.12 lib/mutant/reporter/cli.rb
mutant-0.11.11 lib/mutant/reporter/cli.rb
mutant-0.11.10 lib/mutant/reporter/cli.rb
mutant-0.11.9 lib/mutant/reporter/cli.rb
mutant-0.11.8 lib/mutant/reporter/cli.rb
mutant-0.11.7 lib/mutant/reporter/cli.rb
mutant-0.11.6 lib/mutant/reporter/cli.rb
mutant-0.11.5 lib/mutant/reporter/cli.rb
mutant-0.11.4 lib/mutant/reporter/cli.rb
mutant-0.11.3 lib/mutant/reporter/cli.rb
mutant-0.11.2 lib/mutant/reporter/cli.rb
mutant-0.11.1 lib/mutant/reporter/cli.rb
mutant-0.11.0 lib/mutant/reporter/cli.rb
mutant-0.10.35 lib/mutant/reporter/cli.rb