Sha256: 604ffba880cc93f79e392649c103cc62d6ed6e127d025b074c3cb7b1ae3b7a29

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

require 'colorize'

module Guard
  module Sass
    module Lint
      class AllRunner
        def initialize(linter)
          @linter = linter
          @results = {}
        end

        def run
          $stdout.sync = true

          sass_files.each do |file|
            calculate_result @linter.lint(file)
            print '.'
          end

          display_final_result
        end

        def lint(filename)
          calculate_result
        end

        private

        def sass_files
          @sass_files ||= Dir.glob('*/**/*.scss').sort
        end

        def calculate_result(result_data)
          if !result_data.nil? && !result_data.empty?
            data = result_data.first
            file_path = data['filePath']
            warnings = data['warningCount'].to_i
            errors = data['errorCount'].to_i
            @results[file_path] = { warn: warnings, error: errors }
          end
        end

        def display_final_result
          puts "\n"
          puts ' Error Warn' if @results.present?
          @results.each do |file, counts|
            errors = sprintf('%4d', counts[:error]).red
            warns = sprintf('%4d', counts[:warn]).yellow
            puts "  #{errors} #{warns} - #{file}"
          end

          @results = {}
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
guard-sass-lint-0.1.2 lib/guard/sass/lint/all_runner.rb
guard-sass-lint-0.1.1 lib/guard/sass/lint/all_runner.rb
guard-sass-lint-0.1.0 lib/guard/sass/lint/all_runner.rb