ultra_settings 2.6.1 → 2.8.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 +4 -4
- data/CHANGELOG.md +22 -1
- data/README.md +6 -4
- data/VERSION +1 -1
- data/app/_config_description.html.erb +30 -0
- data/app/_config_list.html.erb +14 -0
- data/app/_select_menu.html.erb +53 -0
- data/app/application.css +172 -34
- data/app/application.js +108 -25
- data/app/configuration.html.erb +57 -24
- data/app/index.html.erb +21 -16
- data/lib/ultra_settings/application_view.rb +20 -10
- data/lib/ultra_settings/coerce.rb +3 -0
- data/lib/ultra_settings/config_helper.rb +12 -8
- data/lib/ultra_settings/configuration.rb +41 -8
- data/lib/ultra_settings/configuration_view.rb +12 -6
- data/lib/ultra_settings/field.rb +3 -2
- data/lib/ultra_settings/rack_app.rb +7 -0
- data/lib/ultra_settings/render_helper.rb +28 -0
- data/lib/ultra_settings/uninitialized_runtime_settings.rb +12 -7
- data/lib/ultra_settings/view_helper.rb +19 -0
- data/lib/ultra_settings/web_view.rb +9 -1
- data/lib/ultra_settings/yaml_config.rb +7 -0
- data/lib/ultra_settings.rb +49 -3
- metadata +7 -7
|
@@ -33,11 +33,18 @@ module UltraSettings
|
|
|
33
33
|
# In addition, the keys are flattened into a one level deep hash with dots
|
|
34
34
|
# separating the keys.
|
|
35
35
|
class YamlConfig
|
|
36
|
+
# Initialize a YAML configuration loader.
|
|
37
|
+
#
|
|
38
|
+
# @param path [String, Pathname] The path to the YAML configuration file.
|
|
39
|
+
# @param environment [String] The environment section to load from the YAML file.
|
|
36
40
|
def initialize(path, environment)
|
|
37
41
|
yaml = load_yaml(path)
|
|
38
42
|
@config = environment_config(yaml, environment)
|
|
39
43
|
end
|
|
40
44
|
|
|
45
|
+
# Convert the loaded configuration to a hash.
|
|
46
|
+
#
|
|
47
|
+
# @return [Hash] The flattened configuration hash.
|
|
41
48
|
def to_h
|
|
42
49
|
@config
|
|
43
50
|
end
|
data/lib/ultra_settings.rb
CHANGED
|
@@ -14,6 +14,7 @@ require_relative "ultra_settings/config_helper"
|
|
|
14
14
|
require_relative "ultra_settings/field"
|
|
15
15
|
require_relative "ultra_settings/rack_app"
|
|
16
16
|
require_relative "ultra_settings/view_helper"
|
|
17
|
+
require_relative "ultra_settings/render_helper"
|
|
17
18
|
require_relative "ultra_settings/web_view"
|
|
18
19
|
require_relative "ultra_settings/application_view"
|
|
19
20
|
require_relative "ultra_settings/configuration_view"
|
|
@@ -38,6 +39,7 @@ module UltraSettings
|
|
|
38
39
|
@mutex = Mutex.new
|
|
39
40
|
@runtime_settings = nil
|
|
40
41
|
@runtime_settings_url = nil
|
|
42
|
+
@runtime_settings_secure = true
|
|
41
43
|
|
|
42
44
|
class << self
|
|
43
45
|
# Adds a configuration to the root namespace. The configuration will be
|
|
@@ -111,6 +113,7 @@ module UltraSettings
|
|
|
111
113
|
# Defaults to "development".
|
|
112
114
|
#
|
|
113
115
|
# @param value [String] The environment name to use.
|
|
116
|
+
# @return [void]
|
|
114
117
|
def yaml_config_env=(value)
|
|
115
118
|
Configuration.yaml_config_env = value
|
|
116
119
|
end
|
|
@@ -128,6 +131,7 @@ module UltraSettings
|
|
|
128
131
|
# this is a period.
|
|
129
132
|
#
|
|
130
133
|
# @param value [String] The delimiter to use.
|
|
134
|
+
# @return [void]
|
|
131
135
|
def runtime_setting_delimiter=(value)
|
|
132
136
|
Configuration.runtime_setting_delimiter = value.to_s
|
|
133
137
|
end
|
|
@@ -162,6 +166,9 @@ module UltraSettings
|
|
|
162
166
|
# Set the object to use for runtime settings. This can be any object that
|
|
163
167
|
# responds to the [] method. If you are using the `super_settings` gem,
|
|
164
168
|
# you can set this to `SuperSettings`.
|
|
169
|
+
#
|
|
170
|
+
# @param value [#[]] The object to use for runtime settings.
|
|
171
|
+
# @return [void]
|
|
165
172
|
attr_writer :runtime_settings
|
|
166
173
|
|
|
167
174
|
# Get the object to use for runtime settings.
|
|
@@ -176,21 +183,46 @@ module UltraSettings
|
|
|
176
183
|
# URL will be displayed in the web view for fields that support runtime settings.
|
|
177
184
|
# The URL may contain a `${name}` placeholder that will be replaced with the name
|
|
178
185
|
# of the setting.
|
|
186
|
+
#
|
|
187
|
+
# @param value [String] The URL for changing runtime settings.
|
|
188
|
+
# @return [void]
|
|
179
189
|
attr_writer :runtime_settings_url
|
|
180
190
|
|
|
181
191
|
# Get the URL for changing runtime settings.
|
|
182
192
|
#
|
|
183
193
|
# @param name [String] The name of the setting.
|
|
194
|
+
# @param type [String] The type of the setting.
|
|
195
|
+
# @param description [String] The description of the setting.
|
|
184
196
|
# @return [String, nil]
|
|
185
197
|
# @api private
|
|
186
|
-
def runtime_settings_url(name, type)
|
|
198
|
+
def runtime_settings_url(name: nil, type: nil, description: nil)
|
|
187
199
|
url = @runtime_settings_url.to_s
|
|
188
200
|
return nil if url.empty?
|
|
189
201
|
|
|
190
|
-
url
|
|
191
|
-
|
|
202
|
+
url.gsub("${name}", URI.encode_www_form_component(name.to_s))
|
|
203
|
+
.gsub("${type}", URI.encode_www_form_component(type.to_s))
|
|
204
|
+
.gsub("${description}", URI.encode_www_form_component(description.to_s))
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
# Set whether or not the runtime settings engine is considered secure. If this is set
|
|
208
|
+
# to false, then runtime settings will be disabled for all fields marked as secret.
|
|
209
|
+
# The default value is true.
|
|
210
|
+
#
|
|
211
|
+
# @param value [Boolean] Whether the runtime settings engine is secure.
|
|
212
|
+
# @return [void]
|
|
213
|
+
attr_writer :runtime_settings_secure
|
|
214
|
+
|
|
215
|
+
# Check if the runtime settings engine is considered secure.
|
|
216
|
+
#
|
|
217
|
+
# @return [Boolean]
|
|
218
|
+
def runtime_settings_secure?
|
|
219
|
+
@runtime_settings_secure
|
|
192
220
|
end
|
|
193
221
|
|
|
222
|
+
# Set whether fields should be considered secret by default.
|
|
223
|
+
#
|
|
224
|
+
# @param value [Boolean] Whether fields should be secret by default.
|
|
225
|
+
# @return [void]
|
|
194
226
|
def fields_secret_by_default=(value)
|
|
195
227
|
Configuration.fields_secret_by_default = value
|
|
196
228
|
end
|
|
@@ -228,6 +260,19 @@ module UltraSettings
|
|
|
228
260
|
@configurations.keys
|
|
229
261
|
end
|
|
230
262
|
|
|
263
|
+
# Get an array of all of the configuration instances that have been loaded into memory.
|
|
264
|
+
#
|
|
265
|
+
# @return [Array<UltraSettings::Configuration>] The configuration instances.
|
|
266
|
+
# @api private
|
|
267
|
+
def __configurations__
|
|
268
|
+
@configurations.each do |name, class_name|
|
|
269
|
+
__load_config__(name, class_name)
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
config_classes = ObjectSpace.each_object(Class).select { |klass| klass < Configuration }
|
|
273
|
+
config_classes.collect(&:instance)
|
|
274
|
+
end
|
|
275
|
+
|
|
231
276
|
private
|
|
232
277
|
|
|
233
278
|
# Load a configuration class.
|
|
@@ -245,6 +290,7 @@ module UltraSettings
|
|
|
245
290
|
unless klass < Configuration
|
|
246
291
|
raise TypeError.new("Configuration class #{class_name} does not inherit from UltraSettings::Configuration")
|
|
247
292
|
end
|
|
293
|
+
|
|
248
294
|
@configurations[name] = klass
|
|
249
295
|
end
|
|
250
296
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ultra_settings
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brian Durand
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: bundler
|
|
@@ -24,7 +23,6 @@ dependencies:
|
|
|
24
23
|
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '0'
|
|
27
|
-
description:
|
|
28
26
|
email:
|
|
29
27
|
- bbdurand@gmail.com
|
|
30
28
|
executables: []
|
|
@@ -36,6 +34,9 @@ files:
|
|
|
36
34
|
- MIT-LICENSE.txt
|
|
37
35
|
- README.md
|
|
38
36
|
- VERSION
|
|
37
|
+
- app/_config_description.html.erb
|
|
38
|
+
- app/_config_list.html.erb
|
|
39
|
+
- app/_select_menu.html.erb
|
|
39
40
|
- app/application.css
|
|
40
41
|
- app/application.js
|
|
41
42
|
- app/application_vars.css.erb
|
|
@@ -53,6 +54,7 @@ files:
|
|
|
53
54
|
- lib/ultra_settings/field.rb
|
|
54
55
|
- lib/ultra_settings/rack_app.rb
|
|
55
56
|
- lib/ultra_settings/railtie.rb
|
|
57
|
+
- lib/ultra_settings/render_helper.rb
|
|
56
58
|
- lib/ultra_settings/uninitialized_runtime_settings.rb
|
|
57
59
|
- lib/ultra_settings/version.rb
|
|
58
60
|
- lib/ultra_settings/view_helper.rb
|
|
@@ -66,7 +68,6 @@ metadata:
|
|
|
66
68
|
homepage_uri: https://github.com/bdurand/ultra_settings
|
|
67
69
|
source_code_uri: https://github.com/bdurand/ultra_settings
|
|
68
70
|
changelog_uri: https://github.com/bdurand/ultra_settings/blob/main/CHANGELOG.md
|
|
69
|
-
post_install_message:
|
|
70
71
|
rdoc_options: []
|
|
71
72
|
require_paths:
|
|
72
73
|
- lib
|
|
@@ -81,8 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
81
82
|
- !ruby/object:Gem::Version
|
|
82
83
|
version: '0'
|
|
83
84
|
requirements: []
|
|
84
|
-
rubygems_version: 3.
|
|
85
|
-
signing_key:
|
|
85
|
+
rubygems_version: 3.6.9
|
|
86
86
|
specification_version: 4
|
|
87
87
|
summary: UltraSettings is a Ruby gem that provides a flexible and documented approach
|
|
88
88
|
to managing application configurations from multiple sources, including environment
|