Sha256: 401faacc02a3028339b90b14df5fbe76fdb9ed886969910d009bdff694506d3e

Contents?: true

Size: 1.49 KB

Versions: 9

Compression:

Stored size: 1.49 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]
      #
      # :reek:ManualDispatch
      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

      # Write output frame
      #
      # @param [String] frame
      #
      # @return [undefined]
      def write(frame)
        output.write(frame)
      end

    end # CLI
  end # Reporter
end # Mutant

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mutant-0.9.8 lib/mutant/reporter/cli.rb
mutant-0.9.7 lib/mutant/reporter/cli.rb
mutant-0.9.6 lib/mutant/reporter/cli.rb
mutant-0.9.5 lib/mutant/reporter/cli.rb
mutant-0.9.4 lib/mutant/reporter/cli.rb
mutant-0.9.3 lib/mutant/reporter/cli.rb
mutant-0.9.2 lib/mutant/reporter/cli.rb
mutant-0.9.1 lib/mutant/reporter/cli.rb
mutant-0.9.0 lib/mutant/reporter/cli.rb