Sha256: 9499e0504f213b97b093561b5066b347326cc445fe2f97d72fb844540b545a87

Contents?: true

Size: 775 Bytes

Versions: 3

Compression:

Stored size: 775 Bytes

Contents

require 'pronto'
require 'haml_lint'

module Pronto
  class Haml < Runner
    def initialize
      @runner = ::HamlLint::Runner.new
    end

    def run(patches, _)
      return [] unless patches

      valid_patches = patches.select { |patch| patch.additions > 0 }
      valid_patches.map { |patch| inspect(patch) }.flatten.compact
    end

    def inspect(patch)
      lints = @runner.run(files: [patch.new_file_full_path.to_s]).lints
      lints.map do |lint|
        patch.added_lines.select { |line| line.new_lineno == lint.line }
                         .map { |line| new_message(lint, line) }
      end
    end

    def new_message(lint, line)
      path = line.patch.delta.new_file[:path]
      Message.new(path, line, lint.severity, lint.message)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pronto-haml-0.4.0 lib/pronto/haml.rb
pronto-haml-0.3.3 lib/pronto/haml.rb
pronto-haml-0.3.2 lib/pronto/haml.rb