ultra_settings 2.3.0 → 2.4.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 +6 -0
- data/README.md +22 -6
- data/VERSION +1 -1
- data/lib/ultra_settings/config_helper.rb +24 -0
- data/lib/ultra_settings.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90728a492b4f4d48193caf10b5a963160b9ff01e6e084541eb571ac3776ddf72
|
4
|
+
data.tar.gz: 98d035433486540669bd8a68d64e1c1f236a35a09567c77bfb59322ae538d94d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 154b003680b751f2137696ed7b7e489c8cd8c205f002c89a45f61ad25dd7c2c44151cd3e67bb64df4438b0cb08056b295f25da4ad4333340bbd6e5817bba64dc
|
7
|
+
data.tar.gz: 558fd5cbbf34f9dda4b9ec93d49bb13b1123291a1bdea625fdb4e314c76d28b0b8f63c12655ab86afbe77a63c72349c719c5d547ace4e5d927093876f4938607
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## 2.4.0
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- Added the `UltraSettings::ConfigHelper` module to add convenience methods `config` on the class and instance.
|
12
|
+
|
7
13
|
## 2.3.0
|
8
14
|
|
9
15
|
### Added
|
data/README.md
CHANGED
@@ -324,24 +324,40 @@ end
|
|
324
324
|
Rails.application.settings.my_service.host
|
325
325
|
```
|
326
326
|
|
327
|
-
#### Using
|
328
|
-
|
329
|
-
To keep your codebase clean, especially if most configurations are accessed from within a specific class, you can encapsulate the configuration access in a helper method.
|
327
|
+
#### Using Helper Methods
|
330
328
|
|
329
|
+
To streamline configuration access and keep your codebase clean, especially when configurations are frequently accessed within specific classes, you can encapsulate configuration access in a helper method:
|
331
330
|
|
332
331
|
```ruby
|
333
332
|
class MyService
|
334
|
-
|
335
|
-
|
333
|
+
def api_key
|
334
|
+
config.api_key
|
335
|
+
end
|
336
336
|
|
337
337
|
private
|
338
338
|
|
339
|
-
def
|
339
|
+
def config
|
340
340
|
MyServiceConfiguration.instance
|
341
341
|
end
|
342
342
|
end
|
343
343
|
```
|
344
344
|
|
345
|
+
#### Leveraging UltraSettings::ConfigHelper
|
346
|
+
|
347
|
+
For added convenience, you can use the UltraSettings::ConfigHelper module to automatically generate helper methods for accessing configurations at both the class and instance levels:
|
348
|
+
|
349
|
+
```ruby
|
350
|
+
class MyService
|
351
|
+
|
352
|
+
extend UltraSettings::ConfigHelper
|
353
|
+
configuration_class MyServiceConfiguration
|
354
|
+
|
355
|
+
# Adds these helper methods:
|
356
|
+
# - MyService.config
|
357
|
+
# - MyService.new.config
|
358
|
+
end
|
359
|
+
```
|
360
|
+
|
345
361
|
### Web UI
|
346
362
|
|
347
363
|
UltraSettings provides a web UI via a mountable Rack application. You can use this to view the settings values and documentation. The UI will not display the value of any setting marked as secret.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.4.0
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UltraSettings
|
4
|
+
# Helper module for setting up a class to use the config methods
|
5
|
+
#
|
6
|
+
# Usage:
|
7
|
+
# class TestClass
|
8
|
+
# extend UltraSettings::ConfigHelper
|
9
|
+
# configuration_class TestConfiguration
|
10
|
+
# end
|
11
|
+
# TestClass.config => TestConfiguration.instance
|
12
|
+
# TestClass.new.config => TestConfiguration.instance
|
13
|
+
module ConfigHelper
|
14
|
+
def configuration_class(config_class)
|
15
|
+
define_singleton_method :config do
|
16
|
+
config_class.instance
|
17
|
+
end
|
18
|
+
|
19
|
+
define_method :config do
|
20
|
+
self.class.config
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/ultra_settings.rb
CHANGED
@@ -10,6 +10,7 @@ require "uri"
|
|
10
10
|
|
11
11
|
require_relative "ultra_settings/configuration"
|
12
12
|
require_relative "ultra_settings/coerce"
|
13
|
+
require_relative "ultra_settings/config_helper"
|
13
14
|
require_relative "ultra_settings/field"
|
14
15
|
require_relative "ultra_settings/rack_app"
|
15
16
|
require_relative "ultra_settings/web_view"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ultra_settings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Durand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -46,6 +46,7 @@ files:
|
|
46
46
|
- lib/ultra_settings.rb
|
47
47
|
- lib/ultra_settings/application_view.rb
|
48
48
|
- lib/ultra_settings/coerce.rb
|
49
|
+
- lib/ultra_settings/config_helper.rb
|
49
50
|
- lib/ultra_settings/configuration.rb
|
50
51
|
- lib/ultra_settings/configuration_view.rb
|
51
52
|
- lib/ultra_settings/field.rb
|