settings_cabinet 0.1.0 → 1.1.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/.rubocop.yml +21 -11
- data/CHANGELOG.md +37 -0
- data/Gemfile +7 -5
- data/README.md +10 -3
- data/lib/settings_cabinet/base.rb +11 -3
- data/lib/settings_cabinet/settings.rb +6 -2
- data/lib/settings_cabinet/version.rb +1 -1
- data/settings_cabinet.gemspec +1 -1
- metadata +4 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 509c530243a696ede84eca06403d746457b419adb824cb07af100f6c05da5969
|
4
|
+
data.tar.gz: dc77cc37b894aec7b4a5787ab1039e593d0ff6ce8edd4be63a242dab01d8fd53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f84f5b0561a9a6745d7643f18a7520646e131fcf908b20a0ed6dcb74d82f863ec4f8c9eb3e916c4e82c5da32ce0d8fdf02fe8ad886422fc13319f4fe61e2381
|
7
|
+
data.tar.gz: b92d4ef2c22701f6eacae5555f5da09ee9e95a772f38c2350913ea7383ff0b9ed01c9b5b128e2d01e4fa38b5b27d35dcff8cd06e818deeb51bd9399a718ffe7c
|
data/.rubocop.yml
CHANGED
@@ -1,12 +1,25 @@
|
|
1
|
-
|
1
|
+
plugins:
|
2
2
|
- rubocop-performance
|
3
3
|
- rubocop-rake
|
4
4
|
- rubocop-rspec
|
5
5
|
|
6
6
|
AllCops:
|
7
|
-
TargetRubyVersion:
|
7
|
+
TargetRubyVersion: 3.0
|
8
8
|
NewCops: enable
|
9
9
|
|
10
|
+
Layout/LineLength:
|
11
|
+
Max: 120
|
12
|
+
|
13
|
+
Layout/MultilineMethodCallIndentation:
|
14
|
+
EnforcedStyle: indented
|
15
|
+
|
16
|
+
Metrics/BlockLength:
|
17
|
+
Exclude:
|
18
|
+
- spec/**/*
|
19
|
+
|
20
|
+
Naming/PredicateMethod:
|
21
|
+
AllowBangMethods: true
|
22
|
+
|
10
23
|
Style/Documentation:
|
11
24
|
Enabled: false
|
12
25
|
|
@@ -18,12 +31,9 @@ Style/StringLiteralsInInterpolation:
|
|
18
31
|
Enabled: true
|
19
32
|
EnforcedStyle: double_quotes
|
20
33
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
Metrics/BlockLength:
|
28
|
-
Exclude:
|
29
|
-
- spec/**/*
|
34
|
+
RSpec/ExampleLength:
|
35
|
+
CountAsOne:
|
36
|
+
- array
|
37
|
+
- hash
|
38
|
+
- heredoc
|
39
|
+
- method_call
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,42 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
|
4
|
+
## [1.1.0] - 2025-08-26
|
5
|
+
|
6
|
+
## Changes
|
7
|
+
|
8
|
+
* Add keys method support for Hash structures
|
9
|
+
+ [PR#5](https://github.com/yujideveloper/settings_cabinet/pull/5)
|
10
|
+
* Support top-level Settings.keys for consistent key access
|
11
|
+
+ [PR#9](https://github.com/yujideveloper/settings_cabinet/pull/9)
|
12
|
+
|
13
|
+
### Misc
|
14
|
+
|
15
|
+
* CI against for Ruby 3.4
|
16
|
+
+ [PR#6](https://github.com/yujideveloper/settings_cabinet/pull/6)
|
17
|
+
* Update rubocop config
|
18
|
+
+ [PR#7](https://github.com/yujideveloper/settings_cabinet/pull/7)
|
19
|
+
* Add irb to `Gemfile`
|
20
|
+
+ [PR#8](https://github.com/yujideveloper/settings_cabinet/pull/8)
|
21
|
+
|
22
|
+
|
23
|
+
## [1.0.0] - 2024-07-23
|
24
|
+
|
25
|
+
### Changes
|
26
|
+
|
27
|
+
* Add Ruby 3.2 support
|
28
|
+
+ [PR#3](https://github.com/yujideveloper/settings_cabinet/pull/3)
|
29
|
+
* Add Ruby 3.3 support and drop Ruby 2.7 support
|
30
|
+
+ [PR#4](https://github.com/yujideveloper/settings_cabinet/pull/4)
|
31
|
+
|
32
|
+
### Misc
|
33
|
+
|
34
|
+
* Update required rubocop version
|
35
|
+
+ [PR#1](https://github.com/yujideveloper/settings_cabinet/pull/1)
|
36
|
+
* Fix examples in README.md
|
37
|
+
* + [PR#2](https://github.com/yujideveloper/settings_cabinet/pull/2)
|
38
|
+
|
39
|
+
|
3
40
|
## [0.1.0] - 2022-04-23
|
4
41
|
|
5
42
|
* Initial release
|
data/Gemfile
CHANGED
@@ -7,8 +7,10 @@ gemspec
|
|
7
7
|
|
8
8
|
gem "rake", "~> 13.0"
|
9
9
|
|
10
|
-
gem "
|
11
|
-
|
12
|
-
gem "
|
13
|
-
gem "rubocop
|
14
|
-
gem "rubocop-
|
10
|
+
gem "irb"
|
11
|
+
|
12
|
+
gem "rspec", "~> 3.13", require: false
|
13
|
+
gem "rubocop", "~> 1.79", require: false
|
14
|
+
gem "rubocop-performance", "~> 1.25", require: false
|
15
|
+
gem "rubocop-rake", "~> 0.7", require: false
|
16
|
+
gem "rubocop-rspec", "~> 3.6", require: false
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# SettingsCabinet
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/settings_cabinet)
|
4
|
+
[](https://github.com/yujideveloper/settings_cabinet/actions/workflows/main.yml)
|
5
|
+
|
3
6
|
SettingsCabinet is a simple settings solution with ERB-enabled YAML file like [settingslogic](https://github.com/settingslogic/settingslogic).
|
4
7
|
|
5
8
|
## Installation
|
@@ -23,7 +26,7 @@ Or install it yourself as:
|
|
23
26
|
DSL is very similar to settingslogic.
|
24
27
|
|
25
28
|
```ruby
|
26
|
-
class Settings < SettingsCabinet
|
29
|
+
class Settings < SettingsCabinet::Base
|
27
30
|
using SettingsCabinet::DSL
|
28
31
|
|
29
32
|
source Rails.root.join("config", "settings.yml")
|
@@ -32,7 +35,7 @@ end
|
|
32
35
|
```
|
33
36
|
|
34
37
|
| Name | Type | Description | Default | Optional |
|
35
|
-
|
38
|
+
|--|--|--|--|--|
|
36
39
|
| `source` | String | Path of settings file. | - | No |
|
37
40
|
| `namespace` | String | Using a namespace allows you to change your configuration depending on your environment. e.g. `Rails.env` | `nil` | Yes |
|
38
41
|
| `permitted_classes` | Array of Class | Arbitrary classes can be allowed by adding those classes to the allowlist. e.g. `[Date, Time]` | `[]` | Yes |
|
@@ -61,6 +64,10 @@ Accessors are defined in the same way as settingslogic, but writers do not.
|
|
61
64
|
```ruby
|
62
65
|
Settings.foo.bar #=> "nested setting"
|
63
66
|
Settings[:baz] #=> 9
|
67
|
+
|
68
|
+
# Hash Keys Support - Get all available keys from Hash structures
|
69
|
+
Settings.foo.keys #=> [:bar]
|
70
|
+
Settings.keys #=> [:foo, :baz, :quz]
|
64
71
|
```
|
65
72
|
|
66
73
|
You can explicitly load all your settings, if needed.
|
@@ -71,7 +78,7 @@ Settings.load!
|
|
71
78
|
```
|
72
79
|
or
|
73
80
|
```ruby
|
74
|
-
class Settings < SettingsCabinet
|
81
|
+
class Settings < SettingsCabinet::Base
|
75
82
|
using SettingsCabinet::DSL
|
76
83
|
using SettingsCabinet::Control
|
77
84
|
|
@@ -93,11 +93,11 @@ module SettingsCabinet
|
|
93
93
|
end
|
94
94
|
|
95
95
|
def [](...)
|
96
|
-
@settings.[](...)
|
96
|
+
@settings.[](...)
|
97
97
|
end
|
98
98
|
|
99
99
|
def dig(...)
|
100
|
-
@settings.dig(...)
|
100
|
+
@settings.dig(...)
|
101
101
|
end
|
102
102
|
|
103
103
|
def fetch(...)
|
@@ -116,12 +116,16 @@ module SettingsCabinet
|
|
116
116
|
@settings.to_h(...)
|
117
117
|
end
|
118
118
|
|
119
|
+
def keys(...)
|
120
|
+
@settings.keys(...)
|
121
|
+
end
|
122
|
+
|
119
123
|
def self.[](...)
|
120
124
|
instance.[](...)
|
121
125
|
end
|
122
126
|
|
123
127
|
def self.dig(...)
|
124
|
-
instance.dig(...)
|
128
|
+
instance.dig(...)
|
125
129
|
end
|
126
130
|
|
127
131
|
def self.fetch(...)
|
@@ -140,6 +144,10 @@ module SettingsCabinet
|
|
140
144
|
instance.to_h(...)
|
141
145
|
end
|
142
146
|
|
147
|
+
def self.keys(...)
|
148
|
+
instance.keys(...)
|
149
|
+
end
|
150
|
+
|
143
151
|
def self.method_missing(...)
|
144
152
|
instance.public_send(...)
|
145
153
|
end
|
@@ -39,8 +39,8 @@ module SettingsCabinet
|
|
39
39
|
@values.dig(*keys)
|
40
40
|
end
|
41
41
|
|
42
|
-
def fetch(key,
|
43
|
-
@values.fetch(key.to_sym,
|
42
|
+
def fetch(key, ...)
|
43
|
+
@values.fetch(key.to_sym, ...)
|
44
44
|
end
|
45
45
|
|
46
46
|
def fetch_values(*keys, &block)
|
@@ -54,5 +54,9 @@ module SettingsCabinet
|
|
54
54
|
def to_h
|
55
55
|
@values.transform_values { |v| v.is_a?(self.class) ? v.to_h : v }
|
56
56
|
end
|
57
|
+
|
58
|
+
def keys
|
59
|
+
@values.keys
|
60
|
+
end
|
57
61
|
end
|
58
62
|
end
|
data/settings_cabinet.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = "A simple settings solution with ERB-enabled YAML file"
|
13
13
|
spec.homepage = "https://github.com/yujideveloper/settings_cabinet"
|
14
14
|
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = ">=
|
15
|
+
spec.required_ruby_version = ">= 3.0"
|
16
16
|
|
17
17
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
18
18
|
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: settings_cabinet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuji Hanamura
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
12
|
description: A simple settings solution with ERB-enabled YAML file
|
14
13
|
email:
|
@@ -43,7 +42,6 @@ metadata:
|
|
43
42
|
source_code_uri: https://github.com/yujideveloper/settings_cabinet
|
44
43
|
changelog_uri: https://github.com/yujideveloper/settings_cabinet/tree/main/CHANGELOG.md
|
45
44
|
rubygems_mfa_required: 'true'
|
46
|
-
post_install_message:
|
47
45
|
rdoc_options: []
|
48
46
|
require_paths:
|
49
47
|
- lib
|
@@ -51,15 +49,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
51
49
|
requirements:
|
52
50
|
- - ">="
|
53
51
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
52
|
+
version: '3.0'
|
55
53
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
54
|
requirements:
|
57
55
|
- - ">="
|
58
56
|
- !ruby/object:Gem::Version
|
59
57
|
version: '0'
|
60
58
|
requirements: []
|
61
|
-
rubygems_version: 3.
|
62
|
-
signing_key:
|
59
|
+
rubygems_version: 3.6.9
|
63
60
|
specification_version: 4
|
64
61
|
summary: A simple settings solution with ERB-enabled YAML file
|
65
62
|
test_files: []
|