html-proofer 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59729987eddc86b73a5542fe3def694fb034fa0a
4
- data.tar.gz: 8a80c231b5e22970b8ca08b6d632c71c86f970ad
3
+ metadata.gz: 0d99f984fc2f22c8190888bbef42ddcbc6eb311f
4
+ data.tar.gz: a9a5b78b906cc5602bcdf352c63590bd58bcce07
5
5
  SHA512:
6
- metadata.gz: 97b8b71c017a4b188cb3c4275f9c8f94e0337142d90f0e395460e7335c205bff28d38602049e77eaab0d8e8901c2651eeca907be29c37d4b71c593b9b04e3187
7
- data.tar.gz: e98f82d67408b22c19ac87ebb10c02a4649b95acf38b2867cc343bb7b809fae5d8d44828b9a888498650298333176fdab8c64215d0be95a42fe7aa3c60aa7166
6
+ metadata.gz: 09a1bd824416b1c5331e0fbf20c3fa6b56f71b9ef8e423ffa42efb368b6834d687fe003e2a9d368ccc9f1126cdfbaea542c56c391d99f66e3623404cb0a7050b
7
+ data.tar.gz: cc1c3a8d29756c4149ac2ac11696c176762934ca6117eb46ce0c98e6662e8be1291da2ead0ec46f258b355b233229b4637ad22510ab058ef0d436151fcdd6506
data/.gitignore CHANGED
@@ -12,6 +12,7 @@ test/tmp
12
12
  test/version_tmp
13
13
  tmp
14
14
 
15
+ Gemfile.lock
15
16
  out/
16
17
  sample.rb
17
18
  run_sample.rb
data/lib/html/proofer.rb CHANGED
@@ -77,17 +77,16 @@ module HTML
77
77
  # continue with no op
78
78
  elsif response.timed_out?
79
79
  @failed_tests << "#{filenames.join(' ').blue}: External link #{href} failed: got a time out"
80
- # hey here's a funny bug: sometimes HEAD requests return a 404, even on legitimate pages! The
81
- # bug seems to affect curl; try `curl -I -X HEAD https://help.github.com/changing-author-info`
82
- # so in these cases, try a regular `GET`. if it fails, it fails.
83
- elsif response_code == 404 && method == :head
84
- next_response = Typhoeus.get(href, @options)
85
- response_handler(next_response, filenames)
86
80
  elsif (response_code == 405 || response_code == 420 || response_code == 503) && method == :head
87
81
  # 420s usually come from rate limiting; let's ignore the query and try just the path with a GET
88
82
  uri = URI(href)
89
83
  next_response = Typhoeus.get(uri.scheme + "://" + uri.host + uri.path, @options)
90
84
  response_handler(next_response, filenames)
85
+ # just be lazy; perform an explicit get request. some servers are apparently not configured to
86
+ # intercept HTTP HEAD
87
+ elsif method == :head
88
+ next_response = Typhoeus.get(href, @options)
89
+ response_handler(next_response, filenames)
91
90
  else
92
91
  # Received a non-successful http response.
93
92
  @failed_tests << "#{filenames.join(' ').blue}: External link #{href} failed: #{response_code} #{response.return_message}"
@@ -1,7 +1,7 @@
1
1
  module HTML
2
2
  class Proofer
3
3
  class Checkable
4
- def initialize(obj, check)
4
+ def initialize(obj, type, check)
5
5
  @src = obj['src']
6
6
  @href = obj['href']
7
7
  @alt = obj['alt']
@@ -10,6 +10,7 @@ module HTML
10
10
  @data_ignore_proofer = obj['data-proofer-ignore']
11
11
  @check = check
12
12
  @checked_paths = {}
13
+ @type = type
13
14
 
14
15
  if @href && @check.options[:href_swap]
15
16
  @check.options[:href_swap].each do |link, replace|
@@ -50,12 +51,18 @@ module HTML
50
51
  rescue URI::BadURIError
51
52
  false
52
53
  rescue URI::InvalidURIError
54
+ if @type == "image"
55
+ @ignored = true
56
+ return true if url.match(/^data:image/)
57
+ end
58
+
53
59
  false
54
60
  end
55
61
 
56
62
  def ignore?
63
+ return true if @ignored || @data_ignore_proofer || @check.additional_href_ignores.include?(url)
57
64
  uri = URI.parse url
58
- @data_ignore_proofer || %w( mailto ).include?(uri.scheme) || @check.additional_href_ignores.include?(url)
65
+ %w( mailto ).include?(uri.scheme)
59
66
  rescue URI::BadURIError
60
67
  false
61
68
  rescue URI::InvalidURIError
@@ -25,7 +25,7 @@ end
25
25
  class Images < ::HTML::Proofer::Checks::Check
26
26
  def run
27
27
  @html.css('img').each do |i|
28
- img = Image.new i, self
28
+ img = Image.new i, "image", self
29
29
 
30
30
  # screenshot filenames should return because of terrible names
31
31
  return self.add_issue "image has a terrible filename (#{img.src})" if img.terrible_filename?
@@ -16,7 +16,7 @@ class Links < ::HTML::Proofer::Checks::Check
16
16
 
17
17
  def run
18
18
  @html.css('a').each do |l|
19
- link = Link.new l, self
19
+ link = Link.new l, "link", self
20
20
  return if link.ignore?
21
21
 
22
22
  # is there even a href?
@@ -1,5 +1,5 @@
1
1
  module HTML
2
2
  class Proofer
3
- VERSION = "0.4.1"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
@@ -0,0 +1 @@
1
+ <a href="https://developers.google.com/university">Some link</a>
@@ -0,0 +1,3 @@
1
+ <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA
2
+ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
3
+ 9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />
@@ -58,4 +58,10 @@ describe "Image tests" do
58
58
  output = capture_stderr { HTML::Proofer.new(relativeImages).run }
59
59
  output.should == ""
60
60
  end
61
+
62
+ it 'properly checks data URI images' do
63
+ dataURIImage = "#{FIXTURES_DIR}/workingDataURIImage.html"
64
+ output = capture_stderr { HTML::Proofer.new(dataURIImage).run }
65
+ output.should == ""
66
+ end
61
67
  end
@@ -68,6 +68,12 @@ describe "Links tests" do
68
68
  output.should == ""
69
69
  end
70
70
 
71
+ it 'properly checks ssl links' do
72
+ checkSSLLinks = "#{FIXTURES_DIR}/checkSSLLinks.html"
73
+ output = capture_stderr { HTML::Proofer.new(checkSSLLinks).run }
74
+ output.should == ""
75
+ end
76
+
71
77
  it 'ignores links marked as ignore data-proofer-ignore' do
72
78
  ignorableLinks = "#{FIXTURES_DIR}/ignorableLinks.html"
73
79
  output = capture_stderr { HTML::Proofer.new(ignorableLinks).run }
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: 0.4.1
4
+ version: 0.5.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: 2013-12-31 00:00:00.000000000 Z
11
+ date: 2014-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mercenary
@@ -118,7 +118,6 @@ files:
118
118
  - .gitignore
119
119
  - .travis.yml
120
120
  - Gemfile
121
- - Gemfile.lock
122
121
  - LICENSE.txt
123
122
  - README.md
124
123
  - Rakefile
@@ -138,6 +137,7 @@ files:
138
137
  - spec/html/proofer/fixtures/brokenLinkExternal.html
139
138
  - spec/html/proofer/fixtures/brokenLinkInternal.html
140
139
  - spec/html/proofer/fixtures/brokenLinkWithNumber.html
140
+ - spec/html/proofer/fixtures/checkSSLLinks.html
141
141
  - spec/html/proofer/fixtures/existingImageExternal.html
142
142
  - spec/html/proofer/fixtures/folder/anchorLink.html
143
143
  - spec/html/proofer/fixtures/folder/assets/barrel.png
@@ -166,6 +166,7 @@ files:
166
166
  - spec/html/proofer/fixtures/rootLink.html
167
167
  - spec/html/proofer/fixtures/rootRelativeImages.html
168
168
  - spec/html/proofer/fixtures/terribleImageName.html
169
+ - spec/html/proofer/fixtures/workingDataURIImage.html
169
170
  - spec/html/proofer/images_spec.rb
170
171
  - spec/html/proofer/links_spec.rb
171
172
  - spec/html/proofer/version_spec.rb
@@ -204,6 +205,7 @@ test_files:
204
205
  - spec/html/proofer/fixtures/brokenLinkExternal.html
205
206
  - spec/html/proofer/fixtures/brokenLinkInternal.html
206
207
  - spec/html/proofer/fixtures/brokenLinkWithNumber.html
208
+ - spec/html/proofer/fixtures/checkSSLLinks.html
207
209
  - spec/html/proofer/fixtures/existingImageExternal.html
208
210
  - spec/html/proofer/fixtures/folder/anchorLink.html
209
211
  - spec/html/proofer/fixtures/folder/assets/barrel.png
@@ -232,6 +234,7 @@ test_files:
232
234
  - spec/html/proofer/fixtures/rootLink.html
233
235
  - spec/html/proofer/fixtures/rootRelativeImages.html
234
236
  - spec/html/proofer/fixtures/terribleImageName.html
237
+ - spec/html/proofer/fixtures/workingDataURIImage.html
235
238
  - spec/html/proofer/images_spec.rb
236
239
  - spec/html/proofer/links_spec.rb
237
240
  - spec/html/proofer/version_spec.rb
data/Gemfile.lock DELETED
@@ -1,70 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- html-proofer (0.3.0)
5
- colored (~> 1.2)
6
- mercenary (~> 0.2.0)
7
- nokogiri (~> 1.6.0)
8
- typhoeus (~> 0.6.7)
9
-
10
- GEM
11
- remote: http://rubygems.org/
12
- specs:
13
- activesupport (4.0.0)
14
- i18n (~> 0.6, >= 0.6.4)
15
- minitest (~> 4.2)
16
- multi_json (~> 1.3)
17
- thread_safe (~> 0.1)
18
- tzinfo (~> 0.3.37)
19
- atomic (1.1.14)
20
- colored (1.2)
21
- diff-lcs (1.2.4)
22
- escape_utils (0.3.2)
23
- ethon (0.6.2)
24
- ffi (>= 1.3.0)
25
- mime-types (~> 1.18)
26
- ffi (1.9.3)
27
- gemoji (1.4.0)
28
- github-markdown (0.5.5)
29
- html-pipeline (0.0.14)
30
- activesupport (>= 2)
31
- escape_utils (~> 0.3)
32
- gemoji (~> 1.0)
33
- github-markdown (~> 0.5)
34
- nokogiri (~> 1.4)
35
- rinku (~> 1.7)
36
- sanitize (~> 2.0)
37
- i18n (0.6.5)
38
- mercenary (0.2.0)
39
- mime-types (1.25.1)
40
- mini_portile (0.5.1)
41
- minitest (4.7.5)
42
- multi_json (1.8.1)
43
- nokogiri (1.6.0)
44
- mini_portile (~> 0.5.0)
45
- rake (10.1.0)
46
- rinku (1.7.3)
47
- rspec (2.13.0)
48
- rspec-core (~> 2.13.0)
49
- rspec-expectations (~> 2.13.0)
50
- rspec-mocks (~> 2.13.0)
51
- rspec-core (2.13.1)
52
- rspec-expectations (2.13.0)
53
- diff-lcs (>= 1.1.3, < 2.0)
54
- rspec-mocks (2.13.1)
55
- sanitize (2.0.6)
56
- nokogiri (>= 1.4.4)
57
- thread_safe (0.1.3)
58
- atomic
59
- typhoeus (0.6.7)
60
- ethon (~> 0.6.2)
61
- tzinfo (0.3.38)
62
-
63
- PLATFORMS
64
- ruby
65
-
66
- DEPENDENCIES
67
- html-pipeline (~> 0.0.12)
68
- html-proofer!
69
- rake
70
- rspec (~> 2.13.0)