Sha256: b1090c37ac6990e37420e52e186b0a53cba9c3000d24e2ed9ae6d68073d8dc2f

Contents?: true

Size: 792 Bytes

Versions: 19

Compression:

Stored size: 792 Bytes

Contents

# frozen_string_literal: true

module Overcommit::Hook::PreCommit
  # Runs `tidy` against any modified HTML files.
  #
  # @see http://www.html-tidy.org/
  class HtmlTidy < Base
    MESSAGE_REGEX = /
      ^(?<file>(?:\w:)?[^:]+):\s
      line\s(?<line>\d+)\s
      column\s(?<col>\d+)\s-\s
      (?<type>Error|Warning):\s(?<message>.+)$
    /x

    def run
      # example message:
      #   line 4 column 24 - Warning: <html> proprietary attribute "class"
      applicable_files.collect do |file|
        result = execute(command + [file])
        output = result.stderr.chomp

        extract_messages(
          output.split("\n").collect { |msg| "#{file}: #{msg}" },
          MESSAGE_REGEX,
          lambda { |type| type.downcase.to_sym }
        )
      end.flatten
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
overcommit-0.58.0 lib/overcommit/hook/pre_commit/html_tidy.rb
overcommit-0.57.0 lib/overcommit/hook/pre_commit/html_tidy.rb
overcommit-0.56.0 lib/overcommit/hook/pre_commit/html_tidy.rb
overcommit-0.55.0 lib/overcommit/hook/pre_commit/html_tidy.rb
overcommit-0.54.1 lib/overcommit/hook/pre_commit/html_tidy.rb
overcommit-0.54.0 lib/overcommit/hook/pre_commit/html_tidy.rb
overcommit-jeygeethanmedia-0.53.1.2 lib/overcommit/hook/pre_commit/html_tidy.rb
overcommit-jeygeethanmedia-0.53.1.1 lib/overcommit/hook/pre_commit/html_tidy.rb
overcommit-jeygeethanmedia-0.53.1 lib/overcommit/hook/pre_commit/html_tidy.rb
overcommit-0.53.0 lib/overcommit/hook/pre_commit/html_tidy.rb
overcommit-0.52.1 lib/overcommit/hook/pre_commit/html_tidy.rb
overcommit-0.52.0 lib/overcommit/hook/pre_commit/html_tidy.rb
overcommit-0.51.0 lib/overcommit/hook/pre_commit/html_tidy.rb
overcommit-0.50.0 lib/overcommit/hook/pre_commit/html_tidy.rb
overcommit-0.49.1 lib/overcommit/hook/pre_commit/html_tidy.rb
overcommit-0.49.0 lib/overcommit/hook/pre_commit/html_tidy.rb
overcommit-0.48.1 lib/overcommit/hook/pre_commit/html_tidy.rb
overcommit-0.48.0 lib/overcommit/hook/pre_commit/html_tidy.rb
overcommit-0.47.0 lib/overcommit/hook/pre_commit/html_tidy.rb