Sha256: f44b2a73dd4e4586cdc9cb6a9f217a5786b46542eaa306b0cbcebd4707f0b3d8

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

module Warder
  # responsible for run coffeescript style guide validation
  class CoffeeLintRunner < Runner
    require 'warder/coffee_lint_runner/lint_runner'
    require 'warder/coffee_lint_runner/message_formatter'

    CLI_OPTION = 'g'
    CLI_FULL_OPTION = 'coffee-lint'
    DESCRIPTION = 'Run coffeescript style guide validation'
    COMMAND_NAME = 'coffeelint'
    FAILURE_REGEXP = /(?<issues>(WARN|ERROR))/

    private

    def run_command
      @stdout.puts(exec_msg) unless quiet?
      lint_results.each do |filename, result|
        next if result.empty?
        yield "\n#{filename}\n#{MessageFormatter.new(result).format}"
      end
      @stdout.puts(stats_msg) if stats?
    end

    def lint_results
      lint_results = {}
      @options.files.split(' ').each do |filename|
        next if filename.length == 0
        lint_results.merge!(LintRunner.new(filename).result)
      end
      lint_results
    end

    def number_of_issues(lines)
      lines.split("\n").count do |line|
        self.class::FAILURE_REGEXP.match(line) ? 1 : 0
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
warder-0.3.4 lib/warder/coffee_lint_runner.rb
warder-0.3.2 lib/warder/coffee_lint_runner.rb
warder-0.3.1 lib/warder/coffee_lint_runner.rb