ruby-link-checker 0.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 +7 -0
- data/CHANGELOG.md +3 -0
- data/CONTRIBUTING.md +125 -0
- data/Dangerfile +4 -0
- data/Gemfile +23 -0
- data/Gemfile.lock +162 -0
- data/LICENSE.md +22 -0
- data/README.md +279 -0
- data/RELEASING.md +60 -0
- data/Rakefile +18 -0
- data/benchmarks/check.rb +31 -0
- data/benchmarks/data/opensearch.org/links.txt +4270 -0
- data/benchmarks/data/opensearch.org/small.txt +100 -0
- data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_asc.png +0 -0
- data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_asc_disabled.png +0 -0
- data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_both.png +0 -0
- data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_desc.png +0 -0
- data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_desc_disabled.png +0 -0
- data/coverage/assets/0.12.3/application.css +1 -0
- data/coverage/assets/0.12.3/application.js +7 -0
- data/coverage/assets/0.12.3/colorbox/border.png +0 -0
- data/coverage/assets/0.12.3/colorbox/controls.png +0 -0
- data/coverage/assets/0.12.3/colorbox/loading.gif +0 -0
- data/coverage/assets/0.12.3/colorbox/loading_background.png +0 -0
- data/coverage/assets/0.12.3/favicon_green.png +0 -0
- data/coverage/assets/0.12.3/favicon_red.png +0 -0
- data/coverage/assets/0.12.3/favicon_yellow.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.12.3/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.12.3/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.12.3/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.12.3/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.12.3/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/assets/0.12.3/loading.gif +0 -0
- data/coverage/assets/0.12.3/magnify.png +0 -0
- data/coverage/index.html +14555 -0
- data/lib/ruby-link-checker/callbacks.rb +50 -0
- data/lib/ruby-link-checker/checker.rb +42 -0
- data/lib/ruby-link-checker/config.rb +41 -0
- data/lib/ruby-link-checker/errors/base_error.rb +8 -0
- data/lib/ruby-link-checker/errors/redirect_loop_error.rb +18 -0
- data/lib/ruby-link-checker/errors.rb +2 -0
- data/lib/ruby-link-checker/logger.rb +14 -0
- data/lib/ruby-link-checker/net/http/checker.rb +31 -0
- data/lib/ruby-link-checker/net/http/config.rb +35 -0
- data/lib/ruby-link-checker/net/http/result.rb +53 -0
- data/lib/ruby-link-checker/net/http.rb +3 -0
- data/lib/ruby-link-checker/result.rb +74 -0
- data/lib/ruby-link-checker/task.rb +20 -0
- data/lib/ruby-link-checker/tasks.rb +99 -0
- data/lib/ruby-link-checker/typhoeus/hydra/checker.rb +52 -0
- data/lib/ruby-link-checker/typhoeus/hydra/config.rb +35 -0
- data/lib/ruby-link-checker/typhoeus/hydra/result.rb +53 -0
- data/lib/ruby-link-checker/typhoeus/hydra.rb +3 -0
- data/lib/ruby-link-checker/version.rb +5 -0
- data/lib/ruby-link-checker.rb +13 -0
- data/lib/ruby_link_checker.rb +3 -0
- data/pkg/ruby-link-checker-0.1.0.gem +0 -0
- data/ruby-link-checker.gemspec +21 -0
- data/spec/fixtures/200.yml +65 -0
- data/spec/fixtures/301_200.yml +102 -0
- data/spec/fixtures/301_301.yml +114 -0
- data/spec/fixtures/301_400_301_200.yml +185 -0
- data/spec/fixtures/301_403.yml +78 -0
- data/spec/fixtures/404.yml +57 -0
- data/spec/fixtures/404_200.yml +89 -0
- data/spec/fixtures/404_404.yml +81 -0
- data/spec/fixtures/429_200.yml +135 -0
- data/spec/fixtures/429_429_200.yml +201 -0
- data/spec/ruby-link-checker/callbacks_spec.rb +43 -0
- data/spec/ruby-link-checker/checker_spec.rb +10 -0
- data/spec/ruby-link-checker/config_spec.rb +39 -0
- data/spec/ruby-link-checker/net/http/checker_spec.rb +61 -0
- data/spec/ruby-link-checker/typhoeus/hydra/checker_spec.rb +67 -0
- data/spec/ruby-link-checker/version_spec.rb +9 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/support/config.rb +8 -0
- data/spec/support/link_checker.rb +322 -0
- data/spec/support/vcr.rb +13 -0
- data/spec/support/with_result.rb +15 -0
- data/spec/support/with_url.rb +14 -0
- metadata +144 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: head
|
|
5
|
+
uri: https://www.example.org
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Accept-Encoding:
|
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
12
|
+
Accept:
|
|
13
|
+
- "*/*"
|
|
14
|
+
User-Agent:
|
|
15
|
+
- Ruby
|
|
16
|
+
Host:
|
|
17
|
+
- www.example.org
|
|
18
|
+
response:
|
|
19
|
+
status:
|
|
20
|
+
code: 404
|
|
21
|
+
message: Not Found
|
|
22
|
+
headers:
|
|
23
|
+
Cache-Control:
|
|
24
|
+
- private
|
|
25
|
+
Transfer-Encoding:
|
|
26
|
+
- chunked
|
|
27
|
+
Content-Type:
|
|
28
|
+
- text/html; charset=utf-8
|
|
29
|
+
Access-Control-Expose-Headers:
|
|
30
|
+
- Request-Context
|
|
31
|
+
Date:
|
|
32
|
+
- Wed, 29 Mar 2023 17:48:06 GMT
|
|
33
|
+
body:
|
|
34
|
+
encoding: UTF-8
|
|
35
|
+
string: ''
|
|
36
|
+
recorded_at: Wed, 29 Mar 2023 17:48:06 GMT
|
|
37
|
+
- request:
|
|
38
|
+
method: get
|
|
39
|
+
uri: https://www.example.org/
|
|
40
|
+
body:
|
|
41
|
+
encoding: US-ASCII
|
|
42
|
+
string: ''
|
|
43
|
+
headers:
|
|
44
|
+
Accept-Encoding:
|
|
45
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
46
|
+
Accept:
|
|
47
|
+
- "*/*"
|
|
48
|
+
User-Agent:
|
|
49
|
+
- Ruby
|
|
50
|
+
Host:
|
|
51
|
+
- www.example.org
|
|
52
|
+
response:
|
|
53
|
+
status:
|
|
54
|
+
code: 200
|
|
55
|
+
message: OK
|
|
56
|
+
headers:
|
|
57
|
+
Cache-Control:
|
|
58
|
+
- private
|
|
59
|
+
Transfer-Encoding:
|
|
60
|
+
- chunked
|
|
61
|
+
Content-Type:
|
|
62
|
+
- text/html; charset=utf-8
|
|
63
|
+
Vary:
|
|
64
|
+
- Accept-Encoding
|
|
65
|
+
Access-Control-Expose-Headers:
|
|
66
|
+
- Request-Context
|
|
67
|
+
Date:
|
|
68
|
+
- Wed, 29 Mar 2023 17:48:06 GMT
|
|
69
|
+
body:
|
|
70
|
+
encoding: UTF-8
|
|
71
|
+
string: "<!doctype html>\n<html>\n<head>\n <title>Example Domain</title>\n\n
|
|
72
|
+
\ <meta charset=\"utf-8\" />\n <meta http-equiv=\"Content-type\" content=\"text/html;
|
|
73
|
+
charset=utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width,
|
|
74
|
+
initial-scale=1\" />\n <style type=\"text/css\">\n body {\n background-color:
|
|
75
|
+
#f0f0f2;\n margin: 0;\n padding: 0;\n font-family: -apple-system,
|
|
76
|
+
system-ui, BlinkMacSystemFont, \"Segoe UI\", \"Open Sans\", \"Helvetica Neue\",
|
|
77
|
+
Helvetica, Arial, sans-serif;\n \n }\n div {\n width:
|
|
78
|
+
600px;\n margin: 5em auto;\n padding: 2em;\n background-color:
|
|
79
|
+
#fdfdff;\n border-radius: 0.5em;\n box-shadow: 2px 3px 7px 2px
|
|
80
|
+
rgba(0,0,0,0.02);\n }\n a:link, a:visited {\n color: #38488f;\n
|
|
81
|
+
\ text-decoration: none;\n }\n @media (max-width: 700px) {\n div
|
|
82
|
+
{\n margin: 0 auto;\n width: auto;\n }\n }\n
|
|
83
|
+
\ </style> \n</head>\n\n<body>\n<div>\n <h1>Example Domain</h1>\n
|
|
84
|
+
\ <p>This domain is for use in illustrative examples in documents. You may
|
|
85
|
+
use this\n domain in literature without prior coordination or asking for
|
|
86
|
+
permission.</p>\n <p><a href=\"https://www.iana.org/domains/example\">More
|
|
87
|
+
information...</a></p>\n</div>\n</body>\n</html>\n"
|
|
88
|
+
recorded_at: Wed, 29 Mar 2023 17:48:07 GMT
|
|
89
|
+
recorded_with: VCR 6.1.0
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: head
|
|
5
|
+
uri: https://www.example.org
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Accept-Encoding:
|
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
12
|
+
Accept:
|
|
13
|
+
- "*/*"
|
|
14
|
+
User-Agent:
|
|
15
|
+
- Ruby
|
|
16
|
+
Host:
|
|
17
|
+
- www.example.org
|
|
18
|
+
response:
|
|
19
|
+
status:
|
|
20
|
+
code: 404
|
|
21
|
+
message: Not Found
|
|
22
|
+
headers:
|
|
23
|
+
Transfer-Encoding:
|
|
24
|
+
- chunked
|
|
25
|
+
Content-Type:
|
|
26
|
+
- text/html; charset=utf-8
|
|
27
|
+
Date:
|
|
28
|
+
- Wed, 29 Mar 2023 17:48:07 GMT
|
|
29
|
+
body:
|
|
30
|
+
encoding: UTF-8
|
|
31
|
+
string: ''
|
|
32
|
+
recorded_at: Wed, 29 Mar 2023 17:48:07 GMT
|
|
33
|
+
- request:
|
|
34
|
+
method: get
|
|
35
|
+
uri: https://www.example.org/
|
|
36
|
+
body:
|
|
37
|
+
encoding: US-ASCII
|
|
38
|
+
string: ''
|
|
39
|
+
headers:
|
|
40
|
+
Accept-Encoding:
|
|
41
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
42
|
+
Accept:
|
|
43
|
+
- "*/*"
|
|
44
|
+
User-Agent:
|
|
45
|
+
- Ruby
|
|
46
|
+
Host:
|
|
47
|
+
- www.example.org
|
|
48
|
+
response:
|
|
49
|
+
status:
|
|
50
|
+
code: 404
|
|
51
|
+
message: Not Found
|
|
52
|
+
headers:
|
|
53
|
+
Cache-Control:
|
|
54
|
+
- private
|
|
55
|
+
Transfer-Encoding:
|
|
56
|
+
- chunked
|
|
57
|
+
Content-Type:
|
|
58
|
+
- text/html; charset=utf-8
|
|
59
|
+
Date:
|
|
60
|
+
- Wed, 29 Mar 2023 17:48:07 GMT
|
|
61
|
+
body:
|
|
62
|
+
encoding: UTF-8
|
|
63
|
+
string: "<!doctype html>\n<html>\n<head>\n <title>Example Domain</title>\n\n
|
|
64
|
+
\ <meta charset=\"utf-8\" />\n <meta http-equiv=\"Content-type\" content=\"text/html;
|
|
65
|
+
charset=utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width,
|
|
66
|
+
initial-scale=1\" />\n <style type=\"text/css\">\n body {\n background-color:
|
|
67
|
+
#f0f0f2;\n margin: 0;\n padding: 0;\n font-family: -apple-system,
|
|
68
|
+
system-ui, BlinkMacSystemFont, \"Segoe UI\", \"Open Sans\", \"Helvetica Neue\",
|
|
69
|
+
Helvetica, Arial, sans-serif;\n \n }\n div {\n width:
|
|
70
|
+
600px;\n margin: 5em auto;\n padding: 2em;\n background-color:
|
|
71
|
+
#fdfdff;\n border-radius: 0.5em;\n box-shadow: 2px 3px 7px 2px
|
|
72
|
+
rgba(0,0,0,0.02);\n }\n a:link, a:visited {\n color: #38488f;\n
|
|
73
|
+
\ text-decoration: none;\n }\n @media (max-width: 700px) {\n div
|
|
74
|
+
{\n margin: 0 auto;\n width: auto;\n }\n }\n
|
|
75
|
+
\ </style> \n</head>\n\n<body>\n<div>\n <h1>Example Domain</h1>\n
|
|
76
|
+
\ <p>This domain is for use in illustrative examples in documents. You may
|
|
77
|
+
use this\n domain in literature without prior coordination or asking for
|
|
78
|
+
permission.</p>\n <p><a href=\"https://www.iana.org/domains/example\">More
|
|
79
|
+
information...</a></p>\n</div>\n</body>\n</html>\n"
|
|
80
|
+
recorded_at: Wed, 29 Mar 2023 17:48:07 GMT
|
|
81
|
+
recorded_with: VCR 6.1.0
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: https://www.example.org/
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Index:
|
|
11
|
+
- 1
|
|
12
|
+
Accept-Encoding:
|
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
14
|
+
Accept:
|
|
15
|
+
- "*/*"
|
|
16
|
+
User-Agent:
|
|
17
|
+
- Ruby Link Checker/0.1.0
|
|
18
|
+
Host:
|
|
19
|
+
- www.example.org
|
|
20
|
+
response:
|
|
21
|
+
status:
|
|
22
|
+
code: 429
|
|
23
|
+
message: OK
|
|
24
|
+
headers:
|
|
25
|
+
Accept-Ranges:
|
|
26
|
+
- bytes
|
|
27
|
+
Age:
|
|
28
|
+
- '100798'
|
|
29
|
+
Cache-Control:
|
|
30
|
+
- max-age=604800
|
|
31
|
+
Content-Type:
|
|
32
|
+
- text/html; charset=UTF-8
|
|
33
|
+
Date:
|
|
34
|
+
- Sat, 01 Apr 2023 12:57:11 GMT
|
|
35
|
+
Etag:
|
|
36
|
+
- '"3147526947"'
|
|
37
|
+
Expires:
|
|
38
|
+
- Sat, 08 Apr 2023 12:57:11 GMT
|
|
39
|
+
Last-Modified:
|
|
40
|
+
- Thu, 17 Oct 2019 07:18:26 GMT
|
|
41
|
+
Server:
|
|
42
|
+
- ECS (nyb/1D2E)
|
|
43
|
+
Vary:
|
|
44
|
+
- Accept-Encoding
|
|
45
|
+
X-Cache:
|
|
46
|
+
- HIT
|
|
47
|
+
Content-Length:
|
|
48
|
+
- '648'
|
|
49
|
+
body:
|
|
50
|
+
encoding: UTF-8
|
|
51
|
+
string: "<!doctype html>\n<html>\n<head>\n <title>Example Domain</title>\n\n
|
|
52
|
+
\ <meta charset=\"utf-8\" />\n <meta http-equiv=\"Content-type\" content=\"text/html;
|
|
53
|
+
charset=utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width,
|
|
54
|
+
initial-scale=1\" />\n <style type=\"text/css\">\n body {\n background-color:
|
|
55
|
+
#f0f0f2;\n margin: 0;\n padding: 0;\n font-family: -apple-system,
|
|
56
|
+
system-ui, BlinkMacSystemFont, \"Segoe UI\", \"Open Sans\", \"Helvetica Neue\",
|
|
57
|
+
Helvetica, Arial, sans-serif;\n \n }\n div {\n width:
|
|
58
|
+
600px;\n margin: 5em auto;\n padding: 2em;\n background-color:
|
|
59
|
+
#fdfdff;\n border-radius: 0.5em;\n box-shadow: 2px 3px 7px 2px
|
|
60
|
+
rgba(0,0,0,0.02);\n }\n a:link, a:visited {\n color: #38488f;\n
|
|
61
|
+
\ text-decoration: none;\n }\n @media (max-width: 700px) {\n div
|
|
62
|
+
{\n margin: 0 auto;\n width: auto;\n }\n }\n
|
|
63
|
+
\ </style> \n</head>\n\n<body>\n<div>\n <h1>Example Domain</h1>\n
|
|
64
|
+
\ <p>This domain is for use in illustrative examples in documents. You may
|
|
65
|
+
use this\n domain in literature without prior coordination or asking for
|
|
66
|
+
permission.</p>\n <p><a href=\"https://www.iana.org/domains/example\">More
|
|
67
|
+
information...</a></p>\n</div>\n</body>\n</html>\n"
|
|
68
|
+
recorded_at: Sat, 01 Apr 2023 12:57:11 GMT
|
|
69
|
+
- request:
|
|
70
|
+
method: get
|
|
71
|
+
uri: https://www.example.org/
|
|
72
|
+
body:
|
|
73
|
+
encoding: US-ASCII
|
|
74
|
+
string: ''
|
|
75
|
+
headers:
|
|
76
|
+
Index:
|
|
77
|
+
- 2
|
|
78
|
+
Accept-Encoding:
|
|
79
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
80
|
+
Accept:
|
|
81
|
+
- "*/*"
|
|
82
|
+
User-Agent:
|
|
83
|
+
- Ruby Link Checker/0.1.0
|
|
84
|
+
Host:
|
|
85
|
+
- www.example.org
|
|
86
|
+
response:
|
|
87
|
+
status:
|
|
88
|
+
code: 200
|
|
89
|
+
message: OK
|
|
90
|
+
headers:
|
|
91
|
+
Accept-Ranges:
|
|
92
|
+
- bytes
|
|
93
|
+
Age:
|
|
94
|
+
- '100798'
|
|
95
|
+
Cache-Control:
|
|
96
|
+
- max-age=604800
|
|
97
|
+
Content-Type:
|
|
98
|
+
- text/html; charset=UTF-8
|
|
99
|
+
Date:
|
|
100
|
+
- Sat, 01 Apr 2023 12:57:11 GMT
|
|
101
|
+
Etag:
|
|
102
|
+
- '"3147526947"'
|
|
103
|
+
Expires:
|
|
104
|
+
- Sat, 08 Apr 2023 12:57:11 GMT
|
|
105
|
+
Last-Modified:
|
|
106
|
+
- Thu, 17 Oct 2019 07:18:26 GMT
|
|
107
|
+
Server:
|
|
108
|
+
- ECS (nyb/1D2E)
|
|
109
|
+
Vary:
|
|
110
|
+
- Accept-Encoding
|
|
111
|
+
X-Cache:
|
|
112
|
+
- HIT
|
|
113
|
+
Content-Length:
|
|
114
|
+
- '648'
|
|
115
|
+
body:
|
|
116
|
+
encoding: UTF-8
|
|
117
|
+
string: "<!doctype html>\n<html>\n<head>\n <title>Example Domain</title>\n\n
|
|
118
|
+
\ <meta charset=\"utf-8\" />\n <meta http-equiv=\"Content-type\" content=\"text/html;
|
|
119
|
+
charset=utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width,
|
|
120
|
+
initial-scale=1\" />\n <style type=\"text/css\">\n body {\n background-color:
|
|
121
|
+
#f0f0f2;\n margin: 0;\n padding: 0;\n font-family: -apple-system,
|
|
122
|
+
system-ui, BlinkMacSystemFont, \"Segoe UI\", \"Open Sans\", \"Helvetica Neue\",
|
|
123
|
+
Helvetica, Arial, sans-serif;\n \n }\n div {\n width:
|
|
124
|
+
600px;\n margin: 5em auto;\n padding: 2em;\n background-color:
|
|
125
|
+
#fdfdff;\n border-radius: 0.5em;\n box-shadow: 2px 3px 7px 2px
|
|
126
|
+
rgba(0,0,0,0.02);\n }\n a:link, a:visited {\n color: #38488f;\n
|
|
127
|
+
\ text-decoration: none;\n }\n @media (max-width: 700px) {\n div
|
|
128
|
+
{\n margin: 0 auto;\n width: auto;\n }\n }\n
|
|
129
|
+
\ </style> \n</head>\n\n<body>\n<div>\n <h1>Example Domain</h1>\n
|
|
130
|
+
\ <p>This domain is for use in illustrative examples in documents. You may
|
|
131
|
+
use this\n domain in literature without prior coordination or asking for
|
|
132
|
+
permission.</p>\n <p><a href=\"https://www.iana.org/domains/example\">More
|
|
133
|
+
information...</a></p>\n</div>\n</body>\n</html>\n"
|
|
134
|
+
recorded_at: Sat, 01 Apr 2023 12:57:11 GMT
|
|
135
|
+
recorded_with: VCR 6.1.0
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: head
|
|
5
|
+
uri: https://www.example.org/
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Index:
|
|
11
|
+
- 1
|
|
12
|
+
Accept-Encoding:
|
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
14
|
+
Accept:
|
|
15
|
+
- "*/*"
|
|
16
|
+
User-Agent:
|
|
17
|
+
- Ruby Link Checker/0.1.0
|
|
18
|
+
Host:
|
|
19
|
+
- www.example.org
|
|
20
|
+
response:
|
|
21
|
+
status:
|
|
22
|
+
code: 429
|
|
23
|
+
message: OK
|
|
24
|
+
headers:
|
|
25
|
+
Accept-Ranges:
|
|
26
|
+
- bytes
|
|
27
|
+
Age:
|
|
28
|
+
- '100798'
|
|
29
|
+
Cache-Control:
|
|
30
|
+
- max-age=604800
|
|
31
|
+
Content-Type:
|
|
32
|
+
- text/html; charset=UTF-8
|
|
33
|
+
Date:
|
|
34
|
+
- Sat, 01 Apr 2023 12:57:11 GMT
|
|
35
|
+
Etag:
|
|
36
|
+
- '"3147526947"'
|
|
37
|
+
Expires:
|
|
38
|
+
- Sat, 08 Apr 2023 12:57:11 GMT
|
|
39
|
+
Last-Modified:
|
|
40
|
+
- Thu, 17 Oct 2019 07:18:26 GMT
|
|
41
|
+
Server:
|
|
42
|
+
- ECS (nyb/1D2E)
|
|
43
|
+
Vary:
|
|
44
|
+
- Accept-Encoding
|
|
45
|
+
X-Cache:
|
|
46
|
+
- HIT
|
|
47
|
+
Content-Length:
|
|
48
|
+
- '648'
|
|
49
|
+
body:
|
|
50
|
+
encoding: UTF-8
|
|
51
|
+
string: "<!doctype html>\n<html>\n<head>\n <title>Example Domain</title>\n\n
|
|
52
|
+
\ <meta charset=\"utf-8\" />\n <meta http-equiv=\"Content-type\" content=\"text/html;
|
|
53
|
+
charset=utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width,
|
|
54
|
+
initial-scale=1\" />\n <style type=\"text/css\">\n body {\n background-color:
|
|
55
|
+
#f0f0f2;\n margin: 0;\n padding: 0;\n font-family: -apple-system,
|
|
56
|
+
system-ui, BlinkMacSystemFont, \"Segoe UI\", \"Open Sans\", \"Helvetica Neue\",
|
|
57
|
+
Helvetica, Arial, sans-serif;\n \n }\n div {\n width:
|
|
58
|
+
600px;\n margin: 5em auto;\n padding: 2em;\n background-color:
|
|
59
|
+
#fdfdff;\n border-radius: 0.5em;\n box-shadow: 2px 3px 7px 2px
|
|
60
|
+
rgba(0,0,0,0.02);\n }\n a:link, a:visited {\n color: #38488f;\n
|
|
61
|
+
\ text-decoration: none;\n }\n @media (max-width: 700px) {\n div
|
|
62
|
+
{\n margin: 0 auto;\n width: auto;\n }\n }\n
|
|
63
|
+
\ </style> \n</head>\n\n<body>\n<div>\n <h1>Example Domain</h1>\n
|
|
64
|
+
\ <p>This domain is for use in illustrative examples in documents. You may
|
|
65
|
+
use this\n domain in literature without prior coordination or asking for
|
|
66
|
+
permission.</p>\n <p><a href=\"https://www.iana.org/domains/example\">More
|
|
67
|
+
information...</a></p>\n</div>\n</body>\n</html>\n"
|
|
68
|
+
recorded_at: Sat, 01 Apr 2023 12:57:11 GMT
|
|
69
|
+
- request:
|
|
70
|
+
method: head
|
|
71
|
+
uri: https://www.example.org/
|
|
72
|
+
body:
|
|
73
|
+
encoding: US-ASCII
|
|
74
|
+
string: ''
|
|
75
|
+
headers:
|
|
76
|
+
Index:
|
|
77
|
+
- 2
|
|
78
|
+
Accept-Encoding:
|
|
79
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
80
|
+
Accept:
|
|
81
|
+
- "*/*"
|
|
82
|
+
User-Agent:
|
|
83
|
+
- Ruby Link Checker/0.1.0
|
|
84
|
+
Host:
|
|
85
|
+
- www.example.org
|
|
86
|
+
response:
|
|
87
|
+
status:
|
|
88
|
+
code: 429
|
|
89
|
+
message: OK
|
|
90
|
+
headers:
|
|
91
|
+
Accept-Ranges:
|
|
92
|
+
- bytes
|
|
93
|
+
Age:
|
|
94
|
+
- '100798'
|
|
95
|
+
Cache-Control:
|
|
96
|
+
- max-age=604800
|
|
97
|
+
Content-Type:
|
|
98
|
+
- text/html; charset=UTF-8
|
|
99
|
+
Date:
|
|
100
|
+
- Sat, 01 Apr 2023 12:57:11 GMT
|
|
101
|
+
Etag:
|
|
102
|
+
- '"3147526947"'
|
|
103
|
+
Expires:
|
|
104
|
+
- Sat, 08 Apr 2023 12:57:11 GMT
|
|
105
|
+
Last-Modified:
|
|
106
|
+
- Thu, 17 Oct 2019 07:18:26 GMT
|
|
107
|
+
Server:
|
|
108
|
+
- ECS (nyb/1D2E)
|
|
109
|
+
Vary:
|
|
110
|
+
- Accept-Encoding
|
|
111
|
+
X-Cache:
|
|
112
|
+
- HIT
|
|
113
|
+
Content-Length:
|
|
114
|
+
- '648'
|
|
115
|
+
body:
|
|
116
|
+
encoding: UTF-8
|
|
117
|
+
string: "<!doctype html>\n<html>\n<head>\n <title>Example Domain</title>\n\n
|
|
118
|
+
\ <meta charset=\"utf-8\" />\n <meta http-equiv=\"Content-type\" content=\"text/html;
|
|
119
|
+
charset=utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width,
|
|
120
|
+
initial-scale=1\" />\n <style type=\"text/css\">\n body {\n background-color:
|
|
121
|
+
#f0f0f2;\n margin: 0;\n padding: 0;\n font-family: -apple-system,
|
|
122
|
+
system-ui, BlinkMacSystemFont, \"Segoe UI\", \"Open Sans\", \"Helvetica Neue\",
|
|
123
|
+
Helvetica, Arial, sans-serif;\n \n }\n div {\n width:
|
|
124
|
+
600px;\n margin: 5em auto;\n padding: 2em;\n background-color:
|
|
125
|
+
#fdfdff;\n border-radius: 0.5em;\n box-shadow: 2px 3px 7px 2px
|
|
126
|
+
rgba(0,0,0,0.02);\n }\n a:link, a:visited {\n color: #38488f;\n
|
|
127
|
+
\ text-decoration: none;\n }\n @media (max-width: 700px) {\n div
|
|
128
|
+
{\n margin: 0 auto;\n width: auto;\n }\n }\n
|
|
129
|
+
\ </style> \n</head>\n\n<body>\n<div>\n <h1>Example Domain</h1>\n
|
|
130
|
+
\ <p>This domain is for use in illustrative examples in documents. You may
|
|
131
|
+
use this\n domain in literature without prior coordination or asking for
|
|
132
|
+
permission.</p>\n <p><a href=\"https://www.iana.org/domains/example\">More
|
|
133
|
+
information...</a></p>\n</div>\n</body>\n</html>\n"
|
|
134
|
+
recorded_at: Sat, 01 Apr 2023 12:57:11 GMT
|
|
135
|
+
- request:
|
|
136
|
+
method: get
|
|
137
|
+
uri: https://www.example.org/
|
|
138
|
+
body:
|
|
139
|
+
encoding: US-ASCII
|
|
140
|
+
string: ''
|
|
141
|
+
headers:
|
|
142
|
+
Index:
|
|
143
|
+
- 3
|
|
144
|
+
Accept-Encoding:
|
|
145
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
146
|
+
Accept:
|
|
147
|
+
- "*/*"
|
|
148
|
+
User-Agent:
|
|
149
|
+
- Ruby Link Checker/0.1.0
|
|
150
|
+
Host:
|
|
151
|
+
- www.example.org
|
|
152
|
+
response:
|
|
153
|
+
status:
|
|
154
|
+
code: 200
|
|
155
|
+
message: OK
|
|
156
|
+
headers:
|
|
157
|
+
Accept-Ranges:
|
|
158
|
+
- bytes
|
|
159
|
+
Age:
|
|
160
|
+
- '100798'
|
|
161
|
+
Cache-Control:
|
|
162
|
+
- max-age=604800
|
|
163
|
+
Content-Type:
|
|
164
|
+
- text/html; charset=UTF-8
|
|
165
|
+
Date:
|
|
166
|
+
- Sat, 01 Apr 2023 12:57:11 GMT
|
|
167
|
+
Etag:
|
|
168
|
+
- '"3147526947"'
|
|
169
|
+
Expires:
|
|
170
|
+
- Sat, 08 Apr 2023 12:57:11 GMT
|
|
171
|
+
Last-Modified:
|
|
172
|
+
- Thu, 17 Oct 2019 07:18:26 GMT
|
|
173
|
+
Server:
|
|
174
|
+
- ECS (nyb/1D2E)
|
|
175
|
+
Vary:
|
|
176
|
+
- Accept-Encoding
|
|
177
|
+
X-Cache:
|
|
178
|
+
- HIT
|
|
179
|
+
Content-Length:
|
|
180
|
+
- '648'
|
|
181
|
+
body:
|
|
182
|
+
encoding: UTF-8
|
|
183
|
+
string: "<!doctype html>\n<html>\n<head>\n <title>Example Domain</title>\n\n
|
|
184
|
+
\ <meta charset=\"utf-8\" />\n <meta http-equiv=\"Content-type\" content=\"text/html;
|
|
185
|
+
charset=utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width,
|
|
186
|
+
initial-scale=1\" />\n <style type=\"text/css\">\n body {\n background-color:
|
|
187
|
+
#f0f0f2;\n margin: 0;\n padding: 0;\n font-family: -apple-system,
|
|
188
|
+
system-ui, BlinkMacSystemFont, \"Segoe UI\", \"Open Sans\", \"Helvetica Neue\",
|
|
189
|
+
Helvetica, Arial, sans-serif;\n \n }\n div {\n width:
|
|
190
|
+
600px;\n margin: 5em auto;\n padding: 2em;\n background-color:
|
|
191
|
+
#fdfdff;\n border-radius: 0.5em;\n box-shadow: 2px 3px 7px 2px
|
|
192
|
+
rgba(0,0,0,0.02);\n }\n a:link, a:visited {\n color: #38488f;\n
|
|
193
|
+
\ text-decoration: none;\n }\n @media (max-width: 700px) {\n div
|
|
194
|
+
{\n margin: 0 auto;\n width: auto;\n }\n }\n
|
|
195
|
+
\ </style> \n</head>\n\n<body>\n<div>\n <h1>Example Domain</h1>\n
|
|
196
|
+
\ <p>This domain is for use in illustrative examples in documents. You may
|
|
197
|
+
use this\n domain in literature without prior coordination or asking for
|
|
198
|
+
permission.</p>\n <p><a href=\"https://www.iana.org/domains/example\">More
|
|
199
|
+
information...</a></p>\n</div>\n</body>\n</html>\n"
|
|
200
|
+
recorded_at: Sat, 01 Apr 2023 12:57:11 GMT
|
|
201
|
+
recorded_with: VCR 6.1.0
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe LinkChecker::Callbacks do
|
|
6
|
+
subject do
|
|
7
|
+
Class.new do
|
|
8
|
+
include LinkChecker::Callbacks
|
|
9
|
+
end.new
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context 'one callback' do
|
|
13
|
+
before do
|
|
14
|
+
allow(subject).to receive(:called!)
|
|
15
|
+
subject.on :foo do |data|
|
|
16
|
+
subject.called! data
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'invokes callback' do
|
|
21
|
+
2.times { subject.send(:callback, :foo, :foo) }
|
|
22
|
+
2.times { subject.send(:callback, :bar, :bar) }
|
|
23
|
+
expect(subject).to have_received(:called!).with(:foo).twice
|
|
24
|
+
expect(subject).not_to have_received(:called!).with(:bar)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context 'multiple callbacks' do
|
|
29
|
+
before do
|
|
30
|
+
allow(subject).to receive(:called!)
|
|
31
|
+
subject.on :foo, :bar do |data|
|
|
32
|
+
subject.called! data
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'invokes both callbacks' do
|
|
37
|
+
2.times { subject.send(:callback, :foo, :foo) }
|
|
38
|
+
subject.send(:callback, :bar, :bar)
|
|
39
|
+
expect(subject).to have_received(:called!).with(:foo).twice
|
|
40
|
+
expect(subject).to have_received(:called!).with(:bar)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe LinkChecker::Checker do
|
|
5
|
+
context 'config' do
|
|
6
|
+
it 'requires at least one method' do
|
|
7
|
+
expect { LinkChecker::Checker.new(methods: []) }.to raise_error ArgumentError, 'Missing methods.'
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
describe LinkChecker::Config do
|
|
5
|
+
describe '#configure' do
|
|
6
|
+
context 'methods' do
|
|
7
|
+
before do
|
|
8
|
+
LinkChecker.configure do |config|
|
|
9
|
+
config.methods = %w[GET]
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'sets methods' do
|
|
14
|
+
expect(LinkChecker.config.methods).to eq %w[GET]
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
context 'retries' do
|
|
19
|
+
it 'requires a positive integer' do
|
|
20
|
+
expect { LinkChecker.config.retries = -1 }.to raise_error ArgumentError, 'Invalid number of retries: -1'
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe 'defaults' do
|
|
26
|
+
it 'sets methods' do
|
|
27
|
+
expect(LinkChecker.config.methods).to eq %w[HEAD GET]
|
|
28
|
+
end
|
|
29
|
+
it 'sets user agent' do
|
|
30
|
+
expect(LinkChecker.config.user_agent).to eq "Ruby Link Checker/#{LinkChecker::VERSION}"
|
|
31
|
+
end
|
|
32
|
+
it 'does not set logger' do
|
|
33
|
+
expect(LinkChecker.config.logger).to be nil
|
|
34
|
+
end
|
|
35
|
+
it 'sets retries' do
|
|
36
|
+
expect(LinkChecker.config.retries).to eq 0
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe LinkChecker::Net::HTTP::Checker do
|
|
6
|
+
before :all do
|
|
7
|
+
VCR.configure do |config|
|
|
8
|
+
config.hook_into :webmock
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
after do
|
|
13
|
+
LinkChecker::Net::HTTP::Config.reset
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it_behaves_like 'a link checker'
|
|
17
|
+
|
|
18
|
+
context 'with timeout options', vcr: { cassette_name: '200' } do
|
|
19
|
+
before do
|
|
20
|
+
LinkChecker::Net::HTTP.configure do |config|
|
|
21
|
+
config.read_timeout = 5
|
|
22
|
+
config.open_timeout = 10
|
|
23
|
+
end
|
|
24
|
+
expect_any_instance_of(Net::HTTP).to receive(:read_timeout=).with(5)
|
|
25
|
+
expect_any_instance_of(Net::HTTP).to receive(:open_timeout=).with(10)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
include_context 'with url'
|
|
29
|
+
|
|
30
|
+
it 'creates requests with a default timeout' do
|
|
31
|
+
expect(result.success?).to be true
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
context 'timeout' do
|
|
36
|
+
before do
|
|
37
|
+
stub_request(:get, 'https://www.example.org/').to_timeout
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
include_context 'with url'
|
|
41
|
+
|
|
42
|
+
around do |example|
|
|
43
|
+
VCR.turned_off { example.run }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it 'times out' do
|
|
47
|
+
expect(result.success?).to be false
|
|
48
|
+
expect(result.error?).to be true
|
|
49
|
+
expect(result.to_s).to eq 'GET https://www.example.org: ERROR (Net::OpenTimeout)'
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context 'with metadata' do
|
|
53
|
+
let(:options) { { foo: :bar } }
|
|
54
|
+
|
|
55
|
+
it 'times out' do
|
|
56
|
+
expect(result.error?).to be true
|
|
57
|
+
expect(result.options).to eq(foo: :bar)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|