site_health 0.1.0 → 0.2.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 +5 -5
- data/.gitignore +3 -0
- data/.rubocop.yml +7 -0
- data/.ruby-style-guide.yml +263 -0
- data/.travis.yml +3 -2
- data/CHANGELOG.md +10 -0
- data/Gemfile +4 -2
- data/LICENSE.txt +1 -1
- data/README.md +165 -21
- data/Rakefile +5 -3
- data/bin/console +4 -10
- data/bin/setup +0 -2
- data/exe/site_health +75 -0
- data/lib/site_health.rb +89 -113
- data/lib/site_health/check_data.rb +35 -0
- data/lib/site_health/checkers/checker.rb +152 -0
- data/lib/site_health/checkers/facebook_share_link.rb +125 -0
- data/lib/site_health/checkers/google_page_speed.rb +55 -0
- data/lib/site_health/checkers/html_proofer.rb +67 -0
- data/lib/site_health/checkers/json_syntax.rb +28 -0
- data/lib/site_health/checkers/missing_description.rb +50 -0
- data/lib/site_health/checkers/missing_title.rb +41 -0
- data/lib/site_health/checkers/page_not_found.rb +30 -0
- data/lib/site_health/checkers/redirect.rb +16 -0
- data/lib/site_health/checkers/w3c_css.rb +37 -0
- data/lib/site_health/checkers/w3c_html.rb +37 -0
- data/lib/site_health/checkers/xml.rb +27 -0
- data/lib/site_health/configuration/configuration.rb +84 -0
- data/lib/site_health/configuration/html_proofer_configuration.rb +88 -0
- data/lib/site_health/configuration/w3c_validators_configuration.rb +23 -0
- data/lib/site_health/event_emitter.rb +70 -0
- data/lib/site_health/issue.rb +125 -0
- data/lib/site_health/issues.rb +43 -0
- data/lib/site_health/issues_report.rb +52 -0
- data/lib/site_health/key_struct.rb +6 -3
- data/lib/site_health/link.rb +32 -0
- data/lib/site_health/null_logger.rb +14 -0
- data/lib/site_health/nurse.rb +167 -0
- data/lib/site_health/summarizers/page_size_summarizer.rb +77 -0
- data/lib/site_health/timer.rb +47 -0
- data/lib/site_health/url_map.rb +41 -0
- data/lib/site_health/version.rb +10 -1
- data/lib/site_health/{journals/w3c_journal.rb → w3c_journal_builder.rb} +5 -1
- data/site_health.gemspec +28 -17
- metadata +144 -21
- data/lib/site_health/checkers/css_page.rb +0 -36
- data/lib/site_health/checkers/html_page.rb +0 -41
- data/lib/site_health/checkers/xml_page.rb +0 -21
- data/lib/site_health/journals/css_journal.rb +0 -12
- data/lib/site_health/journals/html_journal.rb +0 -16
- data/lib/site_health/journals/xml_journal.rb +0 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 58954b6231e7ac87ca9708ed7ab494fea6c40dc0e9be354c94c8d42abdafa48a
|
|
4
|
+
data.tar.gz: 32943cf9511a5bcfcfb9677c33a7f36da093121f654d5947fe380e7670976eb2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 033e88ed85ee9582298722df6098575a1a3526788b1e174c78723175e63ba729e82102aef0771e680c1c5fbbbde2bc08bf33b8c35800949c358a92d0d2fc78f9
|
|
7
|
+
data.tar.gz: cba191702784f73c3fa78980204157ab62d53afc2a0351e9ab6b75e528599d907f78fa4b04f2944e9300722a9417acb19f1fc497adb9eb5eaabf756f0a9c3f49
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
Rails:
|
|
2
|
+
Enabled: false
|
|
3
|
+
AllCops:
|
|
4
|
+
TargetRubyVersion: 2.3
|
|
5
|
+
Exclude:
|
|
6
|
+
- "vendor/**/*"
|
|
7
|
+
UseCache: true
|
|
8
|
+
Style/CollectionMethods:
|
|
9
|
+
Description: Preferred collection methods.
|
|
10
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
|
|
11
|
+
Enabled: true
|
|
12
|
+
PreferredMethods:
|
|
13
|
+
collect: map
|
|
14
|
+
collect!: map!
|
|
15
|
+
find: detect
|
|
16
|
+
find_all: select
|
|
17
|
+
reduce: inject
|
|
18
|
+
Style/RedundantFreeze:
|
|
19
|
+
Description: "Checks usages of Object#freeze on immutable objects."
|
|
20
|
+
Enabled: false
|
|
21
|
+
Layout/DotPosition:
|
|
22
|
+
Description: Checks the position of the dot in multi-line method calls.
|
|
23
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
|
|
24
|
+
Enabled: true
|
|
25
|
+
EnforcedStyle: trailing
|
|
26
|
+
SupportedStyles:
|
|
27
|
+
- leading
|
|
28
|
+
- trailing
|
|
29
|
+
Naming/FileName:
|
|
30
|
+
Description: Use snake_case for source file names.
|
|
31
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
|
|
32
|
+
Enabled: false
|
|
33
|
+
Exclude: []
|
|
34
|
+
Naming/MemoizedInstanceVariableName:
|
|
35
|
+
Description: Memoized method name should match memo instance variable name.
|
|
36
|
+
Enabled: false
|
|
37
|
+
Naming/UncommunicativeMethodParamName:
|
|
38
|
+
Description: >-
|
|
39
|
+
Checks for method parameter names that contain capital letters,
|
|
40
|
+
end in numbers, or do not meet a minimal length.
|
|
41
|
+
Enabled: false
|
|
42
|
+
Style/GuardClause:
|
|
43
|
+
Description: Check for conditionals that can be replaced with guard clauses
|
|
44
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
|
|
45
|
+
Enabled: true
|
|
46
|
+
MinBodyLength: 3
|
|
47
|
+
Style/IfUnlessModifier:
|
|
48
|
+
Description: Favor modifier if/unless usage when you have a single-line body.
|
|
49
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
|
|
50
|
+
Enabled: false
|
|
51
|
+
Style/OptionHash:
|
|
52
|
+
Description: Don't use option hashes when you can use keyword arguments.
|
|
53
|
+
Enabled: false
|
|
54
|
+
Style/PercentLiteralDelimiters:
|
|
55
|
+
Description: Use `%`-literal delimiters consistently
|
|
56
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
|
|
57
|
+
Enabled: false
|
|
58
|
+
PreferredDelimiters:
|
|
59
|
+
"%": "()"
|
|
60
|
+
"%i": "()"
|
|
61
|
+
"%q": "()"
|
|
62
|
+
"%Q": "()"
|
|
63
|
+
"%r": "{}"
|
|
64
|
+
"%s": "()"
|
|
65
|
+
"%w": "()"
|
|
66
|
+
"%W": "()"
|
|
67
|
+
"%x": "()"
|
|
68
|
+
Naming/PredicateName:
|
|
69
|
+
Description: Check the names of predicate methods.
|
|
70
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
|
|
71
|
+
Enabled: true
|
|
72
|
+
NamePrefix:
|
|
73
|
+
- is_
|
|
74
|
+
- has_
|
|
75
|
+
- have_
|
|
76
|
+
NamePrefixBlacklist:
|
|
77
|
+
- is_
|
|
78
|
+
Exclude:
|
|
79
|
+
- spec/**/*
|
|
80
|
+
Style/RaiseArgs:
|
|
81
|
+
Description: Checks the arguments passed to raise/fail.
|
|
82
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
|
|
83
|
+
Enabled: false
|
|
84
|
+
EnforcedStyle: exploded
|
|
85
|
+
SupportedStyles:
|
|
86
|
+
- compact
|
|
87
|
+
- exploded
|
|
88
|
+
Style/SignalException:
|
|
89
|
+
Description: Checks for proper usage of fail and raise.
|
|
90
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
|
|
91
|
+
Enabled: false
|
|
92
|
+
EnforcedStyle: semantic
|
|
93
|
+
SupportedStyles:
|
|
94
|
+
- only_raise
|
|
95
|
+
- only_fail
|
|
96
|
+
- semantic
|
|
97
|
+
Style/SingleLineBlockParams:
|
|
98
|
+
Description: Enforces the names of some block params.
|
|
99
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
|
|
100
|
+
Enabled: false
|
|
101
|
+
Methods:
|
|
102
|
+
- reduce:
|
|
103
|
+
- a
|
|
104
|
+
- e
|
|
105
|
+
- inject:
|
|
106
|
+
- a
|
|
107
|
+
- e
|
|
108
|
+
Style/TrivialAccessors:
|
|
109
|
+
Enabled: false
|
|
110
|
+
Style/SingleLineMethods:
|
|
111
|
+
Description: Avoid single-line methods.
|
|
112
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
|
|
113
|
+
Enabled: false
|
|
114
|
+
AllowIfMethodIsEmpty: true
|
|
115
|
+
Style/StringLiterals:
|
|
116
|
+
Description: Checks if uses of quotes match the configured preference.
|
|
117
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
|
|
118
|
+
Enabled: true
|
|
119
|
+
EnforcedStyle: single_quotes
|
|
120
|
+
SupportedStyles:
|
|
121
|
+
- single_quotes
|
|
122
|
+
- double_quotes
|
|
123
|
+
Style/MixinUsage:
|
|
124
|
+
Enabled: true
|
|
125
|
+
Exclude:
|
|
126
|
+
- exe/*
|
|
127
|
+
Style/StringLiteralsInInterpolation:
|
|
128
|
+
Description: Checks if uses of quotes inside expressions in interpolated strings
|
|
129
|
+
match the configured preference.
|
|
130
|
+
Enabled: true
|
|
131
|
+
EnforcedStyle: single_quotes
|
|
132
|
+
SupportedStyles:
|
|
133
|
+
- single_quotes
|
|
134
|
+
- double_quotes
|
|
135
|
+
Style/TrailingCommaInArrayLiteral:
|
|
136
|
+
Description: Checks for trailing comma in parameter lists and literals.
|
|
137
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
|
|
138
|
+
Enabled: true
|
|
139
|
+
EnforcedStyleForMultiline: comma
|
|
140
|
+
Style/TrailingCommaInHashLiteral:
|
|
141
|
+
Description: Checks for trailing comma in parameter lists and literals.
|
|
142
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
|
|
143
|
+
Enabled: true
|
|
144
|
+
EnforcedStyleForMultiline: comma
|
|
145
|
+
Metrics/AbcSize:
|
|
146
|
+
Description: A calculated magnitude based on number of assignments, branches, and
|
|
147
|
+
conditions.
|
|
148
|
+
Enabled: false
|
|
149
|
+
Max: 15
|
|
150
|
+
Metrics/ClassLength:
|
|
151
|
+
Description: Avoid classes longer than 100 lines of code.
|
|
152
|
+
Enabled: false
|
|
153
|
+
CountComments: false
|
|
154
|
+
Max: 100
|
|
155
|
+
Metrics/ModuleLength:
|
|
156
|
+
CountComments: false
|
|
157
|
+
Max: 100
|
|
158
|
+
Description: Avoid modules longer than 100 lines of code.
|
|
159
|
+
Enabled: false
|
|
160
|
+
Metrics/CyclomaticComplexity:
|
|
161
|
+
Description: A complexity metric that is strongly correlated to the number of test
|
|
162
|
+
cases needed to validate a method.
|
|
163
|
+
Enabled: false
|
|
164
|
+
Max: 6
|
|
165
|
+
Metrics/MethodLength:
|
|
166
|
+
Description: Avoid methods longer than 10 lines of code.
|
|
167
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
|
|
168
|
+
Enabled: false
|
|
169
|
+
CountComments: false
|
|
170
|
+
Max: 10
|
|
171
|
+
Metrics/ParameterLists:
|
|
172
|
+
Description: Avoid parameter lists longer than three or four parameters.
|
|
173
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
|
|
174
|
+
Enabled: false
|
|
175
|
+
Max: 5
|
|
176
|
+
CountKeywordArgs: true
|
|
177
|
+
Metrics/PerceivedComplexity:
|
|
178
|
+
Description: A complexity metric geared towards measuring complexity for a human
|
|
179
|
+
reader.
|
|
180
|
+
Enabled: false
|
|
181
|
+
Max: 7
|
|
182
|
+
Metrics/LineLength:
|
|
183
|
+
Description: Maximum line length
|
|
184
|
+
Enabled: true
|
|
185
|
+
Max: 95
|
|
186
|
+
Exclude:
|
|
187
|
+
- Gemfile
|
|
188
|
+
- site_health.gemspec
|
|
189
|
+
- spec/**/*
|
|
190
|
+
Metrics/BlockLength:
|
|
191
|
+
Enabled: true
|
|
192
|
+
Exclude:
|
|
193
|
+
- site_health.gemspec
|
|
194
|
+
- spec/**/*
|
|
195
|
+
Lint/AssignmentInCondition:
|
|
196
|
+
Description: Don't use assignment in conditions.
|
|
197
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
|
|
198
|
+
Enabled: false
|
|
199
|
+
AllowSafeAssignment: true
|
|
200
|
+
Style/InlineComment:
|
|
201
|
+
Description: Avoid inline comments.
|
|
202
|
+
Enabled: false
|
|
203
|
+
Naming/AccessorMethodName:
|
|
204
|
+
Description: Check the naming of accessor methods for get_/set_.
|
|
205
|
+
Enabled: false
|
|
206
|
+
Style/Alias:
|
|
207
|
+
Description: Use alias_method instead of alias.
|
|
208
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
|
|
209
|
+
Enabled: false
|
|
210
|
+
Style/Documentation:
|
|
211
|
+
Description: Document classes and non-namespace modules.
|
|
212
|
+
Enabled: false
|
|
213
|
+
Style/DoubleNegation:
|
|
214
|
+
Description: Checks for uses of double negation (!!).
|
|
215
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
|
|
216
|
+
Enabled: false
|
|
217
|
+
Style/EachWithObject:
|
|
218
|
+
Description: Prefer `each_with_object` over `inject` or `reduce`.
|
|
219
|
+
Enabled: false
|
|
220
|
+
Style/EmptyLiteral:
|
|
221
|
+
Description: Prefer literals to Array.new/Hash.new/String.new.
|
|
222
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
|
|
223
|
+
Enabled: false
|
|
224
|
+
Style/ModuleFunction:
|
|
225
|
+
Description: Checks for usage of `extend self` in modules.
|
|
226
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
|
|
227
|
+
Enabled: false
|
|
228
|
+
Style/OneLineConditional:
|
|
229
|
+
Description: Favor the ternary operator(?:) over if/then/else/end constructs.
|
|
230
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
|
|
231
|
+
Enabled: false
|
|
232
|
+
Style/PerlBackrefs:
|
|
233
|
+
Description: Avoid Perl-style regex back references.
|
|
234
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
|
|
235
|
+
Enabled: false
|
|
236
|
+
Style/Send:
|
|
237
|
+
Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
|
|
238
|
+
may overlap with existing methods.
|
|
239
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
|
|
240
|
+
Enabled: false
|
|
241
|
+
Style/SpecialGlobalVars:
|
|
242
|
+
Description: Avoid Perl-style global variables.
|
|
243
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
|
|
244
|
+
Enabled: false
|
|
245
|
+
Style/VariableInterpolation:
|
|
246
|
+
Description: Don't interpolate global, instance and class variables directly in
|
|
247
|
+
strings.
|
|
248
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
|
|
249
|
+
Enabled: false
|
|
250
|
+
Style/WhenThen:
|
|
251
|
+
Description: Use when x then ... for one-line cases.
|
|
252
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
|
|
253
|
+
Enabled: false
|
|
254
|
+
Lint/EachWithObjectArgument:
|
|
255
|
+
Description: Check for immutable argument given to each_with_object.
|
|
256
|
+
Enabled: true
|
|
257
|
+
Lint/HandleExceptions:
|
|
258
|
+
Description: Don't suppress exception.
|
|
259
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
|
|
260
|
+
Enabled: false
|
|
261
|
+
Lint/LiteralInInterpolation:
|
|
262
|
+
Description: Checks for literals used in interpolation.
|
|
263
|
+
Enabled: false
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
source 'https://rubygems.org'
|
|
4
|
+
|
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
4
6
|
|
|
5
7
|
# Specify your gem's dependencies in site_health.gemspec
|
|
6
8
|
gemspec
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
# SiteHealth
|
|
1
|
+
# SiteHealth [](https://travis-ci.org/buren/site_health)
|
|
2
2
|
|
|
3
3
|
:warning: Project is still experimental, API will change (a lot) without notice.
|
|
4
4
|
|
|
5
5
|
Crawl a site and check various health indicators, such as:
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
7
|
+
- Server errors
|
|
8
|
+
- HTTP errors
|
|
9
|
+
- Invalid HTML/XML/JSON
|
|
10
|
+
- Missing HTML title/description
|
|
11
|
+
- Missing image alt-attribute
|
|
12
|
+
- Google Pagespeed
|
|
11
13
|
|
|
12
14
|
## Installation
|
|
13
15
|
|
|
14
16
|
Add this line to your application's Gemfile:
|
|
15
17
|
|
|
16
18
|
```ruby
|
|
17
|
-
gem
|
|
19
|
+
gem "site_health"
|
|
18
20
|
```
|
|
19
21
|
|
|
20
22
|
And then execute:
|
|
@@ -27,31 +29,162 @@ Or install it yourself as:
|
|
|
27
29
|
|
|
28
30
|
## Usage
|
|
29
31
|
|
|
32
|
+
[CLI usage](#cli).
|
|
33
|
+
|
|
34
|
+
Crawl and check site
|
|
35
|
+
|
|
36
|
+
```ruby
|
|
37
|
+
nurse = SiteHealth.check("https://example.com")
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Check list of URLs
|
|
41
|
+
```ruby
|
|
42
|
+
nurse = SiteHealth.check_urls(["https://example.com"])
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Write raw JSON result to file
|
|
46
|
+
```ruby
|
|
47
|
+
nurse = SiteHealth.check("https://example.com")
|
|
48
|
+
json = JSON.pretty_generate(nurse.journal)
|
|
49
|
+
|
|
50
|
+
File.write("result.json", json)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Each issue
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
SiteHealth.check_urls(urls) do |nurse|
|
|
57
|
+
nurse.clerk do |clerk|
|
|
58
|
+
clerk.every_issue { |issue| puts "#{issue.severity}, #{issue.title}" }
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Simple issue reports
|
|
64
|
+
```ruby
|
|
65
|
+
nurse = SiteHealth.check("https://example.com")
|
|
66
|
+
report = SiteHealth::IssuesReport.new(nurse.issue) do |r|
|
|
67
|
+
r.fields = %i[url title detail] # issue fields
|
|
68
|
+
r.select { |issue| issue.url.include?('blog/') }
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
report.to_a
|
|
72
|
+
report.to_csv
|
|
73
|
+
report.to_json
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Event handlers
|
|
77
|
+
|
|
78
|
+
```ruby
|
|
79
|
+
urls = ["https://example.com"]
|
|
80
|
+
nurse = SiteHealth.check_urls(urls) do |nurse|
|
|
81
|
+
nurse.clerk do |clerk|
|
|
82
|
+
clerk.every_journal do |journal, page|
|
|
83
|
+
time_in_seconds = journal[:runtime_in_seconds]
|
|
84
|
+
puts "Found page #{page.title} - #{page.url} (checks took #{time_in_seconds})"
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
clerk.every_check do |check|
|
|
88
|
+
puts "Ran check: #{check.name}"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
clerk.every_failed_url do |url|
|
|
92
|
+
puts "Failed to fetch: #{url}"
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Write page speed summary CSV
|
|
99
|
+
|
|
30
100
|
```ruby
|
|
31
|
-
|
|
101
|
+
nurse = SiteHealth.check("https://example.com")
|
|
102
|
+
summary = SiteHealth::PageSpeedSummarizer.new(nurse.journal)
|
|
103
|
+
File.write("page_size_summary.csv", summary.to_csv)
|
|
104
|
+
```
|
|
32
105
|
|
|
33
|
-
|
|
34
|
-
journal.missing_html_title # List of URLs that are missing the HTML title
|
|
35
|
-
journal.html_error_urls # List of URLs with HTML errors in them
|
|
106
|
+
## Configuration
|
|
36
107
|
|
|
37
|
-
|
|
38
|
-
journal.css_error_urls # List of URLs with CSS errors in them
|
|
108
|
+
All configuration is optional.
|
|
39
109
|
|
|
40
|
-
|
|
41
|
-
|
|
110
|
+
```ruby
|
|
111
|
+
SiteHealth.configure do |config|
|
|
112
|
+
# Override default checkers
|
|
113
|
+
config.checkers = [:json_syntax, :html]
|
|
114
|
+
|
|
115
|
+
# Configure logger
|
|
116
|
+
config.logger = Logger.new(STDOUT).tap do |logger|
|
|
117
|
+
logger.progname = 'SiteHealth'
|
|
118
|
+
logger.level = Logger::INFO
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Configure HTMLProofer
|
|
122
|
+
config.html_proofer do |proofer_config|
|
|
123
|
+
proofer_config.log_level = :info
|
|
124
|
+
proofer_config.check_opengraph = false
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Configure W3C HTML/CSS validator
|
|
128
|
+
config.w3c_validators do |w3c_config|
|
|
129
|
+
w3c_config.css_uri = 'http://localhost:8888/check'
|
|
130
|
+
w3c_config.html_uri = 'http://localhost:8888/check'
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
```
|
|
42
134
|
|
|
43
|
-
|
|
44
|
-
broken = journal.broken_urls.first
|
|
45
|
-
broken.url # The URL that failed
|
|
46
|
-
broken.exists_on # Array of URLs where the broken URL was present
|
|
135
|
+
__Load non-default checkers__:
|
|
47
136
|
|
|
48
|
-
|
|
49
|
-
|
|
137
|
+
A few of the non-default checkers available in this gem require 3rd-party dependencies which aren't installed by default.
|
|
138
|
+
|
|
139
|
+
| Checker name | Gem |
|
|
140
|
+
| ------------------ | ------------------ |
|
|
141
|
+
| google_page_speed | google-api-client |
|
|
142
|
+
| html_proofer | html-proofer |
|
|
143
|
+
| w3c_html | w3c_validators |
|
|
144
|
+
| w3c_css | w3c_validators |
|
|
145
|
+
|
|
146
|
+
If you intend to use any of those checkers make sure to install the gem first. For example to use the `google_page_speed` checker add `google-api-client` to your Gemfile or install it manually with `gem install google-api-client`. Then you register the checker for use.
|
|
147
|
+
|
|
148
|
+
```ruby
|
|
149
|
+
SiteHealth.config.register_checker :google_page_speed
|
|
150
|
+
# LoadError is raised if google-api-client is *not* installed
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
__Add your own checker__:
|
|
154
|
+
|
|
155
|
+
```ruby
|
|
156
|
+
class ProfanityChecker < SiteHealth::Checker
|
|
157
|
+
name "profanity"
|
|
158
|
+
types %i[html json xml css javascript]
|
|
159
|
+
|
|
160
|
+
def check
|
|
161
|
+
add_data(profanity: {
|
|
162
|
+
damn: page.body.include?(" damn "),
|
|
163
|
+
shit: page.body.include?(" shit ")
|
|
164
|
+
})
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Then register it
|
|
169
|
+
SiteHealth.configure do |config|
|
|
170
|
+
config.register_checker ProfanityChecker
|
|
171
|
+
end
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## CLI
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
Usage: site_health --help
|
|
178
|
+
--url=val0
|
|
179
|
+
--fields=priority,title,url Issue fields to include - by default all fields are included
|
|
180
|
+
--output=result.csv Output format, .csv or .json
|
|
181
|
+
--[no-]progress
|
|
182
|
+
-h, --help How to use
|
|
50
183
|
```
|
|
51
184
|
|
|
52
185
|
## Development
|
|
53
186
|
|
|
54
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake
|
|
187
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
55
188
|
|
|
56
189
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
57
190
|
|
|
@@ -62,3 +195,14 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/buren/
|
|
|
62
195
|
## License
|
|
63
196
|
|
|
64
197
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## TODO
|
|
202
|
+
|
|
203
|
+
- Good way to render result/reports data
|
|
204
|
+
- Improve logger support
|
|
205
|
+
- Checkers
|
|
206
|
+
* canonical URL
|
|
207
|
+
* http vs https links
|
|
208
|
+
* links matching a pattern
|