Sha256: 1c31f721ad070377b949f6b9275c1b23397a6f7593888a16b16ef49d00080383

Contents?: true

Size: 876 Bytes

Versions: 4

Compression:

Stored size: 876 Bytes

Contents

require 'simplabs/excellent/formatters/base'

module Simplabs

  module Excellent

    module Formatters

      class Text < Base #:nodoc:

        def initialize(stream = $stdout)
          super
          @total_warnings = 0
        end

        def start
          @stream.puts "\n  Excellent result:\n"
        end

        def file(filename)
          @stream.puts "\n  #{filename}\n"
          yield self
        end

        def warning(warning)
          @stream.puts "    * Line #{lpad(warning.line_number.to_s, 3)}: \e[33m#{warning.message}\e[0m"
          @total_warnings += 1
        end

        def end
          @stream.puts "\n  Found #{@total_warnings} warnings.\n\n"
        end

        private

          def lpad(string, length, fill = ' ')
            [fill * ([length - string.length, 0].max), string].join
          end

      end

    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
excellent-2.1.1 lib/simplabs/excellent/formatters/text.rb
excellent-2.1.0 lib/simplabs/excellent/formatters/text.rb
excellent-2.0.1 lib/simplabs/excellent/formatters/text.rb
excellent-2.0.0 lib/simplabs/excellent/formatters/text.rb