Sha256: 4f1339fe957d131483c6ec113e453d014623adce5691f332e2773b0ba712dade

Contents?: true

Size: 1.19 KB

Versions: 6

Compression:

Stored size: 1.19 KB

Contents

module Mutant
  class Reporter
    class CLI
      class Printer
        # Mutation printer
        class Mutation < self

          # Run mutation printer
          #
          # @return [undefined]
          #
          # @api private
          #
          def run
            status(mutation.identification)
            puts(colorized_diff)
          end

        private

          # Return mutation
          #
          # @return [Mutation]
          #
          # @api private
          #
          def mutation
            object.mutation
          end

          # Return colorized diff
          #
          # @param [Mutation] mutation
          #
          # @return [undefined]
          #
          # @api private
          #
          def colorized_diff
            original, current = mutation.original_source, mutation.source
            differ = Differ.new(original, current)
            diff = color? ? differ.colorized_diff : differ.diff

            if diff.empty?
              raise 'Unable to create a diff, so ast mutant or unparser does something strange!!'
            end

            diff
          end

        end # Mutantion
      end # Printer
    end # CLI
  end # Reporter
end # Mutant

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mutant-0.3.0.beta7 lib/mutant/reporter/cli/printer/mutation.rb
mutant-0.3.0.beta6 lib/mutant/reporter/cli/printer/mutation.rb
mutant-0.3.0.beta5 lib/mutant/reporter/cli/printer/mutation.rb
mutant-0.3.0.beta4 lib/mutant/reporter/cli/printer/mutation.rb
mutant-0.3.0.beta3 lib/mutant/reporter/cli/printer/mutation.rb
mutant-0.3.0.beta2 lib/mutant/reporter/cli/printer/mutation.rb