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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e94fed7b3cb30e272c5de25511ad9604e2a9663
4
- data.tar.gz: d2ba44ef2943e993d69906089e374ae51013ff4b
3
+ metadata.gz: 1aa472890a7ddb766fee3cbe2753fb10debf3295
4
+ data.tar.gz: 8c3e21ca0c933f9f907603e64449db6e9ddf2906
5
5
  SHA512:
6
- metadata.gz: 9f65536fcc74006b51ca34ecc77b048ea59608a2a055c4961afaa086d92c3fe09cc2056de5b7d2a5546f37ec0d6586bec29d1fd7fd05607aaaae3c777cf60172
7
- data.tar.gz: ca131c1f0a7d06da44a40a7e714ece99821102153c158f130d909d226a86347ce10745d87b62954cdf71657188459fffef8b7410a949a5134b0ee9236ead3ec9
6
+ metadata.gz: fb1619b0ea97493a352a9fe1456aee45ce0558d7fd15140eb9e3c8f3599c795fba5c75e35c8ab224000bca3712beddf6220cd0f705a723bc047a66367943c142
7
+ data.tar.gz: 65a27bd59091f127e0b89b0b2d1328bb5bb52dbe2e88bb3deea039c6cbb4219ba29aa50cffc083a49fa4e67b54a463b456489a1520af12a4801443448def9ea2
data/.travis.yml CHANGED
@@ -3,6 +3,7 @@ rvm:
3
3
  - 1.9
4
4
  - 2.0
5
5
  - 2.1
6
+ - 2.2
6
7
  env:
7
8
  global:
8
9
  - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
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, "octocat_link", self
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.6.7'
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
- class HTML::Proofer
4
-
5
- # Mostly handles issue management and collecting of external URLs.
6
- class CheckRunner
7
-
8
- attr_reader :issues, :src, :path, :options, :external_urls, :href_ignores, :alt_ignores
9
-
10
- def initialize(src, path, html, opts={})
11
- @src = src
12
- @path = path
13
- @html = remove_ignored(html)
14
- @options = opts
15
- @issues = []
16
- @href_ignores = @options[:href_ignore]
17
- @alt_ignores = @options[:alt_ignore]
18
- @external_urls = {}
19
- end
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
- def run
22
- fail NotImplementedError, 'HTML::Proofer::CheckRunner subclasses must implement #run'
23
- end
25
+ def run
26
+ fail NotImplementedError, 'HTML::Proofer::CheckRunner subclasses must implement #run'
27
+ end
24
28
 
25
- def add_issue(desc, line_number = nil, status = -1)
26
- @issues << Issue.new(@path, desc, line_number, status)
27
- end
29
+ def add_issue(desc, line_number = nil, status = -1)
30
+ @issues << Issue.new(@path, desc, line_number, status)
31
+ end
28
32
 
29
- def add_to_external_urls(href)
30
- if @external_urls[href]
31
- @external_urls[href] << @path
32
- else
33
- @external_urls[href] = [@path]
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
- def self.checks
38
- classes = []
41
+ def self.checks
42
+ classes = []
39
43
 
40
- ObjectSpace.each_object(Class) do |c|
41
- next unless c.superclass == self
42
- classes << c
43
- end
44
+ ObjectSpace.each_object(Class) do |c|
45
+ next unless c.superclass == self
46
+ classes << c
47
+ end
44
48
 
45
- classes
46
- end
49
+ classes
50
+ end
47
51
 
48
- private
52
+ private
49
53
 
50
- def remove_ignored(html)
51
- html.css('code, pre').each(&:unlink)
52
- html
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
- next if attribute == 'data-proofer-ignore' # TODO: not quite sure why this doesn't work
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
- CGI.unescape parts.path unless parts.nil?
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 @data_ignore_proofer
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.options[:typhoeus] && @check.options[:typhoeus][:followlocation]
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", l.line)
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
@@ -1,5 +1,6 @@
1
1
  module HTML
2
2
  class Proofer
3
- VERSION = '2.0.0'
3
+ VERSION = '2.1.0'
4
4
  end
5
5
  end
6
+
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
@@ -0,0 +1,8 @@
1
+ <a
2
+ id="electriccars"
3
+ data-columns="3"
4
+ data-index-number="12314"
5
+ data-parent="cars"
6
+ href="https://www.github.com">
7
+ Hullo
8
+ </a>
@@ -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.0.0
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-01-29 00:00:00.000000000 Z
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.6.7
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.6.7
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