Class: Overcommit::Hook::PreCommit::W3cCss

Inherits:
Base
  • Object
show all
Defined in:
lib/overcommit/hook/pre_commit/w3c_css.rb

Overview

Runs ‘w3c_validators` against any modified CSS files.

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods inherited from Base

#applicable_files, #command, #description, #enabled?, #execute, #execute_in_background, #flags, #in_path?, #initialize, #name, #process_hook_return_value, #quiet?, #required?, #required_executable, #run?, #run_and_transform, #skip?

Constructor Details

This class inherits a constructor from Overcommit::Hook::Base

Instance Method Details

#runObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/overcommit/hook/pre_commit/w3c_css.rb', line 4

def run
  begin
    require 'w3c_validators'
  rescue LoadError
    return :fail, 'w3c_validators not installed -- run `gem install w3c_validators`'
  end

  result_messages =
    begin
      collect_messages
    rescue W3CValidators::ValidatorUnavailable => e
      return :fail, e.message
    rescue W3CValidators::ParsingError => e
      return :fail, e.message
    end

  return :pass if result_messages.empty?

  result_messages
end