seo_cache 1.0.2 → 1.0.3

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: dde4a37e1374c8be6416313e684356041177425e0cf5c2466d4fc7c60818626d
4
- data.tar.gz: 9e5879c7af42860ff332e06eb36343cd650bf8a89c634b386a8073059d9c4aa2
3
+ metadata.gz: f2c6084cfed22c86d8dae948445d042fb5bcccd8a01afac54974dfaa96181f20
4
+ data.tar.gz: a71c76d0d492bb9058d68a81ae8c5aa3170ef09d64192818d6f3a573453f18c9
5
5
  SHA512:
6
- metadata.gz: a391af74f2c3d9848cce8bb4b1daa228c3296e019bed8ab1126dda1b9a52825351a885bfd9c2067671f8ff645a4bb7b88d36d1fb8298790e04c48e36ab93daf5
7
- data.tar.gz: 8aa95c5b23d5120b1a5848d115ed3ceb75ec2019abaf507a7bcf076fa9d391ffe750f1750bbcc4b484d497303544f68ab33788a11bd88a6d1bc5c10aae95f682
6
+ metadata.gz: 454155f0bcc296c6ccd1d7d3eafa90d5a83f17a38c1d24cdd4d52a7ae44eb2dca7dc493fad4233c30b33fb6183028a39bb7e8c60baa55a61533b22ac239267fd
7
+ data.tar.gz: cf60d5d45b01fc2de32ee0963bd086e48859adcc6abcfee8921dcade7a38bdaae09727dfa025a49c0116f36fcff76f6adb651000293f6514db13d2415ccb223c
data/.rubocop.yml CHANGED
@@ -1,18 +1,20 @@
1
1
  # Documentation
2
2
  # https://github.com/bbatsov/rubocop/blob/master/config/default.yml
3
- # http://rubocop.readthedocs.io/en/latest
3
+ # http://rubocop.readthedocs.io/en/latest
4
+
5
+ require:
6
+ - rubocop-rails
7
+ - rubocop-rspec
8
+ - rubocop-performance
4
9
 
5
10
  AllCops:
6
- TargetRubyVersion: 2.6
11
+ TargetRubyVersion: 3.0
7
12
 
8
13
  Bundler/OrderedGems:
9
14
  Enabled: false
10
15
 
11
- Layout/HashAlignment:
12
- Enabled: false
13
-
14
- Layout/ParameterAlignment:
15
- Enabled: false
16
+ Gemspec/DateAssignment:
17
+ Enabled: true
16
18
 
17
19
  Layout/CaseIndentation:
18
20
  Enabled: false
@@ -42,9 +44,15 @@ Layout/FirstArrayElementIndentation:
42
44
  Layout/FirstHashElementIndentation:
43
45
  Enabled: false
44
46
 
47
+ Layout/HashAlignment:
48
+ Enabled: false
49
+
45
50
  Layout/LeadingCommentSpace:
46
51
  Enabled: false
47
52
 
53
+ Layout/LineLength:
54
+ Enabled: false
55
+
48
56
  Layout/MultilineBlockLayout:
49
57
  Enabled: false
50
58
 
@@ -57,20 +65,73 @@ Layout/MultilineMethodCallIndentation:
57
65
  Layout/MultilineOperationIndentation:
58
66
  Enabled: false
59
67
 
68
+ Layout/ParameterAlignment:
69
+ Enabled: false
70
+
60
71
  Layout/SpaceAroundOperators:
61
72
  Enabled: false
62
73
 
74
+ Layout/SpaceBeforeBrackets:
75
+ Enabled: true
76
+
63
77
  Layout/SpaceInLambdaLiteral:
64
78
  Enabled: false
65
79
 
66
80
  Layout/TrailingWhitespace:
67
81
  Enabled: false
68
82
 
83
+ Lint/AmbiguousAssignment:
84
+ Enabled: true
85
+
69
86
  Lint/AmbiguousBlockAssociation:
70
87
  Enabled: false
71
88
 
89
+ Lint/DeprecatedConstants:
90
+ Enabled: true
91
+
92
+ Lint/DuplicateBranch:
93
+ Enabled: true
94
+
95
+ Lint/DuplicateRegexpCharacterClassElement:
96
+ Enabled: true
97
+
98
+ Lint/EmptyBlock:
99
+ Enabled: true
100
+
101
+ Lint/EmptyClass:
102
+ Enabled: true
103
+
104
+ Lint/LambdaWithoutLiteralBlock:
105
+ Enabled: true
106
+
107
+ Lint/NoReturnInBeginEndBlocks:
108
+ Enabled: true
109
+
110
+ Lint/NumberedParameterAssignment:
111
+ Enabled: true
112
+
113
+ Lint/OrAssignmentToConstant:
114
+ Enabled: true
115
+
116
+ Lint/RedundantDirGlobSort:
117
+ Enabled: true
118
+
119
+ Lint/SymbolConversion:
120
+ Enabled: true
121
+
122
+ Lint/ToEnumArguments:
123
+ Enabled: true
124
+
125
+ Lint/TripleQuotes:
126
+ Enabled: true
127
+
128
+ Lint/UnexpectedBlockArity:
129
+ Enabled: true
130
+
131
+ Lint/UnmodifiedReduceAccumulator:
132
+ Enabled: true
133
+
72
134
  Metrics/AbcSize:
73
- # The ABC size is a calculated magnitude, so this number can be a Fixnum or a Float.
74
135
  Max: 240
75
136
 
76
137
  Metrics/BlockLength:
@@ -80,14 +141,14 @@ Metrics/BlockNesting:
80
141
  Max: 4
81
142
 
82
143
  Metrics/ClassLength:
83
- CountComments: false # count full line comments?
144
+ CountComments: false
84
145
  Max: 600
85
146
 
86
147
  Metrics/CyclomaticComplexity:
87
148
  Enabled: false
88
149
 
89
150
  Metrics/MethodLength:
90
- CountComments: false # count full line comments?
151
+ CountComments: false
91
152
  Max: 120
92
153
 
93
154
  Metrics/PerceivedComplexity:
@@ -96,6 +157,168 @@ Metrics/PerceivedComplexity:
96
157
  Naming/RescuedExceptionsVariableName:
97
158
  Enabled: false
98
159
 
160
+ Performance/AncestorsInclude:
161
+ Enabled: true
162
+
163
+ Performance/BigDecimalWithNumericArgument:
164
+ Enabled: true
165
+
166
+ Performance/BlockGivenWithExplicitBlock:
167
+ Enabled: true
168
+
169
+ Performance/CollectionLiteralInLoop:
170
+ Enabled: true
171
+
172
+ Performance/ConstantRegexp:
173
+ Enabled: true
174
+
175
+ Performance/MapCompact:
176
+ Enabled: true
177
+
178
+ Performance/MethodObjectAsBlock:
179
+ Enabled: true
180
+
181
+ Performance/RedundantEqualityComparisonBlock:
182
+ Enabled: true
183
+
184
+ Performance/RedundantSortBlock:
185
+ Enabled: true
186
+
187
+ Performance/RedundantSplitRegexpArgument:
188
+ Enabled: true
189
+
190
+ Performance/RedundantStringChars:
191
+ Enabled: true
192
+
193
+ Performance/ReverseFirst:
194
+ Enabled: true
195
+
196
+ Performance/SortReverse:
197
+ Enabled: true
198
+
199
+ Performance/Squeeze:
200
+ Enabled: true
201
+
202
+ Performance/StringInclude:
203
+ Enabled: true
204
+
205
+ Performance/Sum:
206
+ Enabled: true
207
+
208
+ Rails/ActiveRecordCallbacksOrder:
209
+ Enabled: true
210
+
211
+ Rails/AfterCommitOverride:
212
+ Enabled: true
213
+
214
+ Rails/AttributeDefaultBlockValue:
215
+ Enabled: true
216
+
217
+ Rails/DynamicFindBy:
218
+ Enabled: false
219
+
220
+ Rails/FindBy:
221
+ Enabled: false
222
+
223
+ Rails/FindById:
224
+ Enabled: true
225
+
226
+ Rails/HasManyOrHasOneDependent:
227
+ Enabled: false
228
+
229
+ Rails/Inquiry:
230
+ Enabled: true
231
+
232
+ Rails/InverseOf:
233
+ Enabled: false
234
+
235
+ Rails/MailerName:
236
+ Enabled: true
237
+
238
+ Rails/MatchRoute:
239
+ Enabled: true
240
+
241
+ Rails/NegateInclude:
242
+ Enabled: true
243
+
244
+ Rails/Pluck:
245
+ Enabled: true
246
+
247
+ Rails/OutputSafety:
248
+ Enabled: false
249
+
250
+ Rails/PluckInWhere:
251
+ Enabled: true
252
+
253
+ Rails/RenderInline:
254
+ Enabled: true
255
+
256
+ Rails/RenderPlainText:
257
+ Enabled: true
258
+
259
+ Rails/ShortI18n:
260
+ Enabled: true
261
+
262
+ Rails/SkipsModelValidations:
263
+ Enabled: false
264
+
265
+ Rails/SquishedSQLHeredocs:
266
+ Enabled: true
267
+
268
+ Rails/UnknownEnv:
269
+ Enabled: false
270
+
271
+ Rails/Validation:
272
+ Enabled: false
273
+
274
+ Rails/WhereEquals:
275
+ Enabled: true
276
+
277
+ Rails/WhereExists:
278
+ Enabled: true
279
+
280
+ Rails/WhereNot:
281
+ Enabled: true
282
+
283
+ RSpec/BeforeAfterAll:
284
+ Enabled: false
285
+
286
+ RSpec/ContextWording:
287
+ Enabled: false
288
+
289
+ RSpec/DescribedClass:
290
+ Enabled: false
291
+
292
+ RSpec/ExampleLength:
293
+ Max: 20
294
+
295
+ RSpec/Capybara:
296
+ Enabled: false
297
+
298
+ RSpec/ImplicitExpect:
299
+ Enabled: false
300
+
301
+ RSpec/ImplicitSubject:
302
+ Enabled: false
303
+
304
+ RSpec/InstanceVariable:
305
+ Enabled: false
306
+
307
+ RSpec/LeadingSubject:
308
+ Enabled: false
309
+
310
+ RSpec/MultipleExpectations:
311
+ Max: 10
312
+
313
+ RSpec/MultipleMemoizedHelpers:
314
+ Max: 8
315
+
316
+ RSpec/NestedGroups:
317
+ Max: 4
318
+
319
+ Style/ArgumentsForwarding:
320
+ Enabled: true
321
+
99
322
  Style/AsciiComments:
100
323
  Enabled: false
101
324
 
@@ -105,24 +328,63 @@ Style/BlockDelimiters:
105
328
  Style/ClassAndModuleChildren:
106
329
  Enabled: false
107
330
 
331
+ Style/CollectionCompact:
332
+ Enabled: true
333
+
108
334
  Style/ColonMethodCall:
109
335
  Enabled: false
110
336
 
111
337
  Style/CommandLiteral:
112
338
  Enabled: false
113
339
 
340
+ Style/Documentation:
341
+ Enabled: false
342
+
343
+ Style/DocumentDynamicEvalDefinition:
344
+ Enabled: true
345
+
114
346
  Style/DoubleNegation:
115
347
  Enabled: false
116
348
 
349
+ Style/EndlessMethod:
350
+ Enabled: true
351
+
117
352
  Style/GlobalVars:
118
353
  Enabled: false
119
354
 
355
+ Style/HashConversion:
356
+ Enabled: true
357
+
358
+ Style/HashEachMethods:
359
+ Enabled: true
360
+
361
+ Style/HashExcept:
362
+ Enabled: true
363
+
364
+ Style/HashTransformKeys:
365
+ Enabled: true
366
+
367
+ Style/HashTransformValues:
368
+ Enabled: true
369
+
370
+ Style/IfUnlessModifier:
371
+ Enabled: false
372
+
373
+ Style/IfWithBooleanLiteralBranches:
374
+ Enabled: true
375
+
120
376
  Style/Lambda:
121
377
  Enabled: false
122
378
 
123
379
  Style/MultilineIfModifier:
124
380
  Enabled: false
125
381
 
382
+ Style/NegatedIfElseCondition:
383
+ Enabled: true
384
+
385
+ Style/NilLambda:
386
+ Enabled: true
387
+
126
388
  Style/NumericPredicate:
127
389
  Enabled: false
128
390
 
@@ -130,6 +392,9 @@ Style/RedundantReturn:
130
392
  Enabled: false
131
393
  AllowMultipleReturnValues: true
132
394
 
395
+ Style/RedundantArgument:
396
+ Enabled: true
397
+
133
398
  Style/RedundantSelf:
134
399
  Enabled: false
135
400
 
@@ -139,5 +404,11 @@ Style/RegexpLiteral:
139
404
  Style/RescueModifier:
140
405
  Enabled: false
141
406
 
407
+ Style/StringChars:
408
+ Enabled: true
409
+
410
+ Style/SwapValues:
411
+ Enabled: true
412
+
142
413
  Style/SymbolArray:
143
414
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.0.3
2
+
3
+ - Ensure page rendered status is present after head element
4
+
1
5
  ## 1.0.2
2
6
 
3
7
  - Do not log missed cache for ignored statuses
@@ -37,7 +37,7 @@ module SeoCache
37
37
  Thread.new do
38
38
  prerender_data = page_render(env)
39
39
  # Extract status from render page or return 404
40
- status = prerender_data&.scan(/<!--status:(\d+)-->/)&.last&.first || 404
40
+ status = prerender_data&.scan(/<!--status:(\d+)-->/)&.last&.first
41
41
  after_render(env, prerender_data, status || 200)
42
42
  end
43
43
  end
@@ -48,7 +48,7 @@ module SeoCache
48
48
  status_code = "<!--status:#{status}-->"
49
49
  # Cannot add at the top of file, Chrome removes leading comments...
50
50
  begin
51
- body_code = response.body.sub('<head>', "<head>#{status_code}")
51
+ body_code = response.body.sub(/<head( ?)(.*?)>/i, "<head\\1\\2>#{status_code}")
52
52
  return [status, headers, [body_code]]
53
53
  rescue
54
54
  return [status, headers, [nil]]
@@ -19,11 +19,7 @@ module SeoCache
19
19
  next if @page_caching.cache_exists?(path) && !@force_cache
20
20
 
21
21
  url = @host + path
22
- url += if path.include?('?')
23
- '&'
24
- else
25
- '?'
26
- end
22
+ url += path.include?('?') ? '&' : '?'
27
23
  url += "#{SeoCache.prerender_url_param}=true"
28
24
 
29
25
  page_source = @page_render.get(url, false)
@@ -1,3 +1,3 @@
1
1
  module SeoCache
2
- VERSION = '1.0.2'.freeze
2
+ VERSION = '1.0.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seo_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - FloXcoder
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-06 00:00:00.000000000 Z
11
+ date: 2021-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -229,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
229
  - !ruby/object:Gem::Version
230
230
  version: '0'
231
231
  requirements: []
232
- rubygems_version: 3.0.8
232
+ rubygems_version: 3.2.16
233
233
  signing_key:
234
234
  specification_version: 4
235
235
  summary: Cache dedicated for SEO with Javascript rendering