html-proofer 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -3
- data/html-proofer.gemspec +1 -1
- data/lib/html/proofer/checkable.rb +5 -1
- data/lib/html/proofer/checks/links.rb +7 -6
- data/spec/html/proofer/fixtures/blank_mailto_link.html +9 -0
- data/spec/html/proofer/fixtures/blank_tel_link.html +9 -0
- data/spec/html/proofer/fixtures/existingImageExternal.html +2 -2
- data/spec/html/proofer/fixtures/image_missing_protocol_invalid.html +9 -0
- data/spec/html/proofer/fixtures/image_missing_protocol_valid.html +9 -0
- data/spec/html/proofer/fixtures/link_missing_protocol_invalid.html +9 -0
- data/spec/html/proofer/fixtures/link_missing_protocol_valid.html +9 -0
- data/spec/html/proofer/fixtures/mailto_link.html +9 -0
- data/spec/html/proofer/fixtures/tel_link.html +9 -0
- data/spec/html/proofer/images_spec.rb +12 -0
- data/spec/html/proofer/links_spec.rb +36 -0
- metadata +41 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bda5b3c0387493f6b642dc807b34fff181e1089
|
4
|
+
data.tar.gz: b813373ac7949a41141f81252244612d5e307b71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a02eb1565f8e2b70216de62489190835e4317e8d8e23db4f11724bcdec0a8984e552b5ab4e45713ac99e892a51bed55e3cdba45ff26c3db4eed499a1e6a6eba
|
7
|
+
data.tar.gz: 8ec26851a516a22f6885a576300e224e6b96d078251676ca0a7771413106e31d8637b86e23e18be11726464729a1dd29a8ef42c7327787a2b6e39db0614ab5da
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ And then execute:
|
|
19
19
|
Or install it yourself as:
|
20
20
|
|
21
21
|
$ gem install html-proofer
|
22
|
-
|
22
|
+
|
23
23
|
**NOTE:** When installation speed matters, set `NOKOGIRI_USE_SYSTEM_LIBRARIES` to `true` in your environment. This is useful for increasing the speed of your Continuous Integration builds.
|
24
24
|
|
25
25
|
## Usage
|
@@ -104,7 +104,7 @@ The `HTML::Proofer` constructor takes an optional hash of additional options:
|
|
104
104
|
|
105
105
|
* `:ext`: the extension (including the `.`) of your HTML files (default: `.html`)
|
106
106
|
* `:href_swap`: a hash containing key-value pairs of `RegExp => String`. It transforms links that match `RegExp` into `String` via `gsub`.
|
107
|
-
* `:href_ignore`: an array of Strings or RegExps containing `href`s that are safe to ignore (`mailto`
|
107
|
+
* `:href_ignore`: an array of Strings or RegExps containing `href`s that are safe to ignore (certain URIs, like `mailto` and `tel`, are always ignored)
|
108
108
|
* `:disable_external`: if `true`, does not run the external link checker, which can take a lot of time (default: `false`)
|
109
109
|
* `:verbose`: if `true`, outputs extra information as the checking happens. Useful for debugging. (default: `false`)
|
110
110
|
|
@@ -153,4 +153,3 @@ class MailToOctocat < ::HTML::Proofer::Checks::Check
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
```
|
156
|
-
|
data/html-proofer.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = "html-proofer"
|
6
|
-
gem.version = "0.7.
|
6
|
+
gem.version = "0.7.2"
|
7
7
|
gem.authors = ["Garen Torikian"]
|
8
8
|
gem.email = ["gjtorikian@gmail.com"]
|
9
9
|
gem.description = %q{Test your rendered HTML files to make sure they're accurate.}
|
@@ -18,6 +18,10 @@ module HTML
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
# fix up missing protocols
|
22
|
+
@href.insert 0, "http:" if @href =~ /^\/\//
|
23
|
+
@src.insert 0, "http:" if @src =~ /^\/\//
|
24
|
+
|
21
25
|
end
|
22
26
|
|
23
27
|
def url
|
@@ -72,7 +76,7 @@ module HTML
|
|
72
76
|
end
|
73
77
|
|
74
78
|
uri = URI.parse url
|
75
|
-
%w( mailto ).include?(uri.scheme)
|
79
|
+
%w( mailto tel ).include?(uri.scheme)
|
76
80
|
rescue URI::BadURIError
|
77
81
|
false
|
78
82
|
rescue URI::InvalidURIError
|
@@ -17,6 +17,13 @@ class Links < ::HTML::Proofer::Checks::Check
|
|
17
17
|
def run
|
18
18
|
@html.css('a').each do |l|
|
19
19
|
link = Link.new l, "link", self
|
20
|
+
|
21
|
+
# is it even a valid URL?
|
22
|
+
unless link.valid?
|
23
|
+
self.add_issue "#{link.href} is an invalid URL"
|
24
|
+
next
|
25
|
+
end
|
26
|
+
|
20
27
|
next if link.ignore?
|
21
28
|
|
22
29
|
# is there even a href?
|
@@ -25,12 +32,6 @@ class Links < ::HTML::Proofer::Checks::Check
|
|
25
32
|
next
|
26
33
|
end
|
27
34
|
|
28
|
-
# is it even a valid URL?
|
29
|
-
unless link.valid?
|
30
|
-
self.add_issue "#{link.href} is an invalid URL"
|
31
|
-
next
|
32
|
-
end
|
33
|
-
|
34
35
|
# does the file even exist?
|
35
36
|
if link.remote?
|
36
37
|
add_to_external_urls link.href
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
<body>
|
4
4
|
|
5
|
-
<p>Blah blah blah. <img alt="
|
5
|
+
<p>Blah blah blah. <img alt="An existing image" src="http://upload.wikimedia.org/wikipedia/en/thumb/2/22/Heckert_GNU_white.svg/256px-Heckert_GNU_white.svg.png" /> </p>
|
6
6
|
|
7
7
|
</body>
|
8
8
|
|
9
|
-
</html>
|
9
|
+
</html>
|
@@ -64,4 +64,16 @@ describe "Image tests" do
|
|
64
64
|
output = capture_stderr { HTML::Proofer.new(dataURIImage).run }
|
65
65
|
output.should == ""
|
66
66
|
end
|
67
|
+
|
68
|
+
it "works for valid images missing the protocol" do
|
69
|
+
missingProtocolLink = "#{FIXTURES_DIR}/image_missing_protocol_valid.html"
|
70
|
+
output = capture_stderr { HTML::Proofer.new(missingProtocolLink).run }
|
71
|
+
output.should == ""
|
72
|
+
end
|
73
|
+
|
74
|
+
it "fails for invalid images missing the protocol" do
|
75
|
+
missingProtocolLink = "#{FIXTURES_DIR}/image_missing_protocol_invalid.html"
|
76
|
+
output = capture_stderr { HTML::Proofer.new(missingProtocolLink).run }
|
77
|
+
output.should match /404 No error/
|
78
|
+
end
|
67
79
|
end
|
@@ -97,4 +97,40 @@ describe "Links tests" do
|
|
97
97
|
output = capture_stderr { HTML::Proofer.new(multipleProblems).run }
|
98
98
|
output.should match /linking to internal hash #anadaasdadsadschor that does not exist/
|
99
99
|
end
|
100
|
+
|
101
|
+
it 'ignores valid mailto links' do
|
102
|
+
ignorableLinks = "#{FIXTURES_DIR}/mailto_link.html"
|
103
|
+
output = capture_stderr { HTML::Proofer.new(ignorableLinks).run }
|
104
|
+
output.should == ""
|
105
|
+
end
|
106
|
+
|
107
|
+
it "fails for blank mailto links" do
|
108
|
+
blankMailToLink = "#{FIXTURES_DIR}/blank_mailto_link.html"
|
109
|
+
output = capture_stderr { HTML::Proofer.new(blankMailToLink).run }
|
110
|
+
output.should match /mailto: is an invalid URL/
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'ignores valid tel links' do
|
114
|
+
ignorableLinks = "#{FIXTURES_DIR}/tel_link.html"
|
115
|
+
output = capture_stderr { HTML::Proofer.new(ignorableLinks).run }
|
116
|
+
output.should == ""
|
117
|
+
end
|
118
|
+
|
119
|
+
it "fails for blank tel links" do
|
120
|
+
blankTelLink = "#{FIXTURES_DIR}/blank_tel_link.html"
|
121
|
+
output = capture_stderr { HTML::Proofer.new(blankTelLink).run }
|
122
|
+
output.should match /tel: is an invalid URL/
|
123
|
+
end
|
124
|
+
|
125
|
+
it "works for valid links missing the protocol" do
|
126
|
+
missingProtocolLink = "#{FIXTURES_DIR}/link_missing_protocol_valid.html"
|
127
|
+
output = capture_stderr { HTML::Proofer.new(missingProtocolLink).run }
|
128
|
+
output.should == ""
|
129
|
+
end
|
130
|
+
|
131
|
+
it "fails for invalid links missing the protocol" do
|
132
|
+
missingProtocolLink = "#{FIXTURES_DIR}/link_missing_protocol_invalid.html"
|
133
|
+
output = capture_stderr { HTML::Proofer.new(missingProtocolLink).run }
|
134
|
+
output.should match /Couldn't resolve host name/
|
135
|
+
end
|
100
136
|
end
|
metadata
CHANGED
@@ -1,139 +1,139 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html-proofer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mercenary
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.3.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.3.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: nokogiri
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.6.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.6.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: colored
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.2'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: typhoeus
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.6.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
68
|
version: 0.6.7
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: yell
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '2.0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '2.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: html-pipeline
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '1.8'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ~>
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.8'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: escape_utils
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - ~>
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '1.0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - ~>
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '1.0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rspec
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - ~>
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: 2.13.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - ~>
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 2.13.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rake
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
description: Test your rendered HTML files to make sure they're accurate.
|
@@ -144,8 +144,8 @@ executables:
|
|
144
144
|
extensions: []
|
145
145
|
extra_rdoc_files: []
|
146
146
|
files:
|
147
|
-
- .gitignore
|
148
|
-
- .travis.yml
|
147
|
+
- ".gitignore"
|
148
|
+
- ".travis.yml"
|
149
149
|
- Gemfile
|
150
150
|
- LICENSE.txt
|
151
151
|
- README.md
|
@@ -159,6 +159,8 @@ files:
|
|
159
159
|
- lib/html/proofer/checks/images.rb
|
160
160
|
- lib/html/proofer/checks/links.rb
|
161
161
|
- spec/html/proofer/fixtures/Screen Shot 2012-08-09 at 7.51.18 AM.png
|
162
|
+
- spec/html/proofer/fixtures/blank_mailto_link.html
|
163
|
+
- spec/html/proofer/fixtures/blank_tel_link.html
|
162
164
|
- spec/html/proofer/fixtures/brokenHashExternal.html
|
163
165
|
- spec/html/proofer/fixtures/brokenHashInternal.html
|
164
166
|
- spec/html/proofer/fixtures/brokenInternalLink.html
|
@@ -175,11 +177,16 @@ files:
|
|
175
177
|
- spec/html/proofer/fixtures/ignorableImages.html
|
176
178
|
- spec/html/proofer/fixtures/ignorableLinks.html
|
177
179
|
- spec/html/proofer/fixtures/ignorableLinksViaOptions.html
|
180
|
+
- spec/html/proofer/fixtures/image_missing_protocol_invalid.html
|
181
|
+
- spec/html/proofer/fixtures/image_missing_protocol_valid.html
|
178
182
|
- spec/html/proofer/fixtures/index.html
|
179
183
|
- spec/html/proofer/fixtures/linkToFolder.html
|
180
184
|
- spec/html/proofer/fixtures/linkTranslatedViaHrefSwap.html
|
181
185
|
- spec/html/proofer/fixtures/linkWithHttps.html
|
182
186
|
- spec/html/proofer/fixtures/linkWithRedirect.html
|
187
|
+
- spec/html/proofer/fixtures/link_missing_protocol_invalid.html
|
188
|
+
- spec/html/proofer/fixtures/link_missing_protocol_valid.html
|
189
|
+
- spec/html/proofer/fixtures/mailto_link.html
|
183
190
|
- spec/html/proofer/fixtures/missingImageAlt.html
|
184
191
|
- spec/html/proofer/fixtures/missingImageAltText.html
|
185
192
|
- spec/html/proofer/fixtures/missingImageExternal.html
|
@@ -195,6 +202,7 @@ files:
|
|
195
202
|
- spec/html/proofer/fixtures/resources/books/nestedRelativeImages.html
|
196
203
|
- spec/html/proofer/fixtures/rootLink.html
|
197
204
|
- spec/html/proofer/fixtures/rootRelativeImages.html
|
205
|
+
- spec/html/proofer/fixtures/tel_link.html
|
198
206
|
- spec/html/proofer/fixtures/terribleImageName.html
|
199
207
|
- spec/html/proofer/fixtures/workingDataURIImage.html
|
200
208
|
- spec/html/proofer/images_spec.rb
|
@@ -211,17 +219,17 @@ require_paths:
|
|
211
219
|
- lib
|
212
220
|
required_ruby_version: !ruby/object:Gem::Requirement
|
213
221
|
requirements:
|
214
|
-
- -
|
222
|
+
- - ">="
|
215
223
|
- !ruby/object:Gem::Version
|
216
224
|
version: '0'
|
217
225
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
218
226
|
requirements:
|
219
|
-
- -
|
227
|
+
- - ">="
|
220
228
|
- !ruby/object:Gem::Version
|
221
229
|
version: '0'
|
222
230
|
requirements: []
|
223
231
|
rubyforge_project:
|
224
|
-
rubygems_version: 2.
|
232
|
+
rubygems_version: 2.2.2
|
225
233
|
signing_key:
|
226
234
|
specification_version: 4
|
227
235
|
summary: A set of tests to validate your HTML output. These tests check if your image
|
@@ -229,6 +237,8 @@ summary: A set of tests to validate your HTML output. These tests check if your
|
|
229
237
|
and so on. It's intended to be an all-in-one checker for your documentation output.
|
230
238
|
test_files:
|
231
239
|
- spec/html/proofer/fixtures/Screen Shot 2012-08-09 at 7.51.18 AM.png
|
240
|
+
- spec/html/proofer/fixtures/blank_mailto_link.html
|
241
|
+
- spec/html/proofer/fixtures/blank_tel_link.html
|
232
242
|
- spec/html/proofer/fixtures/brokenHashExternal.html
|
233
243
|
- spec/html/proofer/fixtures/brokenHashInternal.html
|
234
244
|
- spec/html/proofer/fixtures/brokenInternalLink.html
|
@@ -245,11 +255,16 @@ test_files:
|
|
245
255
|
- spec/html/proofer/fixtures/ignorableImages.html
|
246
256
|
- spec/html/proofer/fixtures/ignorableLinks.html
|
247
257
|
- spec/html/proofer/fixtures/ignorableLinksViaOptions.html
|
258
|
+
- spec/html/proofer/fixtures/image_missing_protocol_invalid.html
|
259
|
+
- spec/html/proofer/fixtures/image_missing_protocol_valid.html
|
248
260
|
- spec/html/proofer/fixtures/index.html
|
249
261
|
- spec/html/proofer/fixtures/linkToFolder.html
|
250
262
|
- spec/html/proofer/fixtures/linkTranslatedViaHrefSwap.html
|
251
263
|
- spec/html/proofer/fixtures/linkWithHttps.html
|
252
264
|
- spec/html/proofer/fixtures/linkWithRedirect.html
|
265
|
+
- spec/html/proofer/fixtures/link_missing_protocol_invalid.html
|
266
|
+
- spec/html/proofer/fixtures/link_missing_protocol_valid.html
|
267
|
+
- spec/html/proofer/fixtures/mailto_link.html
|
253
268
|
- spec/html/proofer/fixtures/missingImageAlt.html
|
254
269
|
- spec/html/proofer/fixtures/missingImageAltText.html
|
255
270
|
- spec/html/proofer/fixtures/missingImageExternal.html
|
@@ -265,6 +280,7 @@ test_files:
|
|
265
280
|
- spec/html/proofer/fixtures/resources/books/nestedRelativeImages.html
|
266
281
|
- spec/html/proofer/fixtures/rootLink.html
|
267
282
|
- spec/html/proofer/fixtures/rootRelativeImages.html
|
283
|
+
- spec/html/proofer/fixtures/tel_link.html
|
268
284
|
- spec/html/proofer/fixtures/terribleImageName.html
|
269
285
|
- spec/html/proofer/fixtures/workingDataURIImage.html
|
270
286
|
- spec/html/proofer/images_spec.rb
|