ndd-url_checker 0.2.1 → 0.3.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/.travis.yml +2 -1
- data/Gemfile.lock +57 -44
- data/README.md +5 -2
- data/VERSION +1 -1
- data/lib/ndd/url_checker.rb +2 -0
- data/lib/ndd/url_checker/blocking_url_checker.rb +7 -4
- data/lib/ndd/url_checker/forked_url_checker.rb +4 -2
- data/lib/ndd/url_checker/reporting_url_checker.csv.erb +2 -2
- data/lib/ndd/url_checker/reporting_url_checker.html.erb +171 -80
- data/lib/ndd/url_checker/reporting_url_checker.json.erb +16 -9
- data/lib/ndd/url_checker/reporting_url_checker.rb +22 -11
- data/lib/ndd/url_checker/status.rb +1 -1
- data/lib/ndd/url_checker/status_decorator.rb +64 -0
- data/ndd-url_checker.gemspec +6 -4
- data/spec/ndd/url_checker/abstract_url_checker_spec.rb +1 -1
- data/spec/ndd/url_checker/blocking_url_checker_spec.rb +1 -1
- data/spec/ndd/url_checker/forked_url_checker_spec.rb +1 -1
- data/spec/ndd/url_checker/parallel_url_checker_spec.rb +1 -1
- data/spec/ndd/url_checker/reporting_url_checker/custom.txt.erb +2 -2
- data/spec/ndd/url_checker/reporting_url_checker/multiple_urls.csv +5 -3
- data/spec/ndd/url_checker/reporting_url_checker/multiple_urls.html +227 -92
- data/spec/ndd/url_checker/reporting_url_checker/multiple_urls.json +29 -10
- data/spec/ndd/url_checker/reporting_url_checker/multiple_urls.txt +12 -2
- data/spec/ndd/url_checker/reporting_url_checker/single_url.csv +1 -1
- data/spec/ndd/url_checker/reporting_url_checker/single_url.html +163 -78
- data/spec/ndd/url_checker/reporting_url_checker/single_url.json +14 -7
- data/spec/ndd/url_checker/reporting_url_checker_spec.rb +29 -12
- data/spec/ndd/url_checker/status_decorator_spec.rb +208 -0
- data/spec/ndd/url_checker/status_spec.rb +10 -10
- data/spec/ndd/url_checker/threaded_url_checker_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -3
- data/spec/support/multiple_url_checker_spec.rb +4 -4
- data/spec/support/single_url_checker_spec.rb +74 -21
- metadata +5 -3
@@ -1,30 +1,49 @@
|
|
1
1
|
{
|
2
2
|
"benchmark": {
|
3
|
-
"
|
4
|
-
"
|
5
|
-
"
|
6
|
-
|
7
|
-
|
8
|
-
"
|
3
|
+
"total_duration": 123.456,
|
4
|
+
"average_duration": 123.456,
|
5
|
+
"average_throughput": 123.456
|
6
|
+
},
|
7
|
+
"statistics": {
|
8
|
+
"count": 5,
|
9
|
+
"valid_count": 2,
|
10
|
+
"direct_count": 1,
|
11
|
+
"redirected_count": 1,
|
12
|
+
"invalid_count": 3,
|
13
|
+
"failed_count": 1,
|
14
|
+
"too_many_redirects_count": 1,
|
15
|
+
"unknown_host_count": 1
|
9
16
|
},
|
10
17
|
"results": [
|
11
18
|
{
|
12
19
|
"index": 1,
|
13
20
|
"url": "http://www.google.com",
|
14
|
-
"code": "
|
15
|
-
"
|
21
|
+
"code": "redirected",
|
22
|
+
"details": ""
|
16
23
|
},
|
17
24
|
{
|
18
25
|
"index": 2,
|
19
26
|
"url": "http://www.google.de",
|
20
27
|
"code": "failed",
|
21
|
-
"
|
28
|
+
"details": "some error"
|
22
29
|
},
|
23
30
|
{
|
24
31
|
"index": 3,
|
32
|
+
"url": "http://www.google.es",
|
33
|
+
"code": "too_many_redirects",
|
34
|
+
"details": ""
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"index": 4,
|
25
38
|
"url": "http://www.google.fr",
|
26
39
|
"code": "direct",
|
27
|
-
"
|
40
|
+
"details": ""
|
41
|
+
},
|
42
|
+
{
|
43
|
+
"index": 5,
|
44
|
+
"url": "http://www.google.it",
|
45
|
+
"code": "unknown_host",
|
46
|
+
"details": ""
|
28
47
|
}
|
29
48
|
]
|
30
49
|
}
|
@@ -1,9 +1,9 @@
|
|
1
|
-
count =
|
1
|
+
count = 5
|
2
2
|
|
3
3
|
- index = 1
|
4
4
|
- uri = http://www.google.com
|
5
5
|
- valid = true
|
6
|
-
- code =
|
6
|
+
- code = redirected
|
7
7
|
|
8
8
|
- index = 2
|
9
9
|
- uri = http://www.google.de
|
@@ -11,6 +11,16 @@ count = 3
|
|
11
11
|
- code = failed
|
12
12
|
|
13
13
|
- index = 3
|
14
|
+
- uri = http://www.google.es
|
15
|
+
- valid = false
|
16
|
+
- code = too_many_redirects
|
17
|
+
|
18
|
+
- index = 4
|
14
19
|
- uri = http://www.google.fr
|
15
20
|
- valid = true
|
16
21
|
- code = direct
|
22
|
+
|
23
|
+
- index = 5
|
24
|
+
- uri = http://www.google.it
|
25
|
+
- valid = false
|
26
|
+
- code = unknown_host
|
@@ -1,2 +1,2 @@
|
|
1
|
-
Index,URL,Result,Code,
|
1
|
+
Index,URL,Result,Code,Details
|
2
2
|
1,http://www.google.fr,valid,direct,
|
@@ -2,96 +2,181 @@
|
|
2
2
|
<html lang="en">
|
3
3
|
|
4
4
|
<head>
|
5
|
-
<meta charset="UTF-8"
|
6
|
-
|
7
|
-
<
|
8
|
-
|
9
|
-
|
5
|
+
<meta charset="UTF-8" />
|
6
|
+
|
7
|
+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
|
8
|
+
<style type="text/css">
|
9
|
+
.popover-title {
|
10
|
+
font-weight: bold;
|
11
|
+
}
|
12
|
+
|
13
|
+
.popover-content em {
|
14
|
+
font-style: normal;
|
15
|
+
font-weight: bold;
|
16
|
+
}
|
17
|
+
|
18
|
+
.popover-content ol {
|
19
|
+
margin-left: -20px;
|
10
20
|
}
|
11
21
|
</style>
|
12
22
|
|
13
|
-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.
|
14
|
-
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.
|
23
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
|
24
|
+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
|
15
25
|
<script language="JavaScript">
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
26
|
+
if (!window.ndd_url_checker) {
|
27
|
+
window.ndd_url_checker = {};
|
28
|
+
}
|
29
|
+
|
30
|
+
ndd_url_checker.STATES = ['direct', 'redirected', 'failed', 'too-many-redirects', 'unknown-host'];
|
31
|
+
|
32
|
+
ndd_url_checker.displayStates = function () {
|
33
|
+
var displayStates = {};
|
34
|
+
$.each(ndd_url_checker.STATES, function (_, state) {
|
35
|
+
var checked = $('.display-' + state).is(':checked');
|
36
|
+
displayStates[state] = checked;
|
24
37
|
});
|
38
|
+
return displayStates;
|
39
|
+
}
|
40
|
+
|
41
|
+
ndd_url_checker.filter = function () {
|
42
|
+
var displayStates = ndd_url_checker.displayStates();
|
43
|
+
|
44
|
+
$.each(displayStates, function (state, display) {
|
45
|
+
$('.result-' + state).toggle(display);
|
46
|
+
});
|
47
|
+
}
|
48
|
+
|
49
|
+
$(document).ready(function () {
|
50
|
+
// show or hide results depending on their state
|
51
|
+
$.each(ndd_url_checker.STATES, function (_, state) {
|
52
|
+
$('.display-' + state).change(function () {
|
53
|
+
ndd_url_checker.filter();
|
54
|
+
});
|
55
|
+
});
|
56
|
+
|
57
|
+
// activate all tooltips
|
58
|
+
$('[data-toggle="popover"]')
|
59
|
+
.popover()
|
60
|
+
.click(function (e) {
|
61
|
+
e.preventDefault();
|
62
|
+
});
|
25
63
|
});
|
26
64
|
</script>
|
27
65
|
</head>
|
28
66
|
|
67
|
+
|
29
68
|
<body>
|
30
69
|
|
31
|
-
<
|
32
|
-
|
33
|
-
<
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
</
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
</
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
<
|
65
|
-
|
66
|
-
|
67
|
-
</
|
68
|
-
<
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
</
|
70
|
+
<div class="container">
|
71
|
+
|
72
|
+
<div class="page-header">
|
73
|
+
<h1>
|
74
|
+
<span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span>
|
75
|
+
URL Checker Report
|
76
|
+
</h1>
|
77
|
+
</div>
|
78
|
+
|
79
|
+
|
80
|
+
<div class="row">
|
81
|
+
<div class="col-md-4">
|
82
|
+
<dl class="page-info dl-horizontal">
|
83
|
+
<dt>Number of URLs</dt>
|
84
|
+
<dd>1</dd>
|
85
|
+
<dt>Duration</dt>
|
86
|
+
<dd>123.456 s</dd>
|
87
|
+
<dt>Average duration</dt>
|
88
|
+
<dd>123.456 s/URL</dd>
|
89
|
+
<dt>Average throughput</dt>
|
90
|
+
<dd>123.456 URL/s</dd>
|
91
|
+
</dl>
|
92
|
+
</div>
|
93
|
+
<div class="col-md-4">
|
94
|
+
<dl class="page-info dl-horizontal">
|
95
|
+
<dt>Valid URLS</dt>
|
96
|
+
<dd>1</dd>
|
97
|
+
<dt>direct</dt>
|
98
|
+
<dd>1</dd>
|
99
|
+
<dt>redirected</dt>
|
100
|
+
<dd>0</dd>
|
101
|
+
</dl>
|
102
|
+
</div>
|
103
|
+
<div class="col-md-4">
|
104
|
+
<dl class="page-info dl-horizontal">
|
105
|
+
<dt>Invalid URLS</dt>
|
106
|
+
<dd>0</dd>
|
107
|
+
<dt>failed</dt>
|
108
|
+
<dd>0</dd>
|
109
|
+
<dt>too many redirects</dt>
|
110
|
+
<dd>0</dd>
|
111
|
+
<dt>unknown host</dt>
|
112
|
+
<dd>0</dd>
|
113
|
+
</dl>
|
114
|
+
</div>
|
115
|
+
</div>
|
116
|
+
<hr />
|
117
|
+
|
118
|
+
|
119
|
+
<div class="row page-controls hidden-print">
|
120
|
+
<div class="col-md-6">
|
121
|
+
<span>Valid URLs:</span>
|
74
122
|
|
75
|
-
<
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
123
|
+
<div class="btn-group page-display" data-toggle="buttons">
|
124
|
+
<label class="btn btn-default active">
|
125
|
+
<input type="checkbox" autocomplete="off" class="display-direct" checked="true" />
|
126
|
+
Direct (1)
|
127
|
+
</label>
|
128
|
+
<label class="btn btn-default active">
|
129
|
+
<input type="checkbox" autocomplete="off" class="display-redirected" checked="true" />
|
130
|
+
Redirected (0)
|
131
|
+
</label>
|
132
|
+
</div>
|
133
|
+
</div>
|
134
|
+
<div class="col-md-6">
|
135
|
+
<span>Invalid URLs:</span>
|
136
|
+
|
137
|
+
<div class="btn-group page-display" data-toggle="buttons">
|
138
|
+
<label class="btn btn-default active">
|
139
|
+
<input type="checkbox" autocomplete="off" class="display-failed" checked="true" />
|
140
|
+
Failed (0)
|
141
|
+
</label>
|
142
|
+
<label class="btn btn-default active">
|
143
|
+
<input type="checkbox" autocomplete="off" class="display-too-many-redirects" checked="true" />
|
144
|
+
Too many redirects (0)
|
145
|
+
</label>
|
146
|
+
<label class="btn btn-default active">
|
147
|
+
<input type="checkbox" autocomplete="off" class="display-unknown-host" checked="true" />
|
148
|
+
Unknown host (0)
|
149
|
+
</label>
|
150
|
+
</div>
|
151
|
+
</div>
|
152
|
+
</div>
|
153
|
+
<hr />
|
154
|
+
|
155
|
+
|
156
|
+
<table id="results" class="table table-condensed table-hover">
|
157
|
+
<thead>
|
158
|
+
<tr>
|
159
|
+
<th>#</th>
|
160
|
+
<th>URL</th>
|
161
|
+
<th>Code</th>
|
162
|
+
<th>Details</th>
|
163
|
+
</tr>
|
164
|
+
</thead>
|
165
|
+
<tbody>
|
166
|
+
|
167
|
+
<tr class="result result-direct ">
|
168
|
+
<td>1</td>
|
169
|
+
<td><a href="http://www.google.fr" target="_blank">http://www.google.fr</a></td>
|
170
|
+
<td>direct</td>
|
171
|
+
<td></td>
|
172
|
+
<td>
|
173
|
+
</td>
|
174
|
+
</tr>
|
175
|
+
|
176
|
+
</tbody>
|
177
|
+
</table>
|
178
|
+
|
179
|
+
</div>
|
95
180
|
|
96
181
|
</body>
|
97
182
|
</html>
|
@@ -1,18 +1,25 @@
|
|
1
1
|
{
|
2
2
|
"benchmark": {
|
3
|
-
"
|
4
|
-
"
|
5
|
-
"
|
6
|
-
|
7
|
-
|
8
|
-
"
|
3
|
+
"total_duration": 123.456,
|
4
|
+
"average_duration": 123.456,
|
5
|
+
"average_throughput": 123.456
|
6
|
+
},
|
7
|
+
"statistics": {
|
8
|
+
"count": 1,
|
9
|
+
"valid_count": 1,
|
10
|
+
"direct_count": 1,
|
11
|
+
"redirected_count": 0,
|
12
|
+
"invalid_count": 0,
|
13
|
+
"failed_count": 0,
|
14
|
+
"too_many_redirects_count": 0,
|
15
|
+
"unknown_host_count": 0
|
9
16
|
},
|
10
17
|
"results": [
|
11
18
|
{
|
12
19
|
"index": 1,
|
13
20
|
"url": "http://www.google.fr",
|
14
21
|
"code": "direct",
|
15
|
-
"
|
22
|
+
"details": ""
|
16
23
|
}
|
17
24
|
]
|
18
25
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe NDD::UrlChecker::ReportingUrlChecker do
|
3
|
+
RSpec.describe NDD::UrlChecker::ReportingUrlChecker do
|
4
4
|
|
5
5
|
before(:all) do
|
6
6
|
# Logging.logger.root.level = :debug
|
@@ -26,19 +26,19 @@ describe NDD::UrlChecker::ReportingUrlChecker do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'creates an CSV report' do
|
29
|
-
actual_report =
|
29
|
+
actual_report = actual_report_csv(@report_checker, :csv, 'single_url.csv')
|
30
30
|
expected_report = expected_report('single_url.csv')
|
31
31
|
expect(actual_report).to eq expected_report
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'creates an HTML report' do
|
35
|
-
actual_report =
|
35
|
+
actual_report = actual_report_html(@report_checker, :html, 'single_url.html')
|
36
36
|
expected_report = expected_report('single_url.html')
|
37
37
|
expect(actual_report).to eq expected_report
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'creates an JSON report' do
|
41
|
-
actual_report =
|
41
|
+
actual_report = actual_report_json(@report_checker, :json, 'single_url.json')
|
42
42
|
expected_report = expected_report('single_url.json')
|
43
43
|
expect(actual_report).to eq expected_report
|
44
44
|
end
|
@@ -55,8 +55,10 @@ describe NDD::UrlChecker::ReportingUrlChecker do
|
|
55
55
|
before(:each) do
|
56
56
|
expected_results = [
|
57
57
|
NDD::UrlChecker::Status.new('http://www.google.fr').direct,
|
58
|
-
NDD::UrlChecker::Status.new('http://www.google.com').
|
59
|
-
NDD::UrlChecker::Status.new('http://www.google.de').failed('some error')
|
58
|
+
NDD::UrlChecker::Status.new('http://www.google.com').redirected('http://www.google.fr'),
|
59
|
+
NDD::UrlChecker::Status.new('http://www.google.de').failed(StandardError.new('some error')),
|
60
|
+
NDD::UrlChecker::Status.new('http://www.google.es').redirected('http://www.google.fr').too_many_redirects,
|
61
|
+
NDD::UrlChecker::Status.new('http://www.google.it').unknown_host
|
60
62
|
]
|
61
63
|
checker = double
|
62
64
|
expect(checker).to receive(:check).and_return(expected_results)
|
@@ -66,19 +68,19 @@ describe NDD::UrlChecker::ReportingUrlChecker do
|
|
66
68
|
end
|
67
69
|
|
68
70
|
it 'creates an CSV report' do
|
69
|
-
actual_report =
|
71
|
+
actual_report = actual_report_csv(@report_checker, :csv, 'multiple_urls.csv')
|
70
72
|
expected_report = expected_report('multiple_urls.csv')
|
71
73
|
expect(actual_report).to eq expected_report
|
72
74
|
end
|
73
75
|
|
74
76
|
it 'creates an HTML report' do
|
75
|
-
actual_report =
|
77
|
+
actual_report = actual_report_html(@report_checker, :html, 'multiple_urls.html')
|
76
78
|
expected_report = expected_report('multiple_urls.html')
|
77
79
|
expect(actual_report).to eq expected_report
|
78
80
|
end
|
79
81
|
|
80
82
|
it 'creates an JSON report' do
|
81
|
-
actual_report =
|
83
|
+
actual_report = actual_report_json(@report_checker, :json, 'multiple_urls.json')
|
82
84
|
expected_report = expected_report('multiple_urls.json')
|
83
85
|
expect(actual_report).to eq expected_report
|
84
86
|
end
|
@@ -97,13 +99,28 @@ describe NDD::UrlChecker::ReportingUrlChecker do
|
|
97
99
|
private
|
98
100
|
|
99
101
|
def actual_report(report_checker, report_type, output_file_name)
|
100
|
-
# actual_file = '/tmp/
|
102
|
+
# actual_file = File.new('/tmp/report.html', 'w+')
|
101
103
|
actual_file = Tempfile.new(output_file_name)
|
102
104
|
actual_report = report_checker.report(report_type, actual_file)
|
103
105
|
expect(actual_report).to eq actual_file.read
|
104
106
|
actual_report.gsub(/^\s+/, '')
|
105
|
-
|
106
|
-
|
107
|
+
end
|
108
|
+
|
109
|
+
def actual_report_csv(report_checker, report_type, output_file_name)
|
110
|
+
actual_report(report_checker, report_type, output_file_name)
|
111
|
+
end
|
112
|
+
|
113
|
+
def actual_report_html(report_checker, report_type, output_file_name)
|
114
|
+
actual_report = actual_report(report_checker, report_type, output_file_name)
|
115
|
+
actual_report
|
116
|
+
.gsub(/<dd>[\d\.e-]+ s<\/dd>/, '<dd>123.456 s</dd>')
|
117
|
+
.gsub(/<dd>[\d\.e-]+ URL\/s<\/dd>/, '<dd>123.456 URL/s</dd>')
|
118
|
+
.gsub(/<dd>[\d\.e-]+ s\/URL<\/dd>/, '<dd>123.456 s/URL</dd>')
|
119
|
+
end
|
120
|
+
|
121
|
+
def actual_report_json(report_checker, report_type, output_file_name)
|
122
|
+
actual_report = actual_report(report_checker, report_type, output_file_name)
|
123
|
+
actual_report.gsub(/\d+\.\d+(e-?\d*)?/, '123.456')
|
107
124
|
end
|
108
125
|
|
109
126
|
def expected_report(expected_file_name)
|