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.3.0"
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(src, opts = {}) ⇒ Proofer
Returns a new instance of Proofer.
7
8
9
10
|
# File 'lib/html/proofer.rb', line 7
def initialize(src, opts={})
@srcDir = src
@options = {:ext => ".html"}.merge(opts)
end
|
Class Method Details
.create_nokogiri(path) ⇒ Object
44
45
46
47
|
# File 'lib/html/proofer.rb', line 44
def self.create_nokogiri(path)
path << "/index.html" if File.directory? path Nokogiri::HTML(File.read(path))
end
|
Instance Method Details
#run ⇒ Object
12
13
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
|
# File 'lib/html/proofer.rb', line 12
def run
total_files = 0
failed_tests = []
puts "Running #{get_checks} checks on #{@srcDir}... \n\n"
Dir.glob("#{@srcDir}/**/*#{@options[:ext]}") do |path|
total_files += 1
html = HTML::Proofer.create_nokogiri(path)
get_checks.each do |klass|
check = klass.new(@srcDir, path, html, @options)
check.run
check.hydra.run
failed_tests.concat(check.issues) if check.issues.length > 0
end
end
puts "Ran on #{total_files} files!"
if failed_tests.empty?
puts "HTML-Proofer finished successfully.".green
exit 0
else
failed_tests.each do |issue|
$stderr.puts issue + "\n\n"
end
raise "HTML-Proofer found #{failed_tests.length} failures!"
end
end
|