checklinks 1.0.0 → 1.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 +4 -4
- data/.ruby-version +1 -1
- data/Gemfile.lock +3 -3
- data/README.md +1 -1
- data/bin/checklinks +28 -13
- data/checklinks.gemspec +1 -1
- data/lib/checklinks/version.rb +1 -1
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28d7c06483db9186de6fac5d3793940d4fe8d0a215b084f8e86a5e6dd32f8ddd
|
4
|
+
data.tar.gz: 774bc7b6b15290bc6ef82db771ab9c9d1c1902d292b286768b1896dfe194794a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1cda6ec6dcf171ced0102702b1a577976992e88f1fe0c0288485509bf0df44750904e7cb00a088e86640c313bbf90312e8e18068ed728bb9e815fed467cfe25
|
7
|
+
data.tar.gz: bc96babb64cddf2fc2540319a70e96a379b15af482db37739e721da075d17fb4c13067ade97933d6f0af0c1f05c0eecf4a020b6f5dffe4d200aa1268e6222754
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.5.
|
1
|
+
2.5.9
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Checklinks finds broken or redirected links in a static webpage.
|
|
4
4
|
|
5
5
|
```
|
6
6
|
% gem install checklinks
|
7
|
-
% checklinks
|
7
|
+
% checklinks **.md
|
8
8
|
```
|
9
9
|
|
10
10
|
It uses code from [awesome_bot](https://github.com/dkhamsing/awesome_bot), but the output is much more terse so it's easier to find which links are broken, and it also prints link locations which makes updating them easier.
|
data/bin/checklinks
CHANGED
@@ -19,9 +19,15 @@ until args.empty?
|
|
19
19
|
config_file = args.shift
|
20
20
|
raise unless config_file
|
21
21
|
config = YAML.load(File.read(config_file))
|
22
|
+
when '--help'
|
23
|
+
puts " checklinks [--config config.yaml] *.md"
|
24
|
+
exit 0
|
22
25
|
else
|
23
|
-
|
26
|
+
puts "unknown argument #{arg}"
|
27
|
+
exit 1
|
24
28
|
end
|
29
|
+
elsif File.directory?(arg)
|
30
|
+
files.push *Dir.glob(File.join(arg, '**', '*.md'))
|
25
31
|
else
|
26
32
|
files.push arg
|
27
33
|
end
|
@@ -52,6 +58,9 @@ file_worklist.process(Set.new) do |filename, found_urls|
|
|
52
58
|
line_number += 1
|
53
59
|
end
|
54
60
|
end
|
61
|
+
rescue => error
|
62
|
+
status_worklist.push [:error]
|
63
|
+
error_collector.push [:file, filename, error]
|
55
64
|
end
|
56
65
|
|
57
66
|
# Process URLs to produce status updates and errors
|
@@ -91,7 +100,7 @@ url_worklist.process_concurrently(16) do |url|
|
|
91
100
|
next
|
92
101
|
end
|
93
102
|
status_worklist.push [:error]
|
94
|
-
error_collector.push [url, code, headers]
|
103
|
+
error_collector.push [:url, url, code, headers]
|
95
104
|
end
|
96
105
|
end
|
97
106
|
|
@@ -108,7 +117,6 @@ status_worklist.process({ok: 0, error: 0, ignored: 0, clear: 0}) do |message, st
|
|
108
117
|
state[:ignored] += 1
|
109
118
|
when :error
|
110
119
|
state[:error] += 1
|
111
|
-
error_collector.push
|
112
120
|
end
|
113
121
|
line = "[#{state[:ok].to_s.rjust(5)} ok, #{state[:ignored].to_s.rjust(5)} ignored, #{state[:error].to_s.rjust(5)} errors, #{file_worklist.size.to_s.rjust(5)} files left, #{url_worklist.size.to_s.rjust(5)} URLs left]"
|
114
122
|
print line if $stdout.tty?
|
@@ -137,7 +145,7 @@ else
|
|
137
145
|
|
138
146
|
# Create a map of errored URLs back to their locations
|
139
147
|
|
140
|
-
urls = errors.
|
148
|
+
urls = errors.select { |error| error.first == :url }.map { |error| error[1] } .to_set
|
141
149
|
url_links = {}
|
142
150
|
links.each do |url, filename, line_number|
|
143
151
|
next unless urls.include?(url)
|
@@ -151,16 +159,23 @@ else
|
|
151
159
|
|
152
160
|
# Print each error
|
153
161
|
|
154
|
-
errors.each do |
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
162
|
+
errors.each do |token, *args|
|
163
|
+
case token
|
164
|
+
when :file
|
165
|
+
filename, error = *args
|
166
|
+
puts " #{filename}: #{error}"
|
167
|
+
when :url
|
168
|
+
url, code, headers = *args
|
159
169
|
message = code
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
170
|
+
if (301..302).include?(code)
|
171
|
+
message = "#{code} -> #{headers['location']}"
|
172
|
+
else
|
173
|
+
message = code
|
174
|
+
end
|
175
|
+
puts " #{url} (#{message})"
|
176
|
+
url_links[url].each do |filename, line_number|
|
177
|
+
puts " #{filename}:#{line_number}"
|
178
|
+
end
|
164
179
|
end
|
165
180
|
end
|
166
181
|
end
|
data/checklinks.gemspec
CHANGED
data/lib/checklinks/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: checklinks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Seaton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -42,15 +42,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
42
42
|
requirements:
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 2.5.
|
45
|
+
version: 2.5.9
|
46
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
48
|
- - ">="
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: '0'
|
51
51
|
requirements: []
|
52
|
-
|
53
|
-
rubygems_version: 2.7.6.2
|
52
|
+
rubygems_version: 3.2.15
|
54
53
|
signing_key:
|
55
54
|
specification_version: 4
|
56
55
|
summary: Find broken links in your static website
|