const_conf 0.2.2 → 0.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/CHANGES.md +29 -0
- data/README.md +10 -10
- data/Rakefile +6 -4
- data/const_conf.gemspec +7 -6
- data/lib/const_conf/file_plugin.rb +4 -2
- data/lib/const_conf/setting.rb +1 -1
- data/lib/const_conf/tree.rb +2 -2
- data/lib/const_conf/version.rb +1 -1
- data/lib/const_conf.rb +7 -7
- data/spec/const_conf/file_plugin_spec.rb +44 -0
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af8de1ef676a5506d6ac24c9a0a5cb12c2764be09c78718a8ba89b1835b174df
|
4
|
+
data.tar.gz: f772b3255dcc22c76a1cd2a0767723e544f357857ec990a9e3f4525b479db44f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63c554ea00c471a168199ce9fe2af35e7b2b90a070e2aa6d42b9f02cfd881dca59b3f9bcc0606186449ce7cbcc4620fd269c89fa3d1a13db434b276b82c9e9f0
|
7
|
+
data.tar.gz: 6cf09d2de496051711c5e0651496c2088c8a2518c7503568c7716e8bc7f620be13ebd7c6a95c94c62dff4282e278a0b930b2f0f7994a038b6ae53ab7e58c09fc
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,34 @@
|
|
1
1
|
# Changes
|
2
2
|
|
3
|
+
## 2025-09-18 v0.4.0
|
4
|
+
|
5
|
+
- Improved handling of configuration files with trailing whitespace:
|
6
|
+
- Added `strip: false` parameter to the `ConstConf::FilePlugin#file` method to
|
7
|
+
enable automatic whitespace stripping when `strip: true` is specified
|
8
|
+
- Added comprehensive tests for the new strip functionality in
|
9
|
+
`file_plugin_spec.rb`
|
10
|
+
- Updated the `simplecov` development dependency version from **0.23** to
|
11
|
+
**0.22** in both `Rakefile` and `const_conf.gemspec`
|
12
|
+
|
13
|
+
## 2025-09-18 v0.3.1
|
14
|
+
|
15
|
+
- Replaced `require 'rails'` with `require 'active_support/all'` to reduce
|
16
|
+
dependency size
|
17
|
+
- Updated `tins` dependency from version **1.42** to **1.43**
|
18
|
+
- Updated `complex_config` dependency from version **0.22** to **0.23**
|
19
|
+
- Updated development dependencies: `context_spook` from **0.3** to **0.4**,
|
20
|
+
`all_images` from **0.6** to **0.8**, and `simplecov` from **0.22** to
|
21
|
+
**0.23**
|
22
|
+
- Added required Ruby version constraint of **= 3.2**
|
23
|
+
- Replaced `it` with `_1` in block parameters for Ruby **3.2** compatibility
|
24
|
+
- Updated Dockerfile to install `bundler` and `gem_hadar` gems directly
|
25
|
+
- Changed test command from `rake test` to `rake spec`
|
26
|
+
- Added `fail_fast: true` to CI configuration
|
27
|
+
- Added support for Ruby **3.3** and **3.2** Alpine images in CI pipeline
|
28
|
+
- Fixed prefix computation in nested modules with
|
29
|
+
- Added `color:#07f` to all diagram node style definitions in `README.md` to
|
30
|
+
improve text visibility on colored backgrounds
|
31
|
+
|
3
32
|
## 2025-09-13 v0.2.2
|
4
33
|
|
5
34
|
- Simplified ignore patterns in `Rakefile` by changing `*.contexts/*` to
|
data/README.md
CHANGED
@@ -249,16 +249,16 @@ graph TD
|
|
249
249
|
Y --> AA[Default Value Handling]
|
250
250
|
Y --> AB[Validation & Processing]
|
251
251
|
|
252
|
-
style A fill:#e1f5fe
|
253
|
-
style B fill:#f3e5f5
|
254
|
-
style C fill:#e8f5e9
|
255
|
-
style D fill:#fff3e0
|
256
|
-
style E fill:#fce4ec
|
257
|
-
style F fill:#f1f8e9
|
258
|
-
style G fill:#e0f2f1
|
259
|
-
style H fill:#f1f8e9
|
260
|
-
style I fill:#fafafa
|
261
|
-
style Y fill:#ffebee
|
252
|
+
style A fill:#e1f5fe;color:#07f
|
253
|
+
style B fill:#f3e5f5;color:#07f
|
254
|
+
style C fill:#e8f5e9;color:#07f
|
255
|
+
style D fill:#fff3e0;color:#07f
|
256
|
+
style E fill:#fce4ec;color:#07f
|
257
|
+
style F fill:#f1f8e9;color:#07f
|
258
|
+
style G fill:#e0f2f1;color:#07f
|
259
|
+
style H fill:#f1f8e9;color:#07f
|
260
|
+
style I fill:#fafafa;color:#07f
|
261
|
+
style Y fill:#ffebee;color:#07f
|
262
262
|
```
|
263
263
|
|
264
264
|
#### FilePlugin
|
data/Rakefile
CHANGED
@@ -21,14 +21,16 @@ GemHadar do
|
|
21
21
|
'.contexts'
|
22
22
|
readme 'README.md'
|
23
23
|
|
24
|
-
|
24
|
+
required_ruby_version '~> 3.2'
|
25
|
+
|
26
|
+
dependency 'tins', '~> 1.43'
|
25
27
|
dependency 'json', '~> 2.0'
|
26
|
-
dependency 'complex_config', '~> 0.
|
28
|
+
dependency 'complex_config', '~> 0.23'
|
27
29
|
dependency 'activesupport', '~> 8'
|
28
30
|
development_dependency 'debug'
|
29
31
|
development_dependency 'rspec', '~> 3.13'
|
30
|
-
development_dependency 'context_spook', '~> 0.
|
31
|
-
development_dependency 'all_images', '~> 0.
|
32
|
+
development_dependency 'context_spook', '~> 0.4'
|
33
|
+
development_dependency 'all_images', '~> 0.8'
|
32
34
|
development_dependency 'simplecov', '~> 0.22'
|
33
35
|
|
34
36
|
licenses << 'MIT'
|
data/const_conf.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: const_conf 0.
|
2
|
+
# stub: const_conf 0.4.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "const_conf".freeze
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.4.0".freeze
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
@@ -16,6 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.homepage = "https://github.com/flori/const_conf".freeze
|
17
17
|
s.licenses = ["MIT".freeze]
|
18
18
|
s.rdoc_options = ["--title".freeze, "ConstConf - Clean DSL for config settings with validation and Rails integration".freeze, "--main".freeze, "README.md".freeze]
|
19
|
+
s.required_ruby_version = Gem::Requirement.new("~> 3.2".freeze)
|
19
20
|
s.rubygems_version = "3.6.9".freeze
|
20
21
|
s.summary = "Clean DSL for config settings with validation and Rails integration".freeze
|
21
22
|
s.test_files = ["spec/const_conf/dir_plugin_spec.rb".freeze, "spec/const_conf/env_dir_extension_spec.rb".freeze, "spec/const_conf/file_plugin_spec.rb".freeze, "spec/const_conf/json_plugin_spec.rb".freeze, "spec/const_conf/setting_accessor_spec.rb".freeze, "spec/const_conf/setting_spec.rb".freeze, "spec/const_conf/tree_spec.rb".freeze, "spec/const_conf/yaml_plugin_spec.rb".freeze, "spec/const_conf_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
@@ -25,11 +26,11 @@ Gem::Specification.new do |s|
|
|
25
26
|
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 2.6".freeze])
|
26
27
|
s.add_development_dependency(%q<debug>.freeze, [">= 0".freeze])
|
27
28
|
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.13".freeze])
|
28
|
-
s.add_development_dependency(%q<context_spook>.freeze, ["~> 0.
|
29
|
-
s.add_development_dependency(%q<all_images>.freeze, ["~> 0.
|
29
|
+
s.add_development_dependency(%q<context_spook>.freeze, ["~> 0.4".freeze])
|
30
|
+
s.add_development_dependency(%q<all_images>.freeze, ["~> 0.8".freeze])
|
30
31
|
s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.22".freeze])
|
31
|
-
s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.
|
32
|
+
s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.43".freeze])
|
32
33
|
s.add_runtime_dependency(%q<json>.freeze, ["~> 2.0".freeze])
|
33
|
-
s.add_runtime_dependency(%q<complex_config>.freeze, ["~> 0.
|
34
|
+
s.add_runtime_dependency(%q<complex_config>.freeze, ["~> 0.23".freeze])
|
34
35
|
s.add_runtime_dependency(%q<activesupport>.freeze, ["~> 8".freeze])
|
35
36
|
end
|
@@ -23,9 +23,11 @@ module ConstConf::FilePlugin
|
|
23
23
|
#
|
24
24
|
# @raise [ConstConf::RequiredValueNotConfigured] if the file does not exist
|
25
25
|
# and required is true
|
26
|
-
def file(path, required: false)
|
26
|
+
def file(path, required: false, strip: false)
|
27
27
|
if File.exist?(path)
|
28
|
-
File.read(path)
|
28
|
+
value = File.read(path)
|
29
|
+
strip and value.strip!
|
30
|
+
value
|
29
31
|
elsif required
|
30
32
|
raise ConstConf::RequiredValueNotConfigured,
|
31
33
|
"file required at path #{path.to_s.inspect}"
|
data/lib/const_conf/setting.rb
CHANGED
@@ -226,7 +226,7 @@ class ConstConf::Setting
|
|
226
226
|
#
|
227
227
|
# @return [String] the constructed environment variable name
|
228
228
|
def env_var_name
|
229
|
-
prefix = @prefix.full? { "#{
|
229
|
+
prefix = @prefix.full? { "#{_1}::" }.to_s
|
230
230
|
name.sub(/^#{parent_namespace}::/, prefix).gsub(/::/, ?_)
|
231
231
|
end
|
232
232
|
|
data/lib/const_conf/tree.rb
CHANGED
@@ -71,7 +71,7 @@ module ConstConf
|
|
71
71
|
# @return [ConstConf::Tree] a tree object representing the module's
|
72
72
|
# configuration hierarchy
|
73
73
|
def convert_module(modul)
|
74
|
-
desc = "#{modul.description.full? { italic(' # %s' %
|
74
|
+
desc = "#{modul.description.full? { italic(' # %s' % _1) }}"
|
75
75
|
obj = new("#{modul.name}#{desc}")
|
76
76
|
obj << new("prefix #{modul.prefix.inspect}")
|
77
77
|
obj << new("#{modul.settings.size} settings")
|
@@ -105,7 +105,7 @@ module ConstConf
|
|
105
105
|
#
|
106
106
|
# @return [ConstConf::Tree] a tree node representing the configuration setting
|
107
107
|
def convert_setting(setting)
|
108
|
-
desc = "#{setting.description.full? { italic(' # %s' %
|
108
|
+
desc = "#{setting.description.full? { italic(' # %s' % _1) }}"
|
109
109
|
obj = new("#{bold(setting.name)}#{desc}")
|
110
110
|
|
111
111
|
length = (Tins::Terminal.columns / 4).clamp(20..)
|
data/lib/const_conf/version.rb
CHANGED
data/lib/const_conf.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'tins/xt'
|
2
|
-
require '
|
2
|
+
require 'active_support/all'
|
3
3
|
|
4
4
|
# A configuration management module that provides environment variable-based
|
5
5
|
# settings with validation and thread-safe operations.
|
@@ -94,7 +94,7 @@ module ConstConf
|
|
94
94
|
# files. It performs this operation in a thread-safe manner using the
|
95
95
|
# monitor for synchronization.
|
96
96
|
def reload
|
97
|
-
monitor.synchronize { destroy.each { load
|
97
|
+
monitor.synchronize { destroy.each { load _1 } }
|
98
98
|
nil
|
99
99
|
end
|
100
100
|
end
|
@@ -140,7 +140,7 @@ module ConstConf
|
|
140
140
|
include ConstConf
|
141
141
|
end
|
142
142
|
prefix = [ self, *module_parents ].find {
|
143
|
-
!
|
143
|
+
!_1.prefix.nil? and break _1.prefix
|
144
144
|
}
|
145
145
|
const.prefix [ prefix, const.name.sub(/.*::/, '') ].select(&:present?) * ?_
|
146
146
|
end
|
@@ -149,7 +149,7 @@ module ConstConf
|
|
149
149
|
self.last_setting = nil
|
150
150
|
remove_const(id)
|
151
151
|
prefix = [ self, *module_parents ].find {
|
152
|
-
!
|
152
|
+
!_1.ask_and_send(:prefix).nil? and break _1.prefix
|
153
153
|
}
|
154
154
|
setting = Setting.new(name: [ name, id ], prefix:, &setting_block)
|
155
155
|
if previous_setting = outer_configuration.setting_for(setting.env_var_name)
|
@@ -274,7 +274,7 @@ module ConstConf
|
|
274
274
|
# @return [ Module, nil ] the outer configuration module if found, or nil
|
275
275
|
# if none exists
|
276
276
|
def outer_configuration
|
277
|
-
[ self, *module_parents ].reverse_each.find {
|
277
|
+
[ self, *module_parents ].reverse_each.find { _1 < ConstConf }
|
278
278
|
end
|
279
279
|
|
280
280
|
# Returns an array containing all nested configuration modules recursively,
|
@@ -442,8 +442,8 @@ module ConstConf
|
|
442
442
|
configuration_modules = [ self ]
|
443
443
|
while configuration = configuration_modules.pop
|
444
444
|
configuration.nested_configurations.reverse_each do
|
445
|
-
configuration_modules.member?(
|
446
|
-
configuration_modules <<
|
445
|
+
configuration_modules.member?(_1) and next
|
446
|
+
configuration_modules << _1
|
447
447
|
end
|
448
448
|
yield configuration
|
449
449
|
end
|
@@ -100,6 +100,50 @@ describe ConstConf::FilePlugin do
|
|
100
100
|
}.to raise_error(ConstConf::RequiredValueNotConfigured)
|
101
101
|
end
|
102
102
|
end
|
103
|
+
|
104
|
+
context 'with strip option' do
|
105
|
+
let(:whitespace_file) { File.join(temp_dir, 'whitespace.txt') }
|
106
|
+
|
107
|
+
before do
|
108
|
+
File.write(whitespace_file, " test_content \n\n")
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'strips whitespace when strip: true is specified' do
|
112
|
+
result = instance.file(whitespace_file, strip: true)
|
113
|
+
expect(result).to eq "test_content"
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'does not strip whitespace when strip: false (default)' do
|
117
|
+
result = instance.file(whitespace_file, strip: false)
|
118
|
+
expect(result).to eq " test_content \n\n"
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'does not strip whitespace when strip option is omitted' do
|
122
|
+
result = instance.file(whitespace_file)
|
123
|
+
expect(result).to eq " test_content \n\n"
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'handles empty files with strip: true' do
|
127
|
+
empty_file = File.join(temp_dir, 'empty.txt')
|
128
|
+
File.write(empty_file, "")
|
129
|
+
|
130
|
+
result = instance.file(empty_file, strip: true)
|
131
|
+
expect(result).to eq ""
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'handles whitespace-only files with strip: true' do
|
135
|
+
whitespace_only_file = File.join(temp_dir, 'whitespace_only.txt')
|
136
|
+
File.write(whitespace_only_file, " \n\t ")
|
137
|
+
|
138
|
+
result = instance.file(whitespace_only_file, strip: true)
|
139
|
+
expect(result).to eq ""
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'works correctly with required files and strip option' do
|
143
|
+
result = instance.file(whitespace_file, required: true, strip: true)
|
144
|
+
expect(result).to eq "test_content"
|
145
|
+
end
|
146
|
+
end
|
103
147
|
end
|
104
148
|
|
105
149
|
describe 'integration with ConstConf settings' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: const_conf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
@@ -57,28 +57,28 @@ dependencies:
|
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '0.
|
60
|
+
version: '0.4'
|
61
61
|
type: :development
|
62
62
|
prerelease: false
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '0.
|
67
|
+
version: '0.4'
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
69
|
name: all_images
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '0.
|
74
|
+
version: '0.8'
|
75
75
|
type: :development
|
76
76
|
prerelease: false
|
77
77
|
version_requirements: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '0.
|
81
|
+
version: '0.8'
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
83
|
name: simplecov
|
84
84
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,14 +99,14 @@ dependencies:
|
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '1.
|
102
|
+
version: '1.43'
|
103
103
|
type: :runtime
|
104
104
|
prerelease: false
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
107
|
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: '1.
|
109
|
+
version: '1.43'
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
111
|
name: json
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,14 +127,14 @@ dependencies:
|
|
127
127
|
requirements:
|
128
128
|
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: '0.
|
130
|
+
version: '0.23'
|
131
131
|
type: :runtime
|
132
132
|
prerelease: false
|
133
133
|
version_requirements: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
135
|
- - "~>"
|
136
136
|
- !ruby/object:Gem::Version
|
137
|
-
version: '0.
|
137
|
+
version: '0.23'
|
138
138
|
- !ruby/object:Gem::Dependency
|
139
139
|
name: activesupport
|
140
140
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,9 +220,9 @@ require_paths:
|
|
220
220
|
- lib
|
221
221
|
required_ruby_version: !ruby/object:Gem::Requirement
|
222
222
|
requirements:
|
223
|
-
- - "
|
223
|
+
- - "~>"
|
224
224
|
- !ruby/object:Gem::Version
|
225
|
-
version: '
|
225
|
+
version: '3.2'
|
226
226
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
227
227
|
requirements:
|
228
228
|
- - ">="
|