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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9370e4ac12c05fc8906a579b52fb248045d010f9661bd72794ebdf11755b0632
4
- data.tar.gz: 470a3371cd2f08ec0ec45457180686e3da0f7ebe78a75caadd63ac3c75ca52e4
3
+ metadata.gz: 28d7c06483db9186de6fac5d3793940d4fe8d0a215b084f8e86a5e6dd32f8ddd
4
+ data.tar.gz: 774bc7b6b15290bc6ef82db771ab9c9d1c1902d292b286768b1896dfe194794a
5
5
  SHA512:
6
- metadata.gz: 88cb4b61dbbbbb53c37537bcdc21c4557b561f01904402046ed53049023b592d3bf0a4d2442b28528c3d1df5e805da5399bccb245863f2251f3efb974d76a315
7
- data.tar.gz: f3efe8a2d9631bede466d934aa77b667656914be5e808bb57020f1814dad78b46b04cf6f5f4e66f518f870fa8785e54477c5ec750c77cbcc127382bcb87e86ff
6
+ metadata.gz: e1cda6ec6dcf171ced0102702b1a577976992e88f1fe0c0288485509bf0df44750904e7cb00a088e86640c313bbf90312e8e18068ed728bb9e815fed467cfe25
7
+ data.tar.gz: bc96babb64cddf2fc2540319a70e96a379b15af482db37739e721da075d17fb4c13067ade97933d6f0af0c1f05c0eecf4a020b6f5dffe4d200aa1268e6222754
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.8
1
+ 2.5.9
data/Gemfile.lock CHANGED
@@ -1,17 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- checklinks (1.0.0)
4
+ checklinks (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
 
10
10
  PLATFORMS
11
- ruby
11
+ x86_64-darwin-20
12
12
 
13
13
  DEPENDENCIES
14
14
  checklinks!
15
15
 
16
16
  BUNDLED WITH
17
- 1.17.3
17
+ 2.2.17
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 **/*.md
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
- raise
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.map(&:first).to_set
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 |url, code, headers|
155
- message = code
156
- if (301..302).include?(code)
157
- message = "#{code} -> #{headers['location']}"
158
- else
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
- end
161
- puts " #{url} (#{message})"
162
- url_links[url].each do |filename, line_number|
163
- puts " #{filename}:#{line_number}"
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
@@ -17,5 +17,5 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.require_paths = ['lib']
19
19
 
20
- spec.required_ruby_version = '>= 2.5.8'
20
+ spec.required_ruby_version = '>= 2.5.9'
21
21
  end
@@ -1,6 +1,6 @@
1
1
  module Checklinks
2
2
  MAJOR_VERSION = 1
3
- MINOR_VERSION = 0
3
+ MINOR_VERSION = 1
4
4
  PATCH_VERSION = 0
5
5
  VERSION = "#{MAJOR_VERSION}.#{MINOR_VERSION}.#{PATCH_VERSION}"
6
6
  end
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.0.0
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: 2020-09-14 00:00:00.000000000 Z
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.8
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
- rubyforge_project:
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