ultra_settings 2.10.0 → 2.10.1
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/CHANGELOG.md +26 -0
- data/README.md +18 -0
- data/VERSION +1 -1
- data/app/_config_description.html.erb +10 -1
- data/app/_data_source.html.erb +2 -2
- data/app/application.css +116 -24
- data/app/application_vars.css.erb +30 -12
- data/app/configuration.html.erb +19 -1
- data/app/layout.css +5 -5
- data/app/layout_vars.css.erb +4 -4
- data/app/locales/ar.json +5 -2
- data/app/locales/cs.json +5 -2
- data/app/locales/da.json +5 -2
- data/app/locales/de.json +5 -2
- data/app/locales/el.json +5 -2
- data/app/locales/en.json +5 -2
- data/app/locales/es.json +5 -2
- data/app/locales/fa.json +5 -2
- data/app/locales/fr.json +5 -2
- data/app/locales/gd.json +5 -2
- data/app/locales/he.json +5 -2
- data/app/locales/hi.json +5 -2
- data/app/locales/it.json +5 -2
- data/app/locales/ja.json +5 -2
- data/app/locales/ko.json +5 -2
- data/app/locales/lt.json +5 -2
- data/app/locales/nb.json +5 -2
- data/app/locales/nl.json +5 -2
- data/app/locales/pl.json +5 -2
- data/app/locales/pt-br.json +5 -2
- data/app/locales/pt.json +5 -2
- data/app/locales/ru.json +5 -2
- data/app/locales/sv.json +5 -2
- data/app/locales/ta.json +5 -2
- data/app/locales/tr.json +5 -2
- data/app/locales/uk.json +5 -2
- data/app/locales/ur.json +5 -2
- data/app/locales/vi.json +5 -2
- data/app/locales/zh-cn.json +5 -2
- data/app/locales/zh-tw.json +5 -2
- data/lib/ultra_settings/application_view.rb +13 -4
- data/lib/ultra_settings/audit_data_sources.rb +1 -1
- data/lib/ultra_settings/coerce.rb +1 -1
- data/lib/ultra_settings/configuration.rb +36 -10
- data/lib/ultra_settings/configuration_view.rb +166 -9
- data/lib/ultra_settings/mini_i18n.rb +14 -10
- data/lib/ultra_settings/rack_app.rb +4 -4
- data/lib/ultra_settings/view_helper.rb +27 -5
- data/lib/ultra_settings/web_view.rb +17 -10
- data/lib/ultra_settings/yaml_config.rb +10 -2
- data/lib/ultra_settings.rb +57 -1
- data/ultra_settings.gemspec +1 -1
- metadata +2 -2
data/lib/ultra_settings.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "erb"
|
|
4
4
|
require "yaml"
|
|
5
|
+
require "date"
|
|
5
6
|
require "time"
|
|
6
7
|
require "pathname"
|
|
7
8
|
require "singleton"
|
|
@@ -32,6 +33,10 @@ module UltraSettings
|
|
|
32
33
|
|
|
33
34
|
VALID_NAME_PATTERN = /\A[a-z_][a-zA-Z0-9_]*\z/
|
|
34
35
|
|
|
36
|
+
# Thread local key used to make the runtime settings reload in the web views reentrant.
|
|
37
|
+
RELOAD_GUARD_KEY = :ultra_settings_runtime_settings_reloaded
|
|
38
|
+
private_constant :RELOAD_GUARD_KEY
|
|
39
|
+
|
|
35
40
|
@configurations = {}
|
|
36
41
|
@mutex = Mutex.new
|
|
37
42
|
@runtime_settings = nil
|
|
@@ -177,6 +182,57 @@ module UltraSettings
|
|
|
177
182
|
@runtime_settings
|
|
178
183
|
end
|
|
179
184
|
|
|
185
|
+
# Reload the runtime settings cache and then yield to the block. The web views call
|
|
186
|
+
# this when rendering so that a setting changed from the UI is displayed on the next
|
|
187
|
+
# page load rather than whenever the runtime settings engine gets around to
|
|
188
|
+
# refreshing itself.
|
|
189
|
+
#
|
|
190
|
+
# The runtime settings object is reloaded if it responds to `load_settings`. The
|
|
191
|
+
# `super_settings` gem does, as does anything that delegates to it.
|
|
192
|
+
#
|
|
193
|
+
# Calls are reentrant, so a block that renders several views only reloads once.
|
|
194
|
+
# Wrap a page that embeds more than one `ConfigurationView` in this method to avoid
|
|
195
|
+
# reloading the runtime settings once per view.
|
|
196
|
+
#
|
|
197
|
+
# Errors are not fatal; the page can still show values from the other sources.
|
|
198
|
+
#
|
|
199
|
+
# @example Rendering several configurations with a single reload.
|
|
200
|
+
# UltraSettings.with_runtime_settings_reloaded do
|
|
201
|
+
# configurations.each { |config| output << UltraSettings::ConfigurationView.new(config).render }
|
|
202
|
+
# end
|
|
203
|
+
#
|
|
204
|
+
# @return [Object] The result of the block.
|
|
205
|
+
def with_runtime_settings_reloaded
|
|
206
|
+
return yield if Thread.current[RELOAD_GUARD_KEY]
|
|
207
|
+
|
|
208
|
+
Thread.current[RELOAD_GUARD_KEY] = true
|
|
209
|
+
begin
|
|
210
|
+
settings = __runtime_settings__
|
|
211
|
+
if settings.respond_to?(:load_settings)
|
|
212
|
+
begin
|
|
213
|
+
settings.load_settings
|
|
214
|
+
rescue => e
|
|
215
|
+
warn("UltraSettings: unable to reload runtime settings: #{e.class}: #{e.message}")
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
yield
|
|
220
|
+
ensure
|
|
221
|
+
Thread.current[RELOAD_GUARD_KEY] = nil
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# Returns true if the application is running in development mode. This is used by the
|
|
226
|
+
# web UI to decide if templates, stylesheets, and translations can be cached in memory
|
|
227
|
+
# or if they need to be re-read from disk on every request.
|
|
228
|
+
#
|
|
229
|
+
# @return [Boolean]
|
|
230
|
+
# @api private
|
|
231
|
+
def __development_mode__?
|
|
232
|
+
env = ENV["RAILS_ENV"] || ENV["RACK_ENV"] || ENV["APP_ENV"] || "development"
|
|
233
|
+
env == "development"
|
|
234
|
+
end
|
|
235
|
+
|
|
180
236
|
# Set the URL for changing runtime settings. If this is set, then a link to the
|
|
181
237
|
# URL will be displayed in the web view for fields that support runtime settings.
|
|
182
238
|
# The URL may contain a `${name}` placeholder that will be replaced with the name
|
|
@@ -266,7 +322,7 @@ module UltraSettings
|
|
|
266
322
|
settings = settings.to_a
|
|
267
323
|
config_name, values = settings.first
|
|
268
324
|
config_name = config_name.to_s
|
|
269
|
-
other_settings = settings[1
|
|
325
|
+
other_settings = settings[1..]
|
|
270
326
|
|
|
271
327
|
unless @configurations.include?(config_name)
|
|
272
328
|
raise ArgumentError.new("Unknown configuration: #{config_name.inspect}")
|
data/ultra_settings.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ultra_settings
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.10.
|
|
4
|
+
version: 2.10.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brian Durand
|
|
@@ -110,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
110
110
|
requirements:
|
|
111
111
|
- - ">="
|
|
112
112
|
- !ruby/object:Gem::Version
|
|
113
|
-
version: '2.
|
|
113
|
+
version: '2.6'
|
|
114
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
requirements:
|
|
116
116
|
- - ">="
|