Sha256: b2dae06963b0a5b83e23cbfa6aedc97ae83b06edb722d9218a78422acd7a6329

Contents?: true

Size: 1.03 KB

Versions: 9

Compression:

Stored size: 1.03 KB

Contents

require 'pastel'

module Chutney
  # pretty formatter
  class RainbowFormatter < Formatter
  
    def initialize
      super
      
      @pastel = Pastel.new
    end
  
    def format      
      files_with_issues.each do |file, linter|
        put_file(file)
        linter.filter { |l| !l[:issues].empty? }.each do |linter_with_issues|
          
          put_linter(linter_with_issues)
          linter_with_issues[:issues].each { |i| put_issue(i) }
        end
      end
      put_summary
    end
    
    def put_file(file)
      puts @pastel.cyan(file.to_s)
    end
    
    def put_linter(linter)
      puts @pastel.red("  #{linter[:linter]}")
    end
    
    def put_issue(issue)    
      puts "    #{@pastel.dim(issue.dig(:location, :line))} #{issue[:message]}"
    end
    
    def put_summary
      print "#{files.count} features inspected, "
      if files_with_issues.count.zero?
        puts @pastel.green('all taste delicious')
      else
        puts @pastel.red("#{files_with_issues.count} taste nasty")
      end
    end
    
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
chutney-2.2.1 lib/chutney/formatter/rainbow_formatter.rb
chutney-2.1.1 lib/chutney/formatter/rainbow_formatter.rb
chutney-2.1.0 lib/chutney/formatter/rainbow_formatter.rb
chutney-2.0.3.1 lib/chutney/formatter/rainbow_formatter.rb
chutney-2.0.3 lib/chutney/formatter/rainbow_formatter.rb
chutney-2.0.2 lib/chutney/formatter/rainbow_formatter.rb
chutney-2.0.1 lib/chutney/formatter/rainbow_formatter.rb
chutney-2.0.0 lib/chutney/formatter/rainbow_formatter.rb
chutney-2.0.0.rc1 lib/chutney/formatter/rainbow_formatter.rb