Sha256: e806db0ece40984f88b84e5d1a583e4ba73e96321fdf4ed6b620a51dbaf7f90a

Contents?: true

Size: 881 Bytes

Versions: 2

Compression:

Stored size: 881 Bytes

Contents

module Phare
  class CheckSuite
    attr_reader :status

    DEFAULT_CHECKS = {
      rubocop: Check::Rubocop,
      scsslint: Check::ScssLint,
      jshint: Check::JSHint,
      jscs: Check::JSCS
    }

    def initialize(options = {})
      @options = options

      @directory = options[:directory]
      @directory << '/' unless @directory.end_with?('/')

      @options[:skip] ||= []
      @options[:only] ||= []
    end

    def checks
      checks = DEFAULT_CHECKS.keys

      if @options[:only].any?
        checks &= @options[:only]
      elsif @options[:skip]
        checks - @options[:skip]
      else
        checks
      end
    end

    def run
      @checks = checks.map do |check|
        check = DEFAULT_CHECKS[check]
        check.new(@directory, @options).tap(&:run).status
      end

      @status = @checks.find { |status| status > 0 } || 0
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
phare-0.7.1 lib/phare/check_suite.rb
phare-0.7 lib/phare/check_suite.rb