html-proofer 3.5.0 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/htmlproofer +4 -2
- data/lib/html-proofer/cache.rb +30 -8
- data/lib/html-proofer/check/links.rb +6 -4
- data/lib/html-proofer/configuration.rb +3 -1
- data/lib/html-proofer/runner.rb +0 -4
- data/lib/html-proofer/utils.rb +0 -2
- data/lib/html-proofer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee04feecbb1a662c1c5023003314a6647292fd13
|
4
|
+
data.tar.gz: f01200df1a2f69ea90a2bb8cb49feac80bb4593b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aae793b1fd1d3672cba9a86557efad2b728dd4e09326076c24aeda5203fb03a6aa2600198ae50549d26712ffaf378d405e8f39121e9f0396d34d540f2f5a2c62
|
7
|
+
data.tar.gz: 0ecb402b29e2721ca83acc1b6582d4642954d2378ad0bb992fdfaa93e6d6a326c7199fad2c5056186bfc18b78bf94565f5375fb6f05e8dda69efd90c3108f804
|
data/bin/htmlproofer
CHANGED
@@ -27,7 +27,7 @@ Mercenary.program(:htmlproofer) do |p|
|
|
27
27
|
p.option 'directory_index_file', '--directory-index-file', String, 'Sets the file to look for when a link refers to a directory. (default: `index.html`)'
|
28
28
|
p.option 'disable_external', '--disable-external', 'If `true`, does not run the external link checker, which can take a lot of time (default: `false`)'
|
29
29
|
p.option 'empty_alt_ignore', '--empty-alt-ignore', 'If `true`, ignores images with empty alt tags'
|
30
|
-
p.option 'error_sort', '--error-sort SORT', 'Defines the sort order for error output. Can be `:path`, `:desc`, or `:status` (default:
|
30
|
+
p.option 'error_sort', '--error-sort SORT', 'Defines the sort order for error output. Can be `:path`, `:desc`, or `:status` (default: `:path`).'
|
31
31
|
p.option 'enforce_https', '--enforce-https', 'Fails a link if it\'s not marked as `https` (default: `false`).'
|
32
32
|
p.option 'extension', '--extension EXT', String, 'The extension of your HTML files including the dot. (default: `.html`)'
|
33
33
|
p.option 'external_only', '--external_only', 'Only checks problems with external references'
|
@@ -36,12 +36,13 @@ Mercenary.program(:htmlproofer) do |p|
|
|
36
36
|
p.option 'report_invalid_tags', '--report-invalid-tags', 'Ignore `check_html` errors associated with unknown markup (default: `false`)'
|
37
37
|
p.option 'report_missing_names', '--report-missing-names', 'Ignore `check_html` errors associated with missing entities (default: `false`)'
|
38
38
|
p.option 'report_script_embeds', '--report-script-embeds', 'Ignore `check_html` errors associated with `script`s (default: `false`)'
|
39
|
-
p.option 'log_level', '--log-level <level>', String, 'Sets the logging level, as determined by Yell'
|
39
|
+
p.option 'log_level', '--log-level <level>', String, 'Sets the logging level, as determined by Yell. One of `:debug`, `:info`, `:warn`, `:error`, or `:fatal`. (default: `:info`)'
|
40
40
|
p.option 'only_4xx', '--only-4xx', 'Only reports errors for links that fall within the 4xx status code range'
|
41
41
|
p.option 'timeframe', '--timeframe <time>', String, 'A string representing the caching timeframe.'
|
42
42
|
p.option 'url_ignore', '--url-ignore link1,[link2,...]', Array, 'A comma-separated list of Strings or RegExps containing URLs that are safe to ignore. It affects all HTML attributes. Note that non-HTTP(S) URIs are always ignored'
|
43
43
|
p.option 'url_swap', '--url-swap re:string,[re:string,...]', Array, 'A comma-separated list containing key-value pairs of `RegExp => String`. It transforms URLs that match `RegExp` into `String` via `gsub`. The escape sequences `\\:` should be used to produce literal `:`s.'
|
44
44
|
p.option 'internal_domains', '--internal-domains domain1,[domain2,...]', Array, 'A comma-separated list of Strings containing domains that will be treated as internal urls.'
|
45
|
+
p.option 'storage_dir', '--storage-dir PATH', String, 'Directory where to store the cache log (default: "tmp/.htmlproofer")'
|
45
46
|
|
46
47
|
p.action do |args, opts|
|
47
48
|
args = ['.'] if args.empty?
|
@@ -80,6 +81,7 @@ Mercenary.program(:htmlproofer) do |p|
|
|
80
81
|
|
81
82
|
options[:cache] = {}
|
82
83
|
options[:cache][:timeframe] = opts['timeframe'] unless opts['timeframe'].nil?
|
84
|
+
options[:cache][:storage_dir] = opts['storage_dir'] unless opts['storage_dir'].nil?
|
83
85
|
|
84
86
|
options[:http_status_ignore] = Array(options[:http_status_ignore]).map(&:to_i)
|
85
87
|
|
data/lib/html-proofer/cache.rb
CHANGED
@@ -9,9 +9,10 @@ module HTMLProofer
|
|
9
9
|
class Cache
|
10
10
|
include HTMLProofer::Utils
|
11
11
|
|
12
|
-
|
12
|
+
DEFAULT_STORAGE_DIR = File.join('tmp', '.htmlproofer')
|
13
|
+
DEFAULT_CACHE_FILE_NAME = "cache.log"
|
13
14
|
|
14
|
-
attr_reader :exists, :cache_log
|
15
|
+
attr_reader :exists, :cache_log, :storage_dir, :cache_file
|
15
16
|
|
16
17
|
def initialize(logger, options)
|
17
18
|
@logger = logger
|
@@ -21,15 +22,11 @@ module HTMLProofer
|
|
21
22
|
define_singleton_method('use_cache?') { false }
|
22
23
|
else
|
23
24
|
define_singleton_method('use_cache?') { true }
|
25
|
+
setup_cache!(options)
|
24
26
|
@parsed_timeframe = parsed_timeframe(options[:timeframe])
|
25
27
|
end
|
26
28
|
|
27
29
|
@cache_time = Time.now
|
28
|
-
|
29
|
-
if File.exist?(CACHE_LOG)
|
30
|
-
contents = File.read(CACHE_LOG)
|
31
|
-
@cache_log = contents.empty? ? {} : JSON.parse(contents)
|
32
|
-
end
|
33
30
|
end
|
34
31
|
|
35
32
|
def within_timeframe?(time)
|
@@ -111,7 +108,7 @@ module HTMLProofer
|
|
111
108
|
end
|
112
109
|
|
113
110
|
def write
|
114
|
-
File.write(
|
111
|
+
File.write(cache_file, @cache_log.to_json)
|
115
112
|
end
|
116
113
|
|
117
114
|
def load?
|
@@ -149,5 +146,30 @@ module HTMLProofer
|
|
149
146
|
def clean_url(url)
|
150
147
|
slashless_url(unescape_url(url))
|
151
148
|
end
|
149
|
+
|
150
|
+
def setup_cache!(options)
|
151
|
+
if options[:storage_dir]
|
152
|
+
@storage_dir = options[:storage_dir]
|
153
|
+
else
|
154
|
+
@storage_dir = DEFAULT_STORAGE_DIR
|
155
|
+
end
|
156
|
+
|
157
|
+
if !Dir.exist?(storage_dir)
|
158
|
+
FileUtils.mkdir_p(storage_dir)
|
159
|
+
end
|
160
|
+
|
161
|
+
if options[:cache_file]
|
162
|
+
cache_file_name = options[:cache_file]
|
163
|
+
else
|
164
|
+
cache_file_name = DEFAULT_CACHE_FILE_NAME
|
165
|
+
end
|
166
|
+
|
167
|
+
@cache_file = File.join(storage_dir, cache_file_name)
|
168
|
+
|
169
|
+
if File.exist?(cache_file)
|
170
|
+
contents = File.read(cache_file)
|
171
|
+
@cache_log = contents.empty? ? {} : JSON.parse(contents)
|
172
|
+
end
|
173
|
+
end
|
152
174
|
end
|
153
175
|
end
|
@@ -107,10 +107,12 @@ class LinkCheck < ::HTMLProofer::Check
|
|
107
107
|
|
108
108
|
def hash_check(html, href_hash)
|
109
109
|
decoded_href_hash = URI.decode(href_hash)
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
"//*[case_insensitive_equals(@name,
|
110
|
+
href_hash = "'#{href_hash.split("'").join("', \"'\", '")}', ''"
|
111
|
+
decoded_href_hash = "'#{decoded_href_hash.split("'").join("', \"'\", '")}', ''"
|
112
|
+
html.xpath("//*[case_insensitive_equals(@id, concat(#{href_hash}))]", \
|
113
|
+
"//*[case_insensitive_equals(@name, concat(#{href_hash}))]", \
|
114
|
+
"//*[case_insensitive_equals(@id, concat(#{decoded_href_hash}))]", \
|
115
|
+
"//*[case_insensitive_equals(@name, concat(#{decoded_href_hash}))]", \
|
114
116
|
XpathFunctions.new).length > 0
|
115
117
|
end
|
116
118
|
|
@@ -33,7 +33,9 @@ module HTMLProofer
|
|
33
33
|
:followlocation => true,
|
34
34
|
:headers => {
|
35
35
|
'User-Agent' => "Mozilla/5.0 (compatible; HTML Proofer/#{HTMLProofer::VERSION}; +https://github.com/gjtorikian/html-proofer)"
|
36
|
-
}
|
36
|
+
},
|
37
|
+
:connecttimeout => 10,
|
38
|
+
:timeout => 30
|
37
39
|
}
|
38
40
|
|
39
41
|
HYDRA_DEFAULTS = {
|
data/lib/html-proofer/runner.rb
CHANGED
@@ -19,10 +19,6 @@ module HTMLProofer
|
|
19
19
|
@type = @options.delete(:type)
|
20
20
|
@logger = HTMLProofer::Log.new(@options[:log_level])
|
21
21
|
|
22
|
-
if !@options[:cache].empty? && !File.exist?(STORAGE_DIR)
|
23
|
-
FileUtils.mkdir_p(STORAGE_DIR)
|
24
|
-
end
|
25
|
-
|
26
22
|
# Add swap patterns for internal domains
|
27
23
|
unless @options[:internal_domains].empty?
|
28
24
|
@options[:internal_domains].each do |dom|
|
data/lib/html-proofer/utils.rb
CHANGED
data/lib/html-proofer/version.rb
CHANGED
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: 3.
|
4
|
+
version: 3.6.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: 2017-03-
|
11
|
+
date: 2017-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mercenary
|