Sha256: 716e5d16df1dfb17896b5abe61c225c2d789b063befa86986325527b86f634c6

Contents?: true

Size: 1.32 KB

Versions: 8

Compression:

Stored size: 1.32 KB

Contents

class GoogleLintRunner
  
  def initialize(binary, fix_style_binary, dir, filter, config)
    @binary = binary
    @fix_style_binary = fix_style_binary
    @config_file = dir + '/gjslint.yml'
    @dir = dir
    @filter = filter
    @config = config
  end
  
  def name
    return 'Google Lint'
  end
  
  def execute
    @config.reload
    conf = @config.conf

    input_params = ''
    run_fix_style = false

    conf.each do |param, value|

      if param == 'strict'
        input_params += " --#{param}"
        next
      end
      
      if param == 'run-fix-style'
        run_fix_style = true
        next
      end

      if value.kind_of? Array
        
        value.each do |inner_value|
          input_params += " --#{param} \"#{inner_value}\""
        end
        
      elsif value.kind_of? Integer
        input_params += " --#{param} #{value}"
      else
        input_params += " --#{param} \"#{value}\""
      end
    end

    result = ''
    result += `#{@fix_style_binary} #{input_params} . 2>&1` if run_fix_style

    return result + `#{@binary} #{input_params} . 2>&1`
  end
  
  def is_configured?(all_files)
    return all_files.include?(@config_file)
  end
  
  def should_run?(modified_files)
    return !(modified_files.detect { |file| @filter.filter(file) }).nil? || modified_files.include?(@config_file)
  end
  
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
loris-0.5.2 lib/tasks/google_lint/google_lint_runner.rb
loris-0.5.1 lib/tasks/google_lint/google_lint_runner.rb
loris-0.5.0 lib/tasks/google_lint/google_lint_runner.rb
loris-0.4.1 lib/tasks/google_lint/google_lint_runner.rb
loris-0.4.0 lib/tasks/google_lint/google_lint_runner.rb
loris-0.3.2 lib/tasks/google_lint/google_lint_runner.rb
loris-0.3.1 lib/tasks/google_lint/google_lint_runner.rb
loris-0.3.0 lib/tasks/google_lint/google_lint_runner.rb