Sha256: 7d3722070dc7247e9647e9c2c93de795e268a4f81668050695c78c11fc8e348c

Contents?: true

Size: 822 Bytes

Versions: 9

Compression:

Stored size: 822 Bytes

Contents

require "haml"

module HamlI18nLint
  # Run lint and report the result.
  class Runner
    # @param options [Options] options
    # @return [Runner] new runner to run lint with given options
    def initialize(options)
      @options = options
      @config = ::HamlI18nLint::Config.new(@options)
      @linter = HamlI18nLint.linter.new(@config)
    end

    # Run lint and report the result
    # @return [true, false] all of the files passed lint or not.
    def run
      @config.files.map do |file|
        result = lint(file)

        if result.success?
          true
        else
          @config.report(result)
          false
        end
      end.all?
    end

    private

    def lint(filename)
      template = File.read(filename)
      @linter.lint(filename: filename, template: template)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
haml_i18n_lint-0.12.0 lib/haml_i18n_lint/runner.rb
haml_i18n_lint-0.11.0 lib/haml_i18n_lint/runner.rb
haml_i18n_lint-0.10.0 lib/haml_i18n_lint/runner.rb
haml_i18n_lint-0.9.0 lib/haml_i18n_lint/runner.rb
haml_i18n_lint-0.8.0 lib/haml_i18n_lint/runner.rb
haml_i18n_lint-0.7.0 lib/haml_i18n_lint/runner.rb
haml_i18n_lint-0.6.0 lib/haml_i18n_lint/runner.rb
haml_i18n_lint-0.5.0 lib/haml_i18n_lint/runner.rb
haml_i18n_lint-0.4.0 lib/haml_i18n_lint/runner.rb