Class: HTML::Proofer
- Inherits:
-
Object
- Object
- HTML::Proofer
- Defined in:
- lib/html/proofer.rb,
lib/html/proofer/checks.rb,
lib/html/proofer/version.rb
Defined Under Namespace
Classes: Checks
Constant Summary collapse
- VERSION =
"0.0.7"
Class Method Summary collapse
Instance Method Summary collapse
- #get_checks ⇒ Object
-
#initialize(src, opts = {}) ⇒ Proofer
constructor
A new instance of Proofer.
- #print_issues(klass, issues) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(src, opts = {}) ⇒ Proofer
Returns a new instance of Proofer.
6 7 8 9 10 |
# File 'lib/html/proofer.rb', line 6 def initialize(src, opts={}) @srcDir = src @options = {:ext => ".html"}.merge(opts) @failedTests = [] end |
Class Method Details
.create_nokogiri(path) ⇒ Object
32 33 34 |
# File 'lib/html/proofer.rb', line 32 def self.create_nokogiri(path) Nokogiri::HTML(File.read(path)) end |
Instance Method Details
#get_checks ⇒ Object
36 37 38 |
# File 'lib/html/proofer.rb', line 36 def get_checks HTML::Proofer::Checks::Check.subclasses end |
#print_issues(klass, issues) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/html/proofer.rb', line 40 def print_issues(klass, issues) return if issues.empty? @failedTests.push klass issues.each do |issue| $stderr.puts issue + "\n\n" end end |
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/html/proofer.rb', line 12 def run get_checks.each do |klass| issues = [] puts "Running #{klass.name.split(/:/).pop()} check... \n\n" Find.find(@srcDir) do |path| if File.extname(path) == @options[:ext] html = HTML::Proofer.create_nokogiri(path) check = klass.new(path, html, @options) check.run self.print_issues(klass, check.issues) end end end if !@failedTests.empty? raise "Failing tests for: {@failedTests}" end end |