class Pronto::Haml

Public Instance Methods

inspect(patch) click to toggle source
# File lib/pronto/haml.rb, line 15
def inspect(patch)
  lints = runner.run(files: [patch.new_file_full_path.to_s], reporter: reporter).lints
  lints.map do |lint|
    patch.added_lines.select { |line| line.new_lineno == lint.line }
      .map { |line| new_message(lint, line) }
  end
end
new_message(lint, line) click to toggle source
# File lib/pronto/haml.rb, line 23
def new_message(lint, line)
  path = line.patch.delta.new_file[:path]
  Message.new(path, line, lint.severity.name, lint.message, nil, self.class)
end
run() click to toggle source
# File lib/pronto/haml.rb, line 6
def run
  return [] unless @patches

  @patches.select { |patch| patch.additions > 0 }
    .select { |patch| haml_file?(patch.new_file_full_path) }
    .map { |patch| inspect(patch) }
    .flatten.compact
end

Private Instance Methods

haml_file?(path) click to toggle source
# File lib/pronto/haml.rb, line 30
def haml_file?(path)
  File.extname(path) == '.haml'
end
reporter() click to toggle source
# File lib/pronto/haml.rb, line 34
def reporter
  @reporter ||= ::HamlLint::Reporter::DefaultReporter.new(
    ::HamlLint::Logger.new(StringIO.new)
  )
end
runner() click to toggle source
# File lib/pronto/haml.rb, line 40
def runner
  @runner ||= ::HamlLint::Runner.new
end