ruby-link-checker 0.5.1 → 0.6.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/CHANGELOG.md +19 -0
- data/README.md +153 -19
- data/UPGRADING.md +46 -0
- data/lib/ruby-link-checker/async/http/checker.rb +19 -6
- data/lib/ruby-link-checker/async/http/result.rb +1 -1
- data/lib/ruby-link-checker/cache.rb +90 -21
- data/lib/ruby-link-checker/checker.rb +136 -13
- data/lib/ruby-link-checker/config.rb +79 -0
- data/lib/ruby-link-checker/net/http/checker.rb +3 -2
- data/lib/ruby-link-checker/net/http/result.rb +1 -1
- data/lib/ruby-link-checker/redirect.rb +11 -0
- data/lib/ruby-link-checker/result.rb +96 -1
- data/lib/ruby-link-checker/tasks.rb +24 -12
- data/lib/ruby-link-checker/typhoeus/hydra/checker.rb +59 -11
- data/lib/ruby-link-checker/typhoeus/hydra/result.rb +1 -1
- data/lib/ruby-link-checker/version.rb +1 -1
- data/lib/ruby-link-checker.rb +1 -0
- metadata +18 -51
- data/.github/workflows/coverage.yml +0 -24
- data/.github/workflows/danger-comment.yml +0 -17
- data/.github/workflows/danger.yml +0 -12
- data/.github/workflows/lint.yml +0 -20
- data/.github/workflows/release.yml +0 -14
- data/.github/workflows/test.yml +0 -25
- data/.gitignore +0 -6
- data/.rspec +0 -2
- data/.rubocop.yml +0 -26
- data/.rubocop_todo.yml +0 -332
- data/AGENTS.md +0 -23
- data/CONTRIBUTING.md +0 -129
- data/Dangerfile +0 -6
- data/Gemfile +0 -27
- data/RELEASING.md +0 -37
- data/Rakefile +0 -26
- data/benchmarks/check.rb +0 -38
- data/benchmarks/data/opensearch.org/links.txt +0 -4270
- data/benchmarks/data/opensearch.org/small.txt +0 -100
- data/ruby-link-checker.gemspec +0 -22
- data/spec/fixtures/200.yml +0 -65
- data/spec/fixtures/301_200.yml +0 -102
- data/spec/fixtures/301_301.yml +0 -114
- data/spec/fixtures/301_400_301_200.yml +0 -185
- data/spec/fixtures/301_403.yml +0 -78
- data/spec/fixtures/308_429.yml +0 -108
- data/spec/fixtures/404.yml +0 -57
- data/spec/fixtures/404_200.yml +0 -89
- data/spec/fixtures/404_404.yml +0 -81
- data/spec/fixtures/429_200.yml +0 -135
- data/spec/fixtures/429_429_200.yml +0 -201
- data/spec/ruby-link-checker/async/http/checker_spec.rb +0 -184
- data/spec/ruby-link-checker/callbacks_spec.rb +0 -76
- data/spec/ruby-link-checker/checker_spec.rb +0 -97
- data/spec/ruby-link-checker/config_spec.rb +0 -45
- data/spec/ruby-link-checker/errors/redirect_loop_error_spec.rb +0 -18
- data/spec/ruby-link-checker/net/http/checker_spec.rb +0 -93
- data/spec/ruby-link-checker/result_error_spec.rb +0 -34
- data/spec/ruby-link-checker/result_spec.rb +0 -41
- data/spec/ruby-link-checker/task_spec.rb +0 -20
- data/spec/ruby-link-checker/tasks_spec.rb +0 -91
- data/spec/ruby-link-checker/typhoeus/hydra/checker_spec.rb +0 -180
- data/spec/ruby-link-checker/version_spec.rb +0 -9
- data/spec/spec_helper.rb +0 -19
- data/spec/support/config.rb +0 -8
- data/spec/support/link_checker.rb +0 -609
- data/spec/support/vcr.rb +0 -13
- data/spec/support/with_result.rb +0 -15
- data/spec/support/with_url.rb +0 -14
|
@@ -4,14 +4,12 @@ module LinkChecker
|
|
|
4
4
|
class Task < ::LinkChecker::Task
|
|
5
5
|
def run!
|
|
6
6
|
request = ::Typhoeus::Request.new(
|
|
7
|
-
|
|
7
|
+
request_uri, {
|
|
8
8
|
method: method.downcase.to_sym,
|
|
9
9
|
followlocation: false,
|
|
10
10
|
timeout: checker.timeout,
|
|
11
11
|
connecttimeout: checker.connecttimeout,
|
|
12
|
-
headers:
|
|
13
|
-
'User-Agent' => checker.user_agent
|
|
14
|
-
}.merge(checker.headers)
|
|
12
|
+
headers: checker.request_headers_for(uri)
|
|
15
13
|
}
|
|
16
14
|
)
|
|
17
15
|
request.on_complete do |response|
|
|
@@ -26,6 +24,13 @@ module LinkChecker
|
|
|
26
24
|
end
|
|
27
25
|
checker._queue(request, delay: delay)
|
|
28
26
|
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
# Fragments are not part of an HTTP request.
|
|
31
|
+
def request_uri
|
|
32
|
+
uri.fragment ? uri.dup.tap { |request_uri| request_uri.fragment = nil } : uri
|
|
33
|
+
end
|
|
29
34
|
end
|
|
30
35
|
|
|
31
36
|
class Checker < LinkChecker::Checker
|
|
@@ -39,6 +44,9 @@ module LinkChecker
|
|
|
39
44
|
end
|
|
40
45
|
@hydra = ::Typhoeus::Hydra.new(options[:hydra] || { max_concurrency: 10 })
|
|
41
46
|
@delayed = []
|
|
47
|
+
@host_waiting = Hash.new { |hash, host| hash[host] = [] }
|
|
48
|
+
@host_active = Hash.new(0)
|
|
49
|
+
@host_scheduled = {}
|
|
42
50
|
super options
|
|
43
51
|
end
|
|
44
52
|
|
|
@@ -48,24 +56,64 @@ module LinkChecker
|
|
|
48
56
|
break if @delayed.empty?
|
|
49
57
|
|
|
50
58
|
deadline = @delayed.map(&:first).min
|
|
51
|
-
sleep([deadline -
|
|
52
|
-
ready, @delayed = @delayed.partition { |time,
|
|
53
|
-
ready.each { |entry|
|
|
59
|
+
sleep([deadline - _monotonic_time, 0].max)
|
|
60
|
+
ready, @delayed = @delayed.partition { |time, _action| time <= _monotonic_time }
|
|
61
|
+
ready.each { |entry| entry.last.call }
|
|
54
62
|
end
|
|
63
|
+
_finish_run
|
|
55
64
|
end
|
|
56
65
|
|
|
57
66
|
def _queue(request, delay: 0)
|
|
58
67
|
if delay.positive?
|
|
59
|
-
@delayed << [
|
|
68
|
+
@delayed << [_monotonic_time + delay, -> { _admit(request) }]
|
|
60
69
|
else
|
|
61
|
-
|
|
70
|
+
_admit(request)
|
|
62
71
|
end
|
|
63
72
|
end
|
|
64
73
|
|
|
65
74
|
private
|
|
66
75
|
|
|
67
|
-
def
|
|
68
|
-
|
|
76
|
+
def _host_limits?(host)
|
|
77
|
+
max_concurrency_per_host || min_host_interval.positive? || @host_waiting[host].any? || _host_wait(host).positive?
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Holds requests per host and hands them to Hydra within the per-host limits.
|
|
81
|
+
def _admit(request)
|
|
82
|
+
host = _host_key(request.base_url)
|
|
83
|
+
return @hydra.queue(request) unless host && _host_limits?(host)
|
|
84
|
+
|
|
85
|
+
@host_waiting[host] << request
|
|
86
|
+
_dispatch(host)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def _dispatch(host)
|
|
90
|
+
waiting = @host_waiting[host]
|
|
91
|
+
while waiting.any?
|
|
92
|
+
return if max_concurrency_per_host && @host_active[host] >= max_concurrency_per_host
|
|
93
|
+
|
|
94
|
+
wait = _host_wait(host)
|
|
95
|
+
return _schedule_dispatch(host, wait) if wait.positive?
|
|
96
|
+
|
|
97
|
+
request = waiting.shift
|
|
98
|
+
_reserve_host_slot(host)
|
|
99
|
+
@host_active[host] += 1
|
|
100
|
+
request.on_complete do
|
|
101
|
+
@host_active[host] -= 1
|
|
102
|
+
_dispatch(host)
|
|
103
|
+
end
|
|
104
|
+
@hydra.queue(request)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Hydra cannot start a request later, so retry the dispatch once the active batch drains.
|
|
109
|
+
def _schedule_dispatch(host, wait)
|
|
110
|
+
return if @host_scheduled[host]
|
|
111
|
+
|
|
112
|
+
@host_scheduled[host] = true
|
|
113
|
+
@delayed << [_monotonic_time + wait, lambda {
|
|
114
|
+
@host_scheduled.delete(host)
|
|
115
|
+
_dispatch(host)
|
|
116
|
+
}]
|
|
69
117
|
end
|
|
70
118
|
end
|
|
71
119
|
end
|
data/lib/ruby-link-checker.rb
CHANGED
|
@@ -8,6 +8,7 @@ require_relative 'ruby-link-checker/logger'
|
|
|
8
8
|
require_relative 'ruby-link-checker/task'
|
|
9
9
|
require_relative 'ruby-link-checker/tasks'
|
|
10
10
|
require_relative 'ruby-link-checker/checker'
|
|
11
|
+
require_relative 'ruby-link-checker/redirect'
|
|
11
12
|
require_relative 'ruby-link-checker/result'
|
|
12
13
|
require_relative 'ruby-link-checker/cache'
|
|
13
14
|
require_relative 'ruby-link-checker/net/http'
|
metadata
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-link-checker
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Doubrovkine
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: logger
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
13
27
|
- !ruby/object:Gem::Dependency
|
|
14
28
|
name: async-http
|
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -44,28 +58,10 @@ executables: []
|
|
|
44
58
|
extensions: []
|
|
45
59
|
extra_rdoc_files: []
|
|
46
60
|
files:
|
|
47
|
-
- ".github/workflows/coverage.yml"
|
|
48
|
-
- ".github/workflows/danger-comment.yml"
|
|
49
|
-
- ".github/workflows/danger.yml"
|
|
50
|
-
- ".github/workflows/lint.yml"
|
|
51
|
-
- ".github/workflows/release.yml"
|
|
52
|
-
- ".github/workflows/test.yml"
|
|
53
|
-
- ".gitignore"
|
|
54
|
-
- ".rspec"
|
|
55
|
-
- ".rubocop.yml"
|
|
56
|
-
- ".rubocop_todo.yml"
|
|
57
|
-
- AGENTS.md
|
|
58
61
|
- CHANGELOG.md
|
|
59
|
-
- CONTRIBUTING.md
|
|
60
|
-
- Dangerfile
|
|
61
|
-
- Gemfile
|
|
62
62
|
- LICENSE.md
|
|
63
63
|
- README.md
|
|
64
|
-
-
|
|
65
|
-
- Rakefile
|
|
66
|
-
- benchmarks/check.rb
|
|
67
|
-
- benchmarks/data/opensearch.org/links.txt
|
|
68
|
-
- benchmarks/data/opensearch.org/small.txt
|
|
64
|
+
- UPGRADING.md
|
|
69
65
|
- lib/ruby-link-checker.rb
|
|
70
66
|
- lib/ruby-link-checker/async/http.rb
|
|
71
67
|
- lib/ruby-link-checker/async/http/checker.rb
|
|
@@ -85,6 +81,7 @@ files:
|
|
|
85
81
|
- lib/ruby-link-checker/net/http/checker.rb
|
|
86
82
|
- lib/ruby-link-checker/net/http/config.rb
|
|
87
83
|
- lib/ruby-link-checker/net/http/result.rb
|
|
84
|
+
- lib/ruby-link-checker/redirect.rb
|
|
88
85
|
- lib/ruby-link-checker/result.rb
|
|
89
86
|
- lib/ruby-link-checker/task.rb
|
|
90
87
|
- lib/ruby-link-checker/tasks.rb
|
|
@@ -94,36 +91,6 @@ files:
|
|
|
94
91
|
- lib/ruby-link-checker/typhoeus/hydra/result.rb
|
|
95
92
|
- lib/ruby-link-checker/version.rb
|
|
96
93
|
- lib/ruby_link_checker.rb
|
|
97
|
-
- ruby-link-checker.gemspec
|
|
98
|
-
- spec/fixtures/200.yml
|
|
99
|
-
- spec/fixtures/301_200.yml
|
|
100
|
-
- spec/fixtures/301_301.yml
|
|
101
|
-
- spec/fixtures/301_400_301_200.yml
|
|
102
|
-
- spec/fixtures/301_403.yml
|
|
103
|
-
- spec/fixtures/308_429.yml
|
|
104
|
-
- spec/fixtures/404.yml
|
|
105
|
-
- spec/fixtures/404_200.yml
|
|
106
|
-
- spec/fixtures/404_404.yml
|
|
107
|
-
- spec/fixtures/429_200.yml
|
|
108
|
-
- spec/fixtures/429_429_200.yml
|
|
109
|
-
- spec/ruby-link-checker/async/http/checker_spec.rb
|
|
110
|
-
- spec/ruby-link-checker/callbacks_spec.rb
|
|
111
|
-
- spec/ruby-link-checker/checker_spec.rb
|
|
112
|
-
- spec/ruby-link-checker/config_spec.rb
|
|
113
|
-
- spec/ruby-link-checker/errors/redirect_loop_error_spec.rb
|
|
114
|
-
- spec/ruby-link-checker/net/http/checker_spec.rb
|
|
115
|
-
- spec/ruby-link-checker/result_error_spec.rb
|
|
116
|
-
- spec/ruby-link-checker/result_spec.rb
|
|
117
|
-
- spec/ruby-link-checker/task_spec.rb
|
|
118
|
-
- spec/ruby-link-checker/tasks_spec.rb
|
|
119
|
-
- spec/ruby-link-checker/typhoeus/hydra/checker_spec.rb
|
|
120
|
-
- spec/ruby-link-checker/version_spec.rb
|
|
121
|
-
- spec/spec_helper.rb
|
|
122
|
-
- spec/support/config.rb
|
|
123
|
-
- spec/support/link_checker.rb
|
|
124
|
-
- spec/support/vcr.rb
|
|
125
|
-
- spec/support/with_result.rb
|
|
126
|
-
- spec/support/with_url.rb
|
|
127
94
|
homepage: http://github.com/dblock/ruby-link-checker
|
|
128
95
|
licenses:
|
|
129
96
|
- MIT
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: coverage
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
pull_request:
|
|
8
|
-
jobs:
|
|
9
|
-
coverage:
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
steps:
|
|
12
|
-
- uses: actions/checkout@v4
|
|
13
|
-
- uses: ruby/setup-ruby@v1
|
|
14
|
-
with:
|
|
15
|
-
ruby-version: 3.4
|
|
16
|
-
bundler-cache: true
|
|
17
|
-
- name: Run tests with coverage
|
|
18
|
-
run: bundle exec rake spec
|
|
19
|
-
- name: Upload coverage to Codecov
|
|
20
|
-
uses: codecov/codecov-action@v5
|
|
21
|
-
with:
|
|
22
|
-
files: coverage/.resultset.json
|
|
23
|
-
fail_ci_if_error: true
|
|
24
|
-
token: ${{ secrets.CODECOV_TOKEN }}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
name: Danger Comment
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
workflow_run:
|
|
5
|
-
workflows: [Danger]
|
|
6
|
-
types: [completed]
|
|
7
|
-
|
|
8
|
-
permissions:
|
|
9
|
-
actions: read
|
|
10
|
-
issues: write
|
|
11
|
-
pull-requests: write
|
|
12
|
-
contents: read
|
|
13
|
-
|
|
14
|
-
jobs:
|
|
15
|
-
comment:
|
|
16
|
-
uses: numbata/danger-pr-comment/.github/workflows/danger-comment.yml@v0.1.0
|
|
17
|
-
secrets: inherit
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Danger
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
types: [opened, reopened, edited, synchronize]
|
|
6
|
-
jobs:
|
|
7
|
-
danger:
|
|
8
|
-
uses: numbata/danger-pr-comment/.github/workflows/danger-run.yml@v0.1.0
|
|
9
|
-
secrets: inherit
|
|
10
|
-
with:
|
|
11
|
-
ruby-version: "3.3"
|
|
12
|
-
danger-args: "dry_run --base=origin/main"
|
data/.github/workflows/lint.yml
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
name: Lint
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
branches:
|
|
5
|
-
- main
|
|
6
|
-
pull_request:
|
|
7
|
-
jobs:
|
|
8
|
-
rubocop:
|
|
9
|
-
name: RuboCop
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
steps:
|
|
12
|
-
- name: Checkout
|
|
13
|
-
uses: actions/checkout@v3
|
|
14
|
-
- name: Set up Ruby
|
|
15
|
-
uses: ruby/setup-ruby@v1
|
|
16
|
-
with:
|
|
17
|
-
ruby-version: 3.3
|
|
18
|
-
bundler-cache: true
|
|
19
|
-
- run: bundle exec rubocop
|
|
20
|
-
|
data/.github/workflows/test.yml
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: test
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
pull_request:
|
|
8
|
-
jobs:
|
|
9
|
-
test:
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
strategy:
|
|
12
|
-
fail-fast: false
|
|
13
|
-
matrix:
|
|
14
|
-
entry:
|
|
15
|
-
- { ruby: '3.3' }
|
|
16
|
-
- { ruby: '3.4' }
|
|
17
|
-
- { ruby: '4.0' }
|
|
18
|
-
name: test (${{ matrix.entry.ruby }})
|
|
19
|
-
steps:
|
|
20
|
-
- uses: actions/checkout@v3
|
|
21
|
-
- uses: ruby/setup-ruby@v1
|
|
22
|
-
with:
|
|
23
|
-
ruby-version: ${{ matrix.entry.ruby }}
|
|
24
|
-
- run: bundle install --jobs=3 --retry=3
|
|
25
|
-
- run: bundle exec rake spec
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
AllCops:
|
|
2
|
-
TargetRubyVersion: 3.3
|
|
3
|
-
NewCops: enable
|
|
4
|
-
Exclude:
|
|
5
|
-
- vendor/**/*
|
|
6
|
-
|
|
7
|
-
Style/HashEachMethods:
|
|
8
|
-
Enabled: true
|
|
9
|
-
|
|
10
|
-
Style/HashTransformKeys:
|
|
11
|
-
Enabled: true
|
|
12
|
-
|
|
13
|
-
Style/HashTransformValues:
|
|
14
|
-
Enabled: true
|
|
15
|
-
|
|
16
|
-
Metrics:
|
|
17
|
-
Enabled: false
|
|
18
|
-
|
|
19
|
-
Layout/EndOfLine:
|
|
20
|
-
EnforcedStyle: lf
|
|
21
|
-
|
|
22
|
-
plugins:
|
|
23
|
-
- rubocop-rake
|
|
24
|
-
- rubocop-rspec
|
|
25
|
-
|
|
26
|
-
inherit_from: .rubocop_todo.yml
|