avo 2.42.1 → 2.42.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of avo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/avo/app.rb +1 -20
- data/lib/avo/configuration.rb +29 -0
- data/lib/avo/execution_context.rb +3 -3
- data/lib/avo/version.rb +1 -1
- data/lib/generators/avo/templates/initializer/avo.tt +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85975e5896ef4f49e8ca3b4874470092dfd64eafd7c0282a8715162c9dfc42bc
|
4
|
+
data.tar.gz: c90db50a988c7cc7bf66cbc5671844390f28455f4d09f421b86d49caf86f588a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98b4bc5ccb0193c5ef46da23c582a3da7ee3bf8fc8ae5516232b4ea6f0b98df0fa3a798be6498019e76aa735fd37b6cbfff1d6514d3be3a6628b6b7af56e6431
|
7
|
+
data.tar.gz: ef6fee4b84d1cbf589a0160785005e568c2c8f2a6dad77da7692170c8819e89ad7202ee4f26944180c34a4bd19e6953c50ad96534ce8ca33e2582745ec7bf3c6
|
data/Gemfile.lock
CHANGED
data/lib/avo/app.rb
CHANGED
@@ -31,26 +31,7 @@ module Avo
|
|
31
31
|
def boot
|
32
32
|
init_fields
|
33
33
|
|
34
|
-
self.cache_store =
|
35
|
-
end
|
36
|
-
|
37
|
-
# When not in production we'll just use the MemoryStore which is good enough.
|
38
|
-
# When running in production we'll try to use memcached or redis if available.
|
39
|
-
# If not, we'll use the FileStore.
|
40
|
-
# We decided against the MemoryStore in production because it will not be shared between multiple processes (when using Puma).
|
41
|
-
def get_cache_store
|
42
|
-
if Rails.env.production?
|
43
|
-
case Rails.cache.class.to_s
|
44
|
-
when "ActiveSupport::Cache::MemCacheStore", "ActiveSupport::Cache::RedisCacheStore", "SolidCache::Store"
|
45
|
-
Rails.cache
|
46
|
-
else
|
47
|
-
ActiveSupport::Cache.lookup_store(:file_store, Rails.root.join("tmp", "cache"))
|
48
|
-
end
|
49
|
-
elsif Rails.env.test?
|
50
|
-
Rails.cache
|
51
|
-
else
|
52
|
-
ActiveSupport::Cache.lookup_store(:memory_store)
|
53
|
-
end
|
34
|
+
self.cache_store = Avo.configuration.cache_store
|
54
35
|
end
|
55
36
|
|
56
37
|
# Generate a dynamic root path using the URIService
|
data/lib/avo/configuration.rb
CHANGED
@@ -5,6 +5,7 @@ module Avo
|
|
5
5
|
attr_writer :app_name
|
6
6
|
attr_writer :branding
|
7
7
|
attr_writer :root_path
|
8
|
+
attr_writer :cache_store
|
8
9
|
attr_accessor :timezone
|
9
10
|
attr_accessor :per_page
|
10
11
|
attr_accessor :per_page_steps
|
@@ -96,6 +97,7 @@ module Avo
|
|
96
97
|
@field_wrapper_layout = :inline
|
97
98
|
@resources = nil
|
98
99
|
@prefix_path = nil
|
100
|
+
@cache_store = computed_cache_store
|
99
101
|
end
|
100
102
|
|
101
103
|
def current_user_method(&block)
|
@@ -147,6 +149,33 @@ module Avo
|
|
147
149
|
@app_name
|
148
150
|
end
|
149
151
|
end
|
152
|
+
|
153
|
+
def cache_store
|
154
|
+
Avo::ExecutionContext.new(
|
155
|
+
target: @cache_store,
|
156
|
+
production_rejected_cache_stores: %w[ActiveSupport::Cache::MemoryStore ActiveSupport::Cache::NullStore]
|
157
|
+
).handle
|
158
|
+
end
|
159
|
+
|
160
|
+
# When not in production or test we'll just use the MemoryStore which is good enough.
|
161
|
+
# When running in production we'll use Rails.cache if it's not ActiveSupport::Cache::MemoryStore or ActiveSupport::Cache::NullStore.
|
162
|
+
# If it's one of rejected cache stores, we'll use the FileStore.
|
163
|
+
# We decided against the MemoryStore in production because it will not be shared between multiple processes (when using Puma).
|
164
|
+
def computed_cache_store
|
165
|
+
-> {
|
166
|
+
if Rails.env.production?
|
167
|
+
if Rails.cache.class.to_s.in?(production_rejected_cache_stores)
|
168
|
+
ActiveSupport::Cache.lookup_store(:file_store, Rails.root.join("tmp", "cache"))
|
169
|
+
else
|
170
|
+
Rails.cache
|
171
|
+
end
|
172
|
+
elsif Rails.env.test?
|
173
|
+
Rails.cache
|
174
|
+
else
|
175
|
+
ActiveSupport::Cache.lookup_store(:memory_store)
|
176
|
+
end
|
177
|
+
}
|
178
|
+
end
|
150
179
|
end
|
151
180
|
|
152
181
|
def self.configuration
|
@@ -30,9 +30,9 @@ module Avo
|
|
30
30
|
@params ||= Avo::App.params
|
31
31
|
@view_context ||= Avo::App.view_context
|
32
32
|
@current_user ||= Avo::App.current_user
|
33
|
-
@request ||= view_context
|
34
|
-
@main_app ||= view_context
|
35
|
-
@avo ||= view_context
|
33
|
+
@request ||= view_context&.request
|
34
|
+
@main_app ||= view_context&.main_app
|
35
|
+
@avo ||= view_context&.avo
|
36
36
|
end
|
37
37
|
|
38
38
|
# Return target if target is not callable, otherwise, execute target on this instance context
|
data/lib/avo/version.rb
CHANGED
@@ -47,6 +47,13 @@ Avo.configure do |config|
|
|
47
47
|
# config.per_page_steps = [12, 24, 48, 72]
|
48
48
|
# config.via_per_page = 8
|
49
49
|
# config.id_links_to_resource = false
|
50
|
+
|
51
|
+
## == Cache options ==
|
52
|
+
## Provide a lambda to customize the cache store used by Avo.
|
53
|
+
## We compute the cache store by default, this is NOT the default, just an example.
|
54
|
+
# config.cache_store = -> {
|
55
|
+
# ActiveSupport::Cache.lookup_store(:solid_cache_store)
|
56
|
+
# }
|
50
57
|
# config.cache_resources_on_index_view = true
|
51
58
|
## permanent enable or disable cache_resource_filters, default value is false
|
52
59
|
# config.cache_resource_filters = false
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.42.
|
4
|
+
version: 2.42.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Marin
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-10-
|
12
|
+
date: 2023-10-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|