html-proofer 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +1 -1
- data/html-proofer.gemspec +1 -1
- data/lib/html/proofer/check_runner.rb +46 -42
- data/lib/html/proofer/checkable.rb +4 -6
- data/lib/html/proofer/checks/links.rb +1 -1
- data/lib/html/proofer/url_validator.rb +2 -2
- data/lib/html/proofer/version.rb +2 -1
- data/lib/html/proofer.rb +2 -2
- data/spec/html/proofer/fixtures/links/attributeWithDash.html +8 -0
- data/spec/html/proofer/links_spec.rb +6 -0
- metadata +6 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1aa472890a7ddb766fee3cbe2753fb10debf3295
|
|
4
|
+
data.tar.gz: 8c3e21ca0c933f9f907603e64449db6e9ddf2906
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fb1619b0ea97493a352a9fe1456aee45ce0558d7fd15140eb9e3c8f3599c795fba5c75e35c8ab224000bca3712beddf6220cd0f705a723bc047a66367943c142
|
|
7
|
+
data.tar.gz: 65a27bd59091f127e0b89b0b2d1328bb5bb52dbe2e88bb3deea039c6cbb4219ba29aa50cffc083a49fa4e67b54a463b456489a1520af12a4801443448def9ea2
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
|
@@ -227,7 +227,7 @@ class MailToOctocat < ::HTML::Proofer::CheckRunner
|
|
|
227
227
|
|
|
228
228
|
def run
|
|
229
229
|
@html.css('a').each do |l|
|
|
230
|
-
link = OctocatLinkCheck.new l,
|
|
230
|
+
link = OctocatLinkCheck.new l, self
|
|
231
231
|
|
|
232
232
|
if link.mailto? && link.octocat?
|
|
233
233
|
return add_issue("Don't email the Octocat directly!")
|
data/html-proofer.gemspec
CHANGED
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
|
|
|
19
19
|
gem.add_dependency 'mercenary', '~> 0.3.2'
|
|
20
20
|
gem.add_dependency 'nokogiri', '~> 1.5'
|
|
21
21
|
gem.add_dependency 'colored', '~> 1.2'
|
|
22
|
-
gem.add_dependency 'typhoeus', '~> 0.
|
|
22
|
+
gem.add_dependency 'typhoeus', '~> 0.7'
|
|
23
23
|
gem.add_dependency 'yell', '~> 2.0'
|
|
24
24
|
gem.add_dependency 'parallel', '~> 1.3'
|
|
25
25
|
gem.add_dependency 'addressable', '~> 2.3'
|
|
@@ -1,56 +1,60 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
3
|
+
module HTML
|
|
4
|
+
class Proofer
|
|
5
|
+
# Mostly handles issue management and collecting of external URLs.
|
|
6
|
+
class CheckRunner
|
|
7
|
+
|
|
8
|
+
attr_reader :issues, :src, :path, :options, :typhoeus_opts, :hydra_opts, :parallel_opts, \
|
|
9
|
+
:external_urls, :href_ignores, :alt_ignores
|
|
10
|
+
|
|
11
|
+
def initialize(src, path, html, options, typhoeus_opts, hydra_opts, parallel_opts)
|
|
12
|
+
@src = src
|
|
13
|
+
@path = path
|
|
14
|
+
@html = remove_ignored(html)
|
|
15
|
+
@options = options
|
|
16
|
+
@typhoeus_opts = typhoeus_opts
|
|
17
|
+
@hydra_opts = hydra_opts
|
|
18
|
+
@parallel_opts = parallel_opts
|
|
19
|
+
@issues = []
|
|
20
|
+
@href_ignores = @options[:href_ignore]
|
|
21
|
+
@alt_ignores = @options[:alt_ignore]
|
|
22
|
+
@external_urls = {}
|
|
23
|
+
end
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
def run
|
|
26
|
+
fail NotImplementedError, 'HTML::Proofer::CheckRunner subclasses must implement #run'
|
|
27
|
+
end
|
|
24
28
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
def add_issue(desc, line_number = nil, status = -1)
|
|
30
|
+
@issues << Issue.new(@path, desc, line_number, status)
|
|
31
|
+
end
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
def add_to_external_urls(href)
|
|
34
|
+
if @external_urls[href]
|
|
35
|
+
@external_urls[href] << @path
|
|
36
|
+
else
|
|
37
|
+
@external_urls[href] = [@path]
|
|
38
|
+
end
|
|
34
39
|
end
|
|
35
|
-
end
|
|
36
40
|
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
def self.checks
|
|
42
|
+
classes = []
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
ObjectSpace.each_object(Class) do |c|
|
|
45
|
+
next unless c.superclass == self
|
|
46
|
+
classes << c
|
|
47
|
+
end
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
classes
|
|
50
|
+
end
|
|
47
51
|
|
|
48
|
-
|
|
52
|
+
private
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
def remove_ignored(html)
|
|
55
|
+
html.css('code, pre').each(&:unlink)
|
|
56
|
+
html
|
|
57
|
+
end
|
|
53
58
|
end
|
|
54
|
-
|
|
55
59
|
end
|
|
56
60
|
end
|
|
@@ -10,11 +10,9 @@ module HTML
|
|
|
10
10
|
|
|
11
11
|
def initialize(obj, check)
|
|
12
12
|
obj.attributes.each_pair do |attribute, value|
|
|
13
|
-
|
|
14
|
-
instance_variable_set("@#{attribute}".to_sym, value.value)
|
|
13
|
+
instance_variable_set("@#{attribute.tr('-', '_')}".to_sym, value.value)
|
|
15
14
|
end
|
|
16
15
|
|
|
17
|
-
@data_ignore_proofer = obj['data-proofer-ignore']
|
|
18
16
|
@content = obj.content
|
|
19
17
|
@check = check
|
|
20
18
|
@checked_paths = {}
|
|
@@ -45,7 +43,7 @@ module HTML
|
|
|
45
43
|
end
|
|
46
44
|
|
|
47
45
|
def path
|
|
48
|
-
|
|
46
|
+
Addressable::URI.unencode parts.path unless parts.nil?
|
|
49
47
|
end
|
|
50
48
|
|
|
51
49
|
def hash
|
|
@@ -66,7 +64,7 @@ module HTML
|
|
|
66
64
|
end
|
|
67
65
|
|
|
68
66
|
def ignore?
|
|
69
|
-
return true if @
|
|
67
|
+
return true if @data_proofer_ignore
|
|
70
68
|
|
|
71
69
|
case @type
|
|
72
70
|
when 'FaviconCheckable'
|
|
@@ -140,7 +138,7 @@ module HTML
|
|
|
140
138
|
end
|
|
141
139
|
|
|
142
140
|
def follow_location?
|
|
143
|
-
@check.
|
|
141
|
+
@check.typhoeus_opts && @check.typhoeus_opts[:followlocation]
|
|
144
142
|
end
|
|
145
143
|
|
|
146
144
|
private
|
|
@@ -89,7 +89,7 @@ class LinkCheck < ::HTML::Proofer::CheckRunner
|
|
|
89
89
|
|
|
90
90
|
def external_link_check(link)
|
|
91
91
|
if !link.exists?
|
|
92
|
-
add_issue("trying to find hash of #{link.href}, but #{link.absolute_path} does not exist",
|
|
92
|
+
add_issue("trying to find hash of #{link.href}, but #{link.absolute_path} does not exist", link.line)
|
|
93
93
|
else
|
|
94
94
|
target_html = create_nokogiri link.absolute_path
|
|
95
95
|
unless hash_check target_html, link.hash
|
|
@@ -81,7 +81,7 @@ module HTML
|
|
|
81
81
|
if response_code.between?(200, 299)
|
|
82
82
|
check_hash_in_2xx_response(href, effective_url, response, filenames)
|
|
83
83
|
elsif response.timed_out?
|
|
84
|
-
handle_timeout(filenames, response_code)
|
|
84
|
+
handle_timeout(href, filenames, response_code)
|
|
85
85
|
elsif method == :head
|
|
86
86
|
queue_request(:get, href, filenames)
|
|
87
87
|
else
|
|
@@ -111,7 +111,7 @@ module HTML
|
|
|
111
111
|
add_failed_tests filenames, "External link #{href} failed: #{effective_url} exists, but the hash '#{hash}' does not", response.code
|
|
112
112
|
end
|
|
113
113
|
|
|
114
|
-
def handle_timeout
|
|
114
|
+
def handle_timeout(href, filenames, response_code)
|
|
115
115
|
return if @options[:only_4xx]
|
|
116
116
|
add_failed_tests filenames, "External link #{href} failed: got a time out", response_code
|
|
117
117
|
end
|
data/lib/html/proofer/version.rb
CHANGED
data/lib/html/proofer.rb
CHANGED
|
@@ -21,7 +21,7 @@ module HTML
|
|
|
21
21
|
class Proofer
|
|
22
22
|
include Utils
|
|
23
23
|
|
|
24
|
-
attr_reader :options, :typhoeus_opts, :parallel_opts
|
|
24
|
+
attr_reader :options, :typhoeus_opts, :hydra_opts, :parallel_opts
|
|
25
25
|
|
|
26
26
|
def initialize(src, opts = {})
|
|
27
27
|
@src = src
|
|
@@ -117,7 +117,7 @@ module HTML
|
|
|
117
117
|
|
|
118
118
|
checks.each do |klass|
|
|
119
119
|
logger.log :debug, :yellow, "Checking #{klass.to_s.downcase} on #{path} ..."
|
|
120
|
-
check = Object.const_get(klass).new(@src, path, html, @options)
|
|
120
|
+
check = Object.const_get(klass).new(@src, path, html, @options, @typhoeus_opts, @hydra_opts, @parallel_opts)
|
|
121
121
|
check.run
|
|
122
122
|
result[:external_urls].merge!(check.external_urls)
|
|
123
123
|
result[:failed_tests].concat(check.issues) if check.issues.length > 0
|
|
@@ -349,4 +349,10 @@ describe 'Links test' do
|
|
|
349
349
|
proofer = run_proofer(fixture)
|
|
350
350
|
expect(proofer.failed_tests.first).to match(/post.htm\?id=63009224 failed: 404 No error/)
|
|
351
351
|
end
|
|
352
|
+
|
|
353
|
+
it 'does not complain for files with attributes containing dashes' do
|
|
354
|
+
fixture = "#{FIXTURES_DIR}/links/attributeWithDash.html"
|
|
355
|
+
proofer = run_proofer(fixture)
|
|
356
|
+
expect(proofer.failed_tests).to eq []
|
|
357
|
+
end
|
|
352
358
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: html-proofer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Garen Torikian
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-02-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: mercenary
|
|
@@ -58,14 +58,14 @@ dependencies:
|
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 0.
|
|
61
|
+
version: '0.7'
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: 0.
|
|
68
|
+
version: '0.7'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: yell
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -230,6 +230,7 @@ files:
|
|
|
230
230
|
- spec/html/proofer/fixtures/images/workingDataURIImage.html
|
|
231
231
|
- spec/html/proofer/fixtures/links/_site/folder.html/index.html
|
|
232
232
|
- spec/html/proofer/fixtures/links/anchors_in_pre.html
|
|
233
|
+
- spec/html/proofer/fixtures/links/attributeWithDash.html
|
|
233
234
|
- spec/html/proofer/fixtures/links/blank_mailto_link.html
|
|
234
235
|
- spec/html/proofer/fixtures/links/blank_tel_link.html
|
|
235
236
|
- spec/html/proofer/fixtures/links/brokenHashExternal.html
|
|
@@ -382,6 +383,7 @@ test_files:
|
|
|
382
383
|
- spec/html/proofer/fixtures/images/workingDataURIImage.html
|
|
383
384
|
- spec/html/proofer/fixtures/links/_site/folder.html/index.html
|
|
384
385
|
- spec/html/proofer/fixtures/links/anchors_in_pre.html
|
|
386
|
+
- spec/html/proofer/fixtures/links/attributeWithDash.html
|
|
385
387
|
- spec/html/proofer/fixtures/links/blank_mailto_link.html
|
|
386
388
|
- spec/html/proofer/fixtures/links/blank_tel_link.html
|
|
387
389
|
- spec/html/proofer/fixtures/links/brokenHashExternal.html
|