Class: HTML::Proofer
- Inherits:
-
Object
show all
- Defined in:
- lib/html/proofer.rb,
lib/html/proofer/checks.rb,
lib/html/proofer/version.rb,
lib/html/proofer/checkable.rb
Defined Under Namespace
Classes: Checkable, Checks
Constant Summary
collapse
- VERSION =
"0.1.0"
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(src, opts = {}) ⇒ Proofer
Returns a new instance of Proofer.
8
9
10
11
12
|
# File 'lib/html/proofer.rb', line 8
def initialize(src, opts={})
@srcDir = src
@options = {:ext => ".html"}.merge(opts)
@failedTests = []
end
|
Class Method Details
.create_nokogiri(path) ⇒ Object
48
49
50
51
|
# File 'lib/html/proofer.rb', line 48
def self.create_nokogiri(path)
path << "/index.html" if File.directory? path
Nokogiri::HTML(File.read(path))
end
|
Instance Method Details
#get_checks ⇒ Object
53
54
55
|
# File 'lib/html/proofer.rb', line 53
def get_checks
HTML::Proofer::Checks::Check.subclasses
end
|
#print_issues(klass, issues) ⇒ Object
57
58
59
60
61
62
63
|
# File 'lib/html/proofer.rb', line 57
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
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/html/proofer.rb', line 14
def run
get_checks.each do |klass|
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(@srcDir, path, html, @options)
check.run
check.hydra.run
self.print_issues(klass, check.issues)
end
end
end
if @failedTests.empty?
puts "Tests executed sucesfully.".green
exit 0
else
count = Hash.new(0)
@failedTests.each do |v|
count[v] += 1
end
count.each do |k, v|
$stderr.puts "#{k} failed #{v} times"
end
raise "Tests ran, but found failures!"
end
end
|