Sha256: ecee2b416b9928ed57013d5c1c51e795486142239e3d0896e4aff688a235c77a

Contents?: true

Size: 1.69 KB

Versions: 4

Compression:

Stored size: 1.69 KB

Contents

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]
      #
      # @api private
      #
      def self.build(output)
        tty = output.respond_to?(:tty?) && output.tty?
        format =
          if !Mutant.ci? && tty && Tput::INSTANCE.available
            Format::Framed.new(tty:  tty, tput: Tput::INSTANCE)
          else
            Format::Progressive.new(tty: tty)
          end

        new(output, format)
      end

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

      # Report progress object
      #
      # @param [Runner::Collector] collector
      #
      # @return [self]
      #
      # @api private
      #
      def progress(collector)
        write(format.progress(collector))

        self
      end

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

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

    private

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

    end # CLI
  end # Reporter
end # Mutant

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mutant-0.6.7 lib/mutant/reporter/cli.rb
mutant-0.6.6 lib/mutant/reporter/cli.rb
mutant-0.6.5 lib/mutant/reporter/cli.rb
mutant-0.6.4 lib/mutant/reporter/cli.rb