html-proofer 1.3.3 → 1.4.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/README.md +15 -1
- data/html-proofer.gemspec +2 -1
- data/lib/html/proofer.rb +18 -6
- data/lib/html/proofer/checkable.rb +4 -2
- data/spec/html/proofer_spec.rb +19 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2eb21756ab1eb24e38b51ada6d481b1dbc42eb8
|
4
|
+
data.tar.gz: bb779ed45d42bb8c9e7824cb66bcdd33f027c2ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dd53810b0e3ae1b9760ced7d748100ab5ff56ed9b2b5f9770ea67960653b3a00d199a82f3a92c86c43054c3ec21191f82d9a860be389abce615aaf71b465425
|
7
|
+
data.tar.gz: 1225ae4c9a19292b05017409233dd8e8d1c0bcc5761038a8b40f62bebcc5926073e185ff7a4d4de205a4ffd53886d91481adaba54a57c13eba0086eeac404aba
|
data/README.md
CHANGED
@@ -63,7 +63,7 @@ You'll get a new program called `htmlproof` with this gem. Terrific!
|
|
63
63
|
Use it like you'd expect to:
|
64
64
|
|
65
65
|
``` bash
|
66
|
-
htmlproof
|
66
|
+
htmlproof ./out --swap wow:cow,mow:doh --ext .html.erb --ignore www.github.com
|
67
67
|
```
|
68
68
|
|
69
69
|
Note: since `swap` is a bit special, you'll pass in a pair of `RegEx:String` values.
|
@@ -139,6 +139,8 @@ The `HTML::Proofer` constructor takes an optional hash of additional options:
|
|
139
139
|
| `verbose` | If `true`, outputs extra information as the checking happens. Useful for debugging. | `false` |
|
140
140
|
| `only_4xx` | Only reports errors for links that fall within the 4xx status code range. | `false` |
|
141
141
|
|
142
|
+
### Configuring Typhoeus
|
143
|
+
|
142
144
|
You can also pass in any of Typhoeus' options for the external link check. For example:
|
143
145
|
|
144
146
|
``` ruby
|
@@ -147,6 +149,18 @@ HTML::Proofer.new("out/", {:ext => ".htm", :verbose => true, :ssl_verifyhost =>
|
|
147
149
|
|
148
150
|
This sets `HTML::Proofer`'s extensions to use _.htm_, and gives Typhoeus a configuration for it to be verbose, and use specific SSL settings. Check [the Typhoeus documentation](https://github.com/typhoeus/typhoeus#other-curl-options) for more information on what options it can receive.
|
149
151
|
|
152
|
+
### Configuring Parallel
|
153
|
+
|
154
|
+
[Parallel](https://github.com/grosser/parallel) is being used to speed things up a bit. You can pass in any of its options with the options "namespace" `:parallel`. For example:
|
155
|
+
|
156
|
+
``` ruby
|
157
|
+
HTML::Proofer.new("out/", {:ext => ".htm", :verbose => true, :ssl_verifyhost => 2, :parallel => { :in_processes => 3} })
|
158
|
+
```
|
159
|
+
|
160
|
+
`:in_processes => 3` will be passed into Parallel as a configuration option.
|
161
|
+
|
162
|
+
### Array of links
|
163
|
+
|
150
164
|
Instead of a directory as the first argument, you can also pass in an array of links:
|
151
165
|
|
152
166
|
``` ruby
|
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 = "1.
|
6
|
+
gem.version = "1.4.0"
|
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.}
|
@@ -20,6 +20,7 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.add_dependency "colored", "~> 1.2"
|
21
21
|
gem.add_dependency "typhoeus", "~> 0.6.7"
|
22
22
|
gem.add_dependency "yell", "~> 2.0"
|
23
|
+
gem.add_dependency "parallel", "~> 1.3"
|
23
24
|
|
24
25
|
gem.add_development_dependency "redcarpet"
|
25
26
|
gem.add_development_dependency "rspec", "~> 2.13.0"
|
data/lib/html/proofer.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'nokogiri'
|
2
2
|
require 'yell'
|
3
|
+
require 'parallel'
|
3
4
|
|
4
5
|
begin
|
5
6
|
require "awesome_print"
|
@@ -24,6 +25,8 @@ module HTML
|
|
24
25
|
class Proofer
|
25
26
|
include Yell::Loggable
|
26
27
|
|
28
|
+
attr_reader :options, :typhoeus_opts, :parallel_opts
|
29
|
+
|
27
30
|
def initialize(src, opts={})
|
28
31
|
@src = src
|
29
32
|
|
@@ -43,6 +46,10 @@ module HTML
|
|
43
46
|
:followlocation => true
|
44
47
|
}
|
45
48
|
|
49
|
+
# fall back to parallel defaults
|
50
|
+
@parallel_opts = opts[:parallel] || {}
|
51
|
+
opts.delete(:parallel)
|
52
|
+
|
46
53
|
# Typhoeus won't let you pass in any non-Typhoeus option; if the option is not
|
47
54
|
# a proofer_opt, it must be for Typhoeus
|
48
55
|
opts.keys.each do |key|
|
@@ -63,27 +70,32 @@ module HTML
|
|
63
70
|
|
64
71
|
def run
|
65
72
|
unless @src.is_a? Array
|
66
|
-
total_files = 0
|
67
73
|
external_urls = {}
|
68
74
|
|
69
75
|
logger.info HTML::colorize :white, "Running #{get_checks} checks on #{@src} on *#{@options[:ext]}... \n\n"
|
70
76
|
|
71
|
-
files
|
72
|
-
total_files += 1
|
77
|
+
results = Parallel.map(files, @parallel_opts) do |path|
|
73
78
|
html = HTML::Proofer.create_nokogiri(path)
|
79
|
+
result = {:external_urls => {}, :failed_tests => []}
|
74
80
|
|
75
81
|
get_checks.each do |klass|
|
76
82
|
logger.debug HTML::colorize :blue, "Checking #{klass.to_s.downcase} on #{path} ..."
|
77
83
|
check = Object.const_get(klass).new(@src, path, html, @options)
|
78
84
|
check.run
|
79
|
-
external_urls.merge!(check.external_urls)
|
80
|
-
|
85
|
+
result[:external_urls].merge!(check.external_urls)
|
86
|
+
result[:failed_tests].concat(check.issues) if check.issues.length > 0
|
81
87
|
end
|
88
|
+
result
|
89
|
+
end
|
90
|
+
|
91
|
+
results.each do |item|
|
92
|
+
external_urls.merge!(item[:external_urls])
|
93
|
+
@failed_tests.concat(item[:failed_tests])
|
82
94
|
end
|
83
95
|
|
84
96
|
external_link_checker(external_urls) unless @options[:disable_external]
|
85
97
|
|
86
|
-
logger.info HTML::colorize :green, "Ran on #{
|
98
|
+
logger.info HTML::colorize :green, "Ran on #{files.length} files!\n\n"
|
87
99
|
else
|
88
100
|
external_urls = Hash[*@src.map{ |s| [s, nil] }.flatten]
|
89
101
|
external_link_checker(external_urls) unless @options[:disable_external]
|
@@ -36,9 +36,11 @@ module HTML
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def parts
|
39
|
-
|
39
|
+
return @parts_cached if defined?(@parts_cached)
|
40
|
+
|
41
|
+
@parts_cached = URI::Parser.new(:ESCAPED => '\%|\|').parse url
|
40
42
|
rescue URI::Error
|
41
|
-
nil
|
43
|
+
@parts_cached = nil
|
42
44
|
end
|
43
45
|
|
44
46
|
def path
|
data/spec/html/proofer_spec.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe HTML::Proofer do
|
4
|
+
|
4
5
|
describe "#failed_tests" do
|
5
6
|
it "is a list of the formatted errors" do
|
6
7
|
brokenLinkInternalFilepath = "#{FIXTURES_DIR}/links/brokenLinkInternal.html"
|
@@ -9,6 +10,7 @@ describe HTML::Proofer do
|
|
9
10
|
proofer.failed_tests.should eq(["\e[34mspec/html/proofer/fixtures/links/brokenLinkInternal.html\e[0m: internally linking to ./notreal.html, which does not exist", "\e[34mspec/html/proofer/fixtures/links/brokenLinkInternal.html\e[0m: internally linking to ./missingImageAlt.html, which does not exist"])
|
10
11
|
end
|
11
12
|
end
|
13
|
+
|
12
14
|
describe "#files" do
|
13
15
|
it "works for directory that ends with .html" do
|
14
16
|
folder = "#{FIXTURES_DIR}/links/_site/folder.html"
|
@@ -16,4 +18,21 @@ describe HTML::Proofer do
|
|
16
18
|
proofer.files.should == ["#{folder}/index.html"]
|
17
19
|
end
|
18
20
|
end
|
21
|
+
|
22
|
+
describe "#options" do
|
23
|
+
it "strips out undesired Typhoeus options" do
|
24
|
+
folder = "#{FIXTURES_DIR}/links/_site/folder.html"
|
25
|
+
proofer = HTML::Proofer.new folder, :verbose => true
|
26
|
+
proofer.options[:verbose].should == true
|
27
|
+
proofer.typhoeus_opts[:verbose].should == nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it "takes options for Parallel" do
|
31
|
+
folder = "#{FIXTURES_DIR}/links/_site/folder.html"
|
32
|
+
proofer = HTML::Proofer.new folder, :parallel => { :in_processes => 3 }
|
33
|
+
proofer.parallel_opts[:in_processes].should == 3
|
34
|
+
proofer.typhoeus_opts[:in_processes].should == nil
|
35
|
+
proofer.options[:parallel].should == nil
|
36
|
+
end
|
37
|
+
end
|
19
38
|
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: 1.
|
4
|
+
version: 1.4.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: 2014-
|
11
|
+
date: 2014-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mercenary
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '2.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: parallel
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.3'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.3'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: redcarpet
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|