seo_cache 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3fc2b67ef1141988885f2fa971876755aebfb7d4cc37f1f82a55e86109398ab5
4
- data.tar.gz: e568e095d73c6340fa8b1194b8ba081e32568fd51d104e8d00bbe532b2adc8cf
3
+ metadata.gz: 5883ffe627a24434fdd9b39a474af010cc0ac22d14c8a9a42d02038bcf06d2f9
4
+ data.tar.gz: 01e2ee94da4a8706a78379d8e59918359e021b8e89d942050a2909fdfcb218e4
5
5
  SHA512:
6
- metadata.gz: 8de06af3f3df04dff44f3764f0b3df2cd1b618dbded85357fc1e50a5f40dae38c20e8ea6dfda605752b55717e270a95386281e6734316d87458747fdd4f74085
7
- data.tar.gz: c8e11178a53dc627d92f02dc2c4ecfdb6f4640e8341b95ad6c995cfb51cd973206ce35caf4bfaf22555c7999abc4c795ccd8be88380ced061bf592bc0a459ed0
6
+ metadata.gz: 4ec66862f2ea5b0e9963c92c6841a3a7bdb927f48e6e1b1008cb5adba391251a1b70b0e2231a0ef79f9d33de1f392701e5d9f14162f9c739b91c939bc37d2e35
7
+ data.tar.gz: ba0760d5213a9df4f7da470e87eb395aca8508cb33d674c2708a8e224ba45a46ea9211617c683f2bf476ba1a95be138e4053016fa7f3a7e9f32e461f96099afb
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.5
2
+ TargetRubyVersion: 2.6
3
3
 
4
4
  Documentation:
5
5
  Enabled: false
@@ -10,26 +10,32 @@ LineLength:
10
10
  Bundler/OrderedGems:
11
11
  Enabled: false
12
12
 
13
- Layout/AlignHash:
13
+ Layout/CaseIndentation:
14
14
  Enabled: false
15
15
 
16
- Layout/AlignParameters:
16
+ Layout/CommentIndentation:
17
17
  Enabled: false
18
18
 
19
- Layout/CaseIndentation:
19
+ Layout/EmptyLinesAroundClassBody:
20
20
  Enabled: false
21
21
 
22
- Layout/EmptyLinesAroundClassBody:
22
+ Layout/EmptyLinesAroundModuleBody:
23
23
  Enabled: false
24
24
 
25
25
  Layout/ExtraSpacing:
26
26
  Enabled: false
27
27
  AllowForAlignment: true
28
28
 
29
- Layout/IndentFirstHashElement:
29
+ Layout/FirstArgumentIndentation:
30
+ Enabled: false
31
+
32
+ Layout/FirstArrayElementIndentation:
33
+ Enabled: false
34
+
35
+ Layout/FirstHashElementIndentation:
30
36
  Enabled: false
31
37
 
32
- Layout/IndentFirstArgument:
38
+ Layout/HashAlignment:
33
39
  Enabled: false
34
40
 
35
41
  Layout/LeadingCommentSpace:
@@ -47,6 +53,9 @@ Layout/MultilineMethodCallIndentation:
47
53
  Layout/MultilineOperationIndentation:
48
54
  Enabled: false
49
55
 
56
+ Layout/ParameterAlignment:
57
+ Enabled: false
58
+
50
59
  Layout/SpaceAroundOperators:
51
60
  Enabled: false
52
61
 
@@ -80,18 +89,52 @@ Metrics/MethodLength:
80
89
  CountComments: false # count full line comments?
81
90
  Max: 120
82
91
 
92
+ Metrics/ModuleLength:
93
+ CountComments: false # count full line comments?
94
+ Max: 350
95
+
83
96
  Metrics/ParameterLists:
84
97
  Max: 7
85
98
 
86
99
  Metrics/PerceivedComplexity:
87
100
  Enabled: false
88
101
 
102
+ Naming/RescuedExceptionsVariableName:
103
+ Enabled: false
104
+
105
+ Rails/DynamicFindBy:
106
+ Enabled: false
107
+
108
+ Rails/FindBy:
109
+ Enabled: false
110
+
111
+ Rails/HasAndBelongsToMany:
112
+ Enabled: false
113
+
114
+ Rails/HelperInstanceVariable:
115
+ Enabled: false
116
+
89
117
  Rails/OutputSafety:
90
118
  Enabled: false
91
119
 
120
+ Rails/UnknownEnv:
121
+ Enabled: false
122
+
123
+ Rails/Validation:
124
+ Enabled: false
125
+
126
+ RSpec/ExampleLength:
127
+ Max: 20
128
+
129
+ RSpec/MultipleExpectations:
130
+ Max: 10
131
+
92
132
  Style/AsciiComments:
93
133
  Enabled: false
94
134
 
135
+ Style/ClassAndModuleChildren:
136
+ Enabled: false
137
+
95
138
  Style/ColonMethodCall:
96
139
  Enabled: false
97
140
 
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.12.0
2
+
3
+ - Force driver to quit after page rendering (except for populate cache, quit only after rendered all pages)
4
+ - Add option to wait for page loading (in case of asynchronous components, like React Router)
5
+
1
6
  ## 0.11.0
2
7
 
3
8
  - Update for Rails 6
data/README.md CHANGED
@@ -181,6 +181,9 @@ end
181
181
 
182
182
  You can add the `force_cache: true` option to `SeoCache::PopulateCache` for overwrite cache data.
183
183
 
184
+ If you want to only execute only through a rake task, you can comment the line which include the middleware. keep all options configured and remove only the middleware. Thus all pages will be cached and SeoCache not called for pages not in cache.
185
+ It's useful if you have a script which generates all website pages (based on sitemap for instance) and you run script every day.
186
+
184
187
  ## Server
185
188
 
186
189
  If you use disk caching, add to your Nginx configuration:
@@ -34,7 +34,7 @@ module SeoCache
34
34
  Thread.new do
35
35
  prerender_data = page_render(env)
36
36
  # Extract status from render page
37
- status = prerender_data.scan(/<!--status:(\d+)-->/).last&.first
37
+ status = prerender_data&.scan(/<!--status:(\d+)-->/)&.last&.first
38
38
  after_render(env, prerender_data, status || 200)
39
39
  end
40
40
  end
@@ -6,14 +6,16 @@ module SeoCache
6
6
  init_driver
7
7
  end
8
8
 
9
- def get(url)
9
+ def get(url, quit_after_render = true)
10
10
  @driver.get(url)
11
11
 
12
+ sleep SeoCache.wait_time_for_page_loading if SeoCache.wait_time_for_page_loading
13
+
12
14
  return @driver.page_source
13
15
  rescue StandardError => error
14
16
  SeoCache.log_error(error.message)
15
- # ensure
16
- # @driver&.quit
17
+ ensure
18
+ @driver&.quit if quit_after_render
17
19
  end
18
20
 
19
21
  def close_connection
@@ -25,7 +27,7 @@ module SeoCache
25
27
  def init_driver
26
28
  # Selenium::WebDriver.logger.level = :info
27
29
 
28
- Webdrivers.cache_time = 86_400
30
+ Webdrivers.cache_time = 86_400 * 10 # Chromedriver will be cached for 10 days (except if it detects a new version of Chrome)
29
31
 
30
32
  Selenium::WebDriver::Chrome.path = SeoCache.chrome_path if SeoCache.chrome_path
31
33
 
@@ -18,7 +18,7 @@ module SeoCache
18
18
  @paths.each do |path|
19
19
  next if @page_caching.cache_exists?(path) && !@force_cache
20
20
 
21
- page_source = @page_render.get(@host + path)
21
+ page_source = @page_render.get(@host + path, true)
22
22
  @page_caching.cache(page_source, path)
23
23
  end
24
24
 
@@ -1,3 +1,3 @@
1
1
  module SeoCache
2
- VERSION = '0.11.0'.freeze
2
+ VERSION = '0.12.0'.freeze
3
3
  end
data/lib/seo_cache.rb CHANGED
@@ -5,7 +5,7 @@ require 'net/http'
5
5
  require 'redis'
6
6
  require 'redis-namespace'
7
7
  require 'selenium/webdriver'
8
- require 'webdrivers'
8
+ require 'webdrivers/chromedriver'
9
9
 
10
10
  require 'seo_cache/logger'
11
11
  require 'seo_cache/version'
@@ -59,6 +59,10 @@ module SeoCache
59
59
  mattr_accessor :force_cache_url_param
60
60
  self.force_cache_url_param = '_seo_cache_'
61
61
 
62
+ # Time to wait to wait before page rendering (for asynchronous called), in seconds
63
+ mattr_accessor :wait_time_for_page_loading
64
+ self.wait_time_for_page_loading = nil
65
+
62
66
  mattr_accessor :cache_only_status
63
67
  self.cache_only_status = [200]
64
68
 
data/seo_cache.gemspec CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency 'webdrivers', '~> 4'
30
30
 
31
31
  spec.add_development_dependency 'bundler', '~> 1'
32
- spec.add_development_dependency 'rake', '~> 12'
32
+ spec.add_development_dependency 'rake', '~> 13'
33
33
  spec.add_development_dependency 'rspec', '~> 3'
34
34
  spec.add_development_dependency 'simplecov', '~> 0.17'
35
35
  spec.add_development_dependency 'webmock', '~> 3'
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: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - FloXcoder
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-18 00:00:00.000000000 Z
11
+ date: 2019-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '12'
131
+ version: '13'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '12'
138
+ version: '13'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rspec
141
141
  requirement: !ruby/object:Gem::Requirement