configx 0.4.0 → 0.6.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/README.md +97 -50
- data/lib/config_x/builder.rb +16 -9
- data/lib/config_x/config.rb +8 -37
- data/lib/config_x/config_factory.rb +13 -4
- data/lib/config_x/configurable.rb +23 -0
- data/lib/config_x/env_source.rb +1 -1
- data/lib/config_x/hash_source.rb +16 -1
- data/lib/config_x/untyped_config.rb +43 -0
- data/lib/config_x/version.rb +1 -1
- data/lib/config_x.rb +7 -4
- metadata +5 -12
- data/sig/config_x/builder.rbs +0 -21
- data/sig/config_x/config.rbs +0 -13
- data/sig/config_x/config_factory.rbs +0 -55
- data/sig/config_x/env_source.rbs +0 -11
- data/sig/config_x/file_source.rbs +0 -7
- data/sig/config_x/hash_source.rbs +0 -8
- data/sig/config_x/source.rbs +0 -8
- data/sig/config_x/yaml_source.rbs +0 -10
- data/sig/config_x.rbs +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16db5f1190ac4fbe24e85387f7b3ca7bee509c7e6708d0e637b48eb2303bf3c9
|
4
|
+
data.tar.gz: b985146110a368f9dc5cab2aa981fff7b12ca0d39a544a43448b9da9cff26241
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4397f851488af93b623e1c61090e7d1ecfb790ed800e1fd2667c89bd90de72a5ad8d66ffecf3cf44318a11fafe4764ef1e69d5f6d14c4c7c75f1d2694ff0ee0
|
7
|
+
data.tar.gz: ad768e3b2a8e4fe5f9da813ea959f063b69899637c1cf6550b064bf367fa2ac76f863befc26ac090ced67e8b980e040ba98e73a99ad4491c4e07a2b0ee6343f1
|
data/README.md
CHANGED
@@ -1,31 +1,34 @@
|
|
1
1
|
# ⚙️ConfigX
|
2
2
|
|
3
|
-
ConfigX is a
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
not define a global objects and allows you having multiple independent configurations.
|
3
|
+
ConfigX is a lightweight configuration library that helps you manage settings for applications or libraries.
|
4
|
+
Unlike other configuration libraries, ConfigX does not allow configuring arbitrary Ruby objects. Instead,
|
5
|
+
it focuses on loading configuration from YAML files and environment variables into structured Ruby objects.
|
6
|
+
Inspired by the [config] gem, ConfigX avoids defining global objects and supports multiple
|
7
|
+
independent configurations.
|
9
8
|
|
10
9
|
## Installation
|
11
10
|
|
12
|
-
|
11
|
+
To install, add the gem to your Gemfile:
|
13
12
|
|
14
|
-
|
13
|
+
```bash
|
14
|
+
$ bundle add configx
|
15
|
+
```
|
15
16
|
|
16
|
-
|
17
|
+
Or, if you’re not using Bundler:
|
17
18
|
|
18
|
-
|
19
|
+
```bash
|
20
|
+
$ gem install configx
|
21
|
+
```
|
19
22
|
|
20
23
|
## Usage
|
21
24
|
|
22
|
-
|
25
|
+
To load configuration from the default locations, use:
|
23
26
|
|
24
27
|
```ruby
|
25
28
|
config = ConfigX.load
|
26
29
|
```
|
27
30
|
|
28
|
-
|
31
|
+
This loads configuration from the following sources in order:
|
29
32
|
|
30
33
|
1. `config/settings.yml`
|
31
34
|
2. `config/settings/production.yml`
|
@@ -33,7 +36,7 @@ It loads configuration from the following locations in the specified order:
|
|
33
36
|
4. `config/settings/production.local.yml`
|
34
37
|
5. Environment variables
|
35
38
|
|
36
|
-
|
39
|
+
The configuration is merged in an intuitive way, with environment variables taking precedence. For example:
|
37
40
|
|
38
41
|
* **config/settings.yml**
|
39
42
|
|
@@ -59,18 +62,18 @@ api:
|
|
59
62
|
export SETTINGS__API__ACCESS_TOKEN=foobar
|
60
63
|
```
|
61
64
|
|
62
|
-
|
65
|
+
Results in:
|
63
66
|
|
64
67
|
```ruby
|
65
68
|
config = ConfigX.load
|
66
69
|
config.api.enabled # => true
|
67
70
|
config.api.endpoint # => "https://example.com"
|
68
|
-
config.api.
|
71
|
+
config.api.access_token # => "foobar"
|
69
72
|
```
|
70
73
|
|
71
74
|
### Customizing Configuration
|
72
75
|
|
73
|
-
You can customize
|
76
|
+
You can customize how configurations are loaded:
|
74
77
|
|
75
78
|
```ruby
|
76
79
|
ConfigX.load(
|
@@ -83,25 +86,26 @@ ConfigX.load(
|
|
83
86
|
)
|
84
87
|
```
|
85
88
|
|
86
|
-
|
87
|
-
|
89
|
+
Explanation of options:
|
90
|
+
|
91
|
+
* `env`, `dir_name`, `file_name`, and `config_root` specify where to look for configuration files.
|
92
|
+
|
93
|
+
In this example ConfigX will look for configuration files in the following order:
|
88
94
|
|
89
95
|
1. `{config_root}/{file_name}.yml`
|
90
96
|
2. `{config_root}/{file_name}/{env}.yml`
|
91
97
|
3. `{config_root}/{file_name}.local.yml`
|
92
98
|
4. `{config_root}/{file_name}/{env}.local.yml`
|
93
99
|
|
100
|
+
* `env_prefix` and `env_separator` define how environment variables map to configuration keys.
|
94
101
|
|
95
|
-
|
96
|
-
the above example, they start from `SETTINGS` and use `__` as a separator.
|
97
|
-
|
98
|
-
For instance, the following environment variable:
|
102
|
+
For example, with the following environment variable:
|
99
103
|
|
100
104
|
```
|
101
105
|
export SETTINGS__API__ACCESS_TOKEN=foobar
|
102
106
|
```
|
103
107
|
|
104
|
-
|
108
|
+
ConfigX loads it into:
|
105
109
|
|
106
110
|
```yaml
|
107
111
|
---
|
@@ -109,65 +113,107 @@ api:
|
|
109
113
|
access_token: foobar
|
110
114
|
```
|
111
115
|
|
112
|
-
|
116
|
+
### Environment Variable Parsing
|
117
|
+
|
118
|
+
ConfigX automatically parses environment variable values and converts them to the appropriate types where possible.
|
119
|
+
It handles strings, booleans, numbers, and even arrays. The following types are supported:
|
120
|
+
|
121
|
+
#### Booleans:
|
113
122
|
|
114
|
-
```
|
123
|
+
```bash
|
115
124
|
export SETTINGS__API__ENABLED=true
|
116
125
|
export SETTINGS__API__ENABLED=false
|
117
126
|
export SETTINGS__API__ENABLED=on
|
118
127
|
export SETTINGS__API__ENABLED=off
|
119
128
|
```
|
120
129
|
|
121
|
-
|
130
|
+
These values will be parsed into their corresponding boolean types (`true` or `false`):
|
122
131
|
|
123
|
-
|
132
|
+
```ruby
|
133
|
+
config.api.enabled # => true or false
|
134
|
+
```
|
124
135
|
|
125
|
-
|
126
|
-
|
136
|
+
#### Numbers:
|
137
|
+
|
138
|
+
```bash
|
139
|
+
export SETTINGS__API__RETRY_COUNT=5
|
140
|
+
export SETTINGS__API__TIMEOUT=30.5
|
141
|
+
```
|
127
142
|
|
128
|
-
|
143
|
+
Numeric values will be parsed as either integers or floats:
|
129
144
|
|
130
145
|
```ruby
|
131
|
-
config
|
132
|
-
|
133
|
-
|
146
|
+
config.api.retry_count # => 5
|
147
|
+
config.api.timeout # => 30.5
|
148
|
+
```
|
134
149
|
|
135
|
-
|
150
|
+
|
151
|
+
#### Arrays:
|
152
|
+
|
153
|
+
Arrays can be specified by using comma-separated values:
|
154
|
+
|
155
|
+
```bash
|
156
|
+
export SETTINGS__API__SERVERS='["server1","server2","server3"]'
|
136
157
|
```
|
137
158
|
|
138
|
-
|
159
|
+
This will be parsed as an array:
|
139
160
|
|
140
161
|
```ruby
|
141
|
-
config
|
142
|
-
.add_source('config/settings.yml')
|
143
|
-
.load
|
162
|
+
config.api.servers # => ["server1", "server2", "server3"]
|
144
163
|
```
|
145
164
|
|
146
|
-
3. Environment variables
|
147
165
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
166
|
+
#### Strings:
|
167
|
+
|
168
|
+
Regular string values remain unchanged:
|
169
|
+
|
170
|
+
```bash
|
171
|
+
export SETTINGS__API__ACCESS_TOKEN="my_secret_token"
|
152
172
|
```
|
153
173
|
|
154
|
-
|
174
|
+
This will simply be loaded as a string:
|
155
175
|
|
156
176
|
```ruby
|
157
|
-
config
|
158
|
-
.add_source({api: {enabled: true}})
|
159
|
-
.add_source('config/settings.yml')
|
160
|
-
.add_source(ENV, prefix: "SETTINGS", separator: "__")
|
161
|
-
.load
|
177
|
+
config.api.access_token # => "my_secret_token"
|
162
178
|
```
|
163
179
|
|
164
|
-
|
180
|
+
Environment variables have the highest precedence and will override values from YAML configuration files.
|
181
|
+
This ensures that any environment-specific settings can be applied without modifying the configuration
|
182
|
+
files themselves.
|
183
|
+
|
184
|
+
### Loading Single Sources
|
185
|
+
|
186
|
+
To load configuration from a specific source (e.g., during testing):
|
165
187
|
|
166
188
|
```ruby
|
167
189
|
config = ConfigX.from({api: {enabled: true}})
|
168
190
|
config.api.enabled # => true
|
169
191
|
```
|
170
192
|
|
193
|
+
### Typed Config
|
194
|
+
|
195
|
+
ConfigX supports typed configurations using `ConfigX::Config`, which leverages [dry-struct]:
|
196
|
+
|
197
|
+
```ruby
|
198
|
+
class Config < ConfigX::Config
|
199
|
+
attribute :api do
|
200
|
+
attribute :enabled, Types::Bool.default(false)
|
201
|
+
attribute :endpoint, Types::String
|
202
|
+
attribute :access_token, Types::String
|
203
|
+
end
|
204
|
+
end
|
205
|
+
```
|
206
|
+
|
207
|
+
Load the typed configuration with:
|
208
|
+
|
209
|
+
```ruby
|
210
|
+
config = ConfigX.load(config_class: Config)
|
211
|
+
config.api.enabled #=> true
|
212
|
+
config.api.endpoint #=> "https://example.com"
|
213
|
+
```
|
214
|
+
|
215
|
+
Typed configurations enforce structure and type-checking.
|
216
|
+
|
171
217
|
## Development
|
172
218
|
|
173
219
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -183,3 +229,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/bolsha
|
|
183
229
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
184
230
|
|
185
231
|
[config]: https://rubygems.org/gems/config
|
232
|
+
[dry-struct]: https://dry-rb.org/gems/dry-struct/
|
data/lib/config_x/builder.rb
CHANGED
@@ -5,6 +5,11 @@ require "deep_merge/core"
|
|
5
5
|
module ConfigX
|
6
6
|
class Builder
|
7
7
|
class << self
|
8
|
+
# Creates a source object based on the type of the input.
|
9
|
+
#
|
10
|
+
# @param source [Source, Hash, String, Pathname, ENV] the source input
|
11
|
+
# @param args [Hash] additional arguments for the source
|
12
|
+
# @return [Source]
|
8
13
|
def source(source, **args)
|
9
14
|
case source
|
10
15
|
in Source then source
|
@@ -15,10 +20,11 @@ module ConfigX
|
|
15
20
|
end
|
16
21
|
end
|
17
22
|
|
23
|
+
# Loads the configuration.
|
24
|
+
#
|
25
|
+
# @return [UntypedConfig]
|
18
26
|
# @see #initialize
|
19
|
-
def load(...)
|
20
|
-
new(...).load
|
21
|
-
end
|
27
|
+
def load(...) = new.load(...)
|
22
28
|
end
|
23
29
|
|
24
30
|
# @example
|
@@ -31,17 +37,18 @@ module ConfigX
|
|
31
37
|
|
32
38
|
attr_reader :sources
|
33
39
|
|
40
|
+
# Adds a source to the builder.
|
41
|
+
#
|
42
|
+
# @param source [Source, Hash, String, Pathname, ENV] the source input
|
43
|
+
# @param args [Hash] additional arguments for the source
|
44
|
+
# @return [Builder]
|
34
45
|
def add_source(source, **args)
|
35
46
|
sources << self.class.source(source, **args)
|
36
47
|
self
|
37
48
|
end
|
38
49
|
|
39
|
-
|
40
|
-
|
41
|
-
# 2. Reads all the config files provided in the order
|
42
|
-
# 3. Reads environment variables
|
43
|
-
def load
|
44
|
-
Config.new(read_from_sources)
|
50
|
+
def load(config_class:)
|
51
|
+
config_class.new(read_from_sources)
|
45
52
|
end
|
46
53
|
|
47
54
|
def ==(other)
|
data/lib/config_x/config.rb
CHANGED
@@ -1,44 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require "
|
3
|
+
begin
|
4
|
+
require "dry-struct"
|
5
|
+
rescue LoadError
|
6
|
+
raise "The dry-struct gem is required for ConfigX::TypedConfig"
|
7
|
+
end
|
5
8
|
|
6
9
|
module ConfigX
|
7
|
-
class Config <
|
8
|
-
|
9
|
-
super()
|
10
|
-
|
11
|
-
members.each do |key, value|
|
12
|
-
raise ArgumentError, "option keys should be strings" unless key.respond_to?(:to_s)
|
13
|
-
|
14
|
-
key = key.to_s
|
15
|
-
|
16
|
-
if value.is_a?(Hash)
|
17
|
-
value = self.class.new(value)
|
18
|
-
elsif value.is_a?(Array)
|
19
|
-
value = value.map do |element|
|
20
|
-
element.is_a?(Hash) ? self.class.new(element) : element
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
self[key] = value
|
25
|
-
end
|
26
|
-
|
27
|
-
freeze
|
28
|
-
end
|
29
|
-
|
30
|
-
def with_fallback(fallback)
|
31
|
-
DeepMerge.deep_merge!(
|
32
|
-
to_h,
|
33
|
-
fallback.to_h,
|
34
|
-
overwrite_arrays: true
|
35
|
-
).then { Config.new(_1) }
|
36
|
-
end
|
10
|
+
class Config < Dry::Struct
|
11
|
+
transform_keys(&:to_sym)
|
37
12
|
|
38
|
-
|
39
|
-
each_pair.each_with_object({}) do |(key, value), hash|
|
40
|
-
hash[key] = value.is_a?(Config) ? value.to_h : value
|
41
|
-
end
|
42
|
-
end
|
13
|
+
include Configurable
|
43
14
|
end
|
44
15
|
end
|
@@ -26,6 +26,10 @@ module ConfigX
|
|
26
26
|
# Default root directory for configuration
|
27
27
|
def default_config_root = "config"
|
28
28
|
|
29
|
+
# Default configuration class
|
30
|
+
# @return [Class<ConfigX::Configurable>]
|
31
|
+
def default_config_class = UntypedConfig
|
32
|
+
|
29
33
|
# Load method to initialize and load the configuration
|
30
34
|
def load(...) = new(...).load
|
31
35
|
end
|
@@ -43,7 +47,8 @@ module ConfigX
|
|
43
47
|
env_separator: self.class.default_env_separator,
|
44
48
|
dir_name: self.class.default_dir_name,
|
45
49
|
file_name: self.class.default_file_name,
|
46
|
-
config_root: self.class.default_config_root
|
50
|
+
config_root: self.class.default_config_root,
|
51
|
+
config_class: self.class.default_config_class
|
47
52
|
)
|
48
53
|
@env = env
|
49
54
|
@env_prefix = env_prefix
|
@@ -51,15 +56,16 @@ module ConfigX
|
|
51
56
|
@dir_name = dir_name
|
52
57
|
@file_name = file_name
|
53
58
|
@config_root = config_root
|
59
|
+
@config_class = config_class
|
54
60
|
end
|
55
61
|
|
56
62
|
# Loads the configuration from the sources and additional sources.
|
57
63
|
# @param additional_sources [Array] additional sources to load configuration from.
|
58
|
-
# @return [
|
64
|
+
# @return [UntypedConfig] the loaded configuration.
|
59
65
|
def load(*additional_sources)
|
60
66
|
(sources + additional_sources)
|
61
67
|
.reduce(Builder.new) { |builder, source| builder.add_source(source) }
|
62
|
-
.load
|
68
|
+
.load(config_class:)
|
63
69
|
end
|
64
70
|
|
65
71
|
private
|
@@ -87,7 +93,7 @@ module ConfigX
|
|
87
93
|
# @return [Array] the local setting files.
|
88
94
|
def local_setting_files
|
89
95
|
[
|
90
|
-
|
96
|
+
File.join(config_root, "#{file_name}.local.yml"),
|
91
97
|
File.join(config_root, dir_name, "#{env}.local.yml")
|
92
98
|
].compact
|
93
99
|
end
|
@@ -109,5 +115,8 @@ module ConfigX
|
|
109
115
|
|
110
116
|
# The file name for settings.
|
111
117
|
attr_reader :file_name
|
118
|
+
|
119
|
+
# The configuration class.
|
120
|
+
attr_reader :config_class
|
112
121
|
end
|
113
122
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "deep_merge/core"
|
4
|
+
|
5
|
+
module ConfigX
|
6
|
+
module Configurable
|
7
|
+
# @!method to_h
|
8
|
+
# @abstract
|
9
|
+
# @return [Hash]
|
10
|
+
|
11
|
+
# Merges the current configuration with a fallback configuration.
|
12
|
+
#
|
13
|
+
# @param fallback [Configurable] the fallback configuration
|
14
|
+
# @return [Configurable] a new Config object with the merged configuration
|
15
|
+
def with_fallback(fallback)
|
16
|
+
DeepMerge.deep_merge!(
|
17
|
+
to_h,
|
18
|
+
fallback.to_h,
|
19
|
+
overwrite_arrays: true
|
20
|
+
).then { self.class.new(_1) }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/config_x/env_source.rb
CHANGED
data/lib/config_x/hash_source.rb
CHANGED
@@ -7,11 +7,26 @@ module ConfigX
|
|
7
7
|
attr_reader :source
|
8
8
|
protected :source
|
9
9
|
|
10
|
+
class << self
|
11
|
+
def deep_stringify_keys(hash)
|
12
|
+
hash.each_with_object({}) do |(key, value), acc|
|
13
|
+
acc[key.to_s] =
|
14
|
+
if Hash === value
|
15
|
+
deep_stringify_keys(value)
|
16
|
+
else
|
17
|
+
value
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
10
23
|
def initialize(source)
|
11
24
|
@source = source
|
12
25
|
end
|
13
26
|
|
14
|
-
def load
|
27
|
+
def load
|
28
|
+
self.class.deep_stringify_keys(source)
|
29
|
+
end
|
15
30
|
|
16
31
|
def ==(other)
|
17
32
|
other.is_a?(self.class) && source == other.source
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "ostruct"
|
4
|
+
|
5
|
+
module ConfigX
|
6
|
+
# The Config class extends OpenStruct to provide a flexible configuration object.
|
7
|
+
class UntypedConfig < OpenStruct
|
8
|
+
include Configurable
|
9
|
+
|
10
|
+
# @param members [Hash] the initial configuration hash
|
11
|
+
# @raise [ArgumentError] if any of the keys are not convertible to strings
|
12
|
+
def initialize(members)
|
13
|
+
super({})
|
14
|
+
|
15
|
+
members.each do |key, value|
|
16
|
+
raise ArgumentError, "option keys should be strings" unless key.respond_to?(:to_s)
|
17
|
+
|
18
|
+
key = key.to_s
|
19
|
+
|
20
|
+
if value.is_a?(Hash)
|
21
|
+
value = self.class.new(value)
|
22
|
+
elsif value.is_a?(Array)
|
23
|
+
value = value.map do |element|
|
24
|
+
element.is_a?(Hash) ? self.class.new(element) : element
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
self[key] = value
|
29
|
+
end
|
30
|
+
|
31
|
+
freeze
|
32
|
+
end
|
33
|
+
|
34
|
+
# Converts the Config object to a hash.
|
35
|
+
#
|
36
|
+
# @return [Hash] the configuration as a hash
|
37
|
+
def to_h
|
38
|
+
each_pair.each_with_object({}) do |(key, value), hash|
|
39
|
+
hash[key] = value.is_a?(self.class) ? value.to_h : value
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/config_x/version.rb
CHANGED
data/lib/config_x.rb
CHANGED
@@ -6,23 +6,26 @@ require_relative "config_x/version"
|
|
6
6
|
module ConfigX
|
7
7
|
class << self
|
8
8
|
# @api private
|
9
|
+
# @return [Zeitwerk::Loader]
|
9
10
|
def loader
|
10
11
|
@loader ||= Zeitwerk::Loader.for_gem.tap do |loader|
|
11
12
|
loader.ignore("#{__dir__}/configx.rb")
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
16
|
+
# @return [Configurable]
|
15
17
|
def load(...) = ConfigFactory.load(...)
|
16
18
|
|
17
|
-
def builder = Builder.new
|
18
|
-
|
19
19
|
# Loads config from the given source
|
20
20
|
# @example
|
21
21
|
# config = ConfigX.from({api: {endpoint: "http://example.com", enabled: true}})
|
22
22
|
# config.api.endpoint # => "http://example.com"
|
23
23
|
# config.api.enabled # => true
|
24
|
-
#
|
25
|
-
def from(source, **args) = builder.add_source(source, **args).load
|
24
|
+
# @return [ConfigX::UntypedConfig]
|
25
|
+
def from(source, **args) = builder.add_source(source, **args).load(config_class: UntypedConfig)
|
26
|
+
|
27
|
+
# @return [ConfigX::Builder]
|
28
|
+
private def builder = Builder.new
|
26
29
|
end
|
27
30
|
end
|
28
31
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: configx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tëma Bolshakov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deep_merge
|
@@ -58,22 +58,15 @@ files:
|
|
58
58
|
- lib/config_x/builder.rb
|
59
59
|
- lib/config_x/config.rb
|
60
60
|
- lib/config_x/config_factory.rb
|
61
|
+
- lib/config_x/configurable.rb
|
61
62
|
- lib/config_x/env_source.rb
|
62
63
|
- lib/config_x/file_source.rb
|
63
64
|
- lib/config_x/hash_source.rb
|
64
65
|
- lib/config_x/source.rb
|
66
|
+
- lib/config_x/untyped_config.rb
|
65
67
|
- lib/config_x/version.rb
|
66
68
|
- lib/config_x/yaml_source.rb
|
67
69
|
- lib/configx.rb
|
68
|
-
- sig/config_x.rbs
|
69
|
-
- sig/config_x/builder.rbs
|
70
|
-
- sig/config_x/config.rbs
|
71
|
-
- sig/config_x/config_factory.rbs
|
72
|
-
- sig/config_x/env_source.rbs
|
73
|
-
- sig/config_x/file_source.rbs
|
74
|
-
- sig/config_x/hash_source.rbs
|
75
|
-
- sig/config_x/source.rbs
|
76
|
-
- sig/config_x/yaml_source.rbs
|
77
70
|
homepage: https://github.com/bolshakov/configx
|
78
71
|
licenses:
|
79
72
|
- MIT
|
@@ -95,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
88
|
- !ruby/object:Gem::Version
|
96
89
|
version: '0'
|
97
90
|
requirements: []
|
98
|
-
rubygems_version: 3.5.
|
91
|
+
rubygems_version: 3.5.11
|
99
92
|
signing_key:
|
100
93
|
specification_version: 4
|
101
94
|
summary: Configuration simplified
|
data/sig/config_x/builder.rbs
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module ConfigX
|
2
|
-
class Builder
|
3
|
-
type source = Source | Hash[untyped, untyped] | String | Pathname | Object
|
4
|
-
|
5
|
-
def self.load: -> Config
|
6
|
-
def self.source: [T < Source] (source, **untyped) -> T
|
7
|
-
|
8
|
-
def initialize: -> void
|
9
|
-
|
10
|
-
attr_reader sources: Array[Source]
|
11
|
-
|
12
|
-
|
13
|
-
def add_source: (source, **untyped) -> self
|
14
|
-
|
15
|
-
def load: -> Config
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def read_from_sources: -> Hash[untyped, untyped]
|
20
|
-
end
|
21
|
-
end
|
data/sig/config_x/config.rbs
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
module ConfigX
|
2
|
-
class Config
|
3
|
-
def initialize: (Hash[untyped, untyped]) -> void
|
4
|
-
|
5
|
-
def to_h: -> Hash[untyped, untyped]
|
6
|
-
|
7
|
-
def with_fallback: (Config) -> Config
|
8
|
-
|
9
|
-
def each_pair: -> Enumerable[[untyped, untyped]]
|
10
|
-
|
11
|
-
def []=: (untyped, untyped) -> untyped
|
12
|
-
end
|
13
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
module ConfigX
|
2
|
-
class ConfigFactory
|
3
|
-
def self.default_config_root: -> String
|
4
|
-
|
5
|
-
def self.default_dir_name: -> String
|
6
|
-
|
7
|
-
def self.default_env_prefix: -> String
|
8
|
-
|
9
|
-
def self.default_env_separator: -> String
|
10
|
-
|
11
|
-
def self.default_env: -> String
|
12
|
-
|
13
|
-
def self.default_file_name: -> String
|
14
|
-
|
15
|
-
def self.load: (
|
16
|
-
?String env,
|
17
|
-
?env_prefix: String,
|
18
|
-
?env_separator: String,
|
19
|
-
?dir_name: String,
|
20
|
-
?file_name: String,
|
21
|
-
?config_root: String
|
22
|
-
) -> Config
|
23
|
-
|
24
|
-
def initialize: (
|
25
|
-
?String env,
|
26
|
-
?env_prefix: String,
|
27
|
-
?env_separator: String,
|
28
|
-
?dir_name: String,
|
29
|
-
?file_name: String,
|
30
|
-
?config_root: String
|
31
|
-
) -> void
|
32
|
-
|
33
|
-
def load: -> Config
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def local_setting_files: -> Array[String]
|
38
|
-
|
39
|
-
def setting_files: -> Array[String]
|
40
|
-
|
41
|
-
attr_reader config_root: String
|
42
|
-
|
43
|
-
attr_reader dir_name: String
|
44
|
-
|
45
|
-
attr_reader env_prefix: String
|
46
|
-
|
47
|
-
attr_reader env_separator: String
|
48
|
-
|
49
|
-
attr_reader env: String
|
50
|
-
|
51
|
-
attr_reader file_name: String
|
52
|
-
|
53
|
-
def sources: -> Array[Builder::source]
|
54
|
-
end
|
55
|
-
end
|
data/sig/config_x/env_source.rbs
DELETED
data/sig/config_x/source.rbs
DELETED
data/sig/config_x.rbs
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module ConfigX
|
2
|
-
VERSION: String
|
3
|
-
|
4
|
-
def self.builder: -> Builder
|
5
|
-
def self.from: (Builder::source, **untyped) -> Config
|
6
|
-
|
7
|
-
def self.load: (
|
8
|
-
String env,
|
9
|
-
env_prefix: String,
|
10
|
-
env_separator: String,
|
11
|
-
dir_name: String,
|
12
|
-
file_name: String,
|
13
|
-
config_root: String
|
14
|
-
) -> Config
|
15
|
-
|
16
|
-
|
17
|
-
def self.loader: -> Zeitwerk::Loader
|
18
|
-
end
|