Sha256: d62ac54b1a5dc7656e4da1270afa3c370ebdc7fc922e5c1411cf63d0d05c721c

Contents?: true

Size: 784 Bytes

Versions: 10

Compression:

Stored size: 784 Bytes

Contents

module FaceControl
  class CheckerRunner
    def initialize(checker_class, filenames = [], options = {})
      @checker = checker_class.new
      if @checker.respond_to?(:options=)
        @checker.options = options
      end

      @filenames = filenames
    end

    def comments
      return [] if relevant_filenames.empty?

      report = `#{@checker.command(relevant_filenames.join(' '))}`
      return [] if report.strip.empty?

      @checker.parse(report)
    end

    private

    def relevant_filenames
      return @filenames unless @checker.respond_to?(:relevant_globs)

      @relevant_filenames ||= @checker.relevant_globs.map do |glob|
        @filenames.select do |filename|
          File.fnmatch?(glob, filename)
        end
      end.flatten.uniq
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
face_control-1.0.0 lib/face_control/checker_runner.rb
face_control-0.9.1 lib/face_control/checker_runner.rb
face_control-0.8.6 lib/face_control/checker_runner.rb
face_control-0.9.0 lib/face_control/checker_runner.rb
face_control-0.8.5 lib/face_control/checker_runner.rb
face_control-0.8.4 lib/face_control/checker_runner.rb
face_control-0.8.3 lib/face_control/checker_runner.rb
face_control-0.8.2 lib/face_control/checker_runner.rb
face_control-0.8.1 lib/face_control/checker_runner.rb
face_control-0.8.0 lib/face_control/checker_runner.rb