complex_config 0.20.0 → 0.21.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a383ead2fa3f869b63ae75a7e32321a86027440d387942020721b8b68b1d081
4
- data.tar.gz: 95e904f31eff85a43ec1c10ab255f0956152ef2208bc33f4c8a0a2d81eb49cbf
3
+ metadata.gz: 1be2d6a3e3fa81319f6455a9e4f158f45d096c322a3d224e8547fe81a4490b33
4
+ data.tar.gz: fc4bfec9fac1f616f51818f3bcd1ebf0ca4db5102d7430b09207339746472293
5
5
  SHA512:
6
- metadata.gz: e77f6fc234a0c5e39cb51706d102252b8d809592529b6642b06931532849e9aa740fd395d325fc6e1e2172623677c1d3390fa2afcc012effaf8a01a440791aca
7
- data.tar.gz: d5f857481ebf24869540d53aa31fe021f54ff1cd4759b935236e63d0c2305ced2be867c9e34f2997f5b3fdd6825cac028ef3d7722de409c0e307125d2c811e71
6
+ metadata.gz: 65f0b0f8c29597bda6a31a2c80285e02caeccb7068e184f8385dfa8849233623382a6667407328fcc3b2c5a91f108885daba55f4b4eb70f7ea7f1b241e82833a
7
+ data.tar.gz: 23fbb4f4bc736e10606cd001ec1af90bba397ad939720d148354e9fada7cbb4a0b6b849ffe7592d7692247a4d615d600f430ddbc39c11423d33e3ce360be902b
data/.all_images.yml CHANGED
@@ -6,7 +6,7 @@ script: &script |-
6
6
  echo -e "\e[1m"
7
7
  ruby -v
8
8
  echo -e "\e[0m"
9
- bundle
9
+ bundle install --full-index
10
10
  rake spec
11
11
 
12
12
  images:
data/CHANGES.md ADDED
@@ -0,0 +1,379 @@
1
+ # Changes
2
+
3
+ ## 2024-09-09 v0.21.1
4
+
5
+ * **API Changes**:
6
+ * The default string representation of ComplexConfig has been changed to a tree-like structure.
7
+ * The `to_s` method in ComplexConfig::Settings has been renamed to `list`.
8
+ * A new `list` method has been added to ComplexConfig::Settings for listing settings as a string.
9
+
10
+ ## 2024-09-09 v0.21.0
11
+
12
+ * **Tree Representation**:
13
+ + Add `Tree` class to convert complex config objects into trees.
14
+ + Update `Settings` class to use `Tree` conversion in `to_tree` method.
15
+ + Update tests to reflect changes.
16
+ * **Components Array**: Add components array for flux capacitors
17
+ * **Rakefile and Gemspec**:
18
+ - Add clobber task for coverage to Rakefile
19
+ - Update all_images script: update `bundle` to `bundle install --full-index`
20
+ * **.gitignore**: Remove `.byebug_history` from ignored files
21
+ * **Complex Config**:
22
+ + Raise type error and add test for empty configuration file.
23
+ + Update gemspec to use GemHadar 1.17.0
24
+ + Add requirement for tins/xt/ask_and_send in complex_config/provider.rb
25
+ + Add check for hash type in ComplexConfig::Settings#build method
26
+ + Add test for reading from empty configuration file in provider_spec.rb
27
+ + Replace byebug with debug in spec_helper.rb
28
+
29
+ ## 2024-04-17 v0.20.0
30
+
31
+ #### Significant Changes
32
+
33
+ * **Add dependency to base64**: The code now depends on the `base64` library,
34
+ which will be extracted from Ruby 3.4.
35
+ * **Upgrade ruby and add debug gem**: The project has been upgraded to use a
36
+ newer version of Ruby and includes the `debug` gem for debugging purposes.
37
+ * **Use newest ruby, drop the older 2.5 version**: The code now targets the
38
+ latest version of Ruby and no longer supports Ruby 2.5.
39
+
40
+ #### Other Changes
41
+
42
+ * Run specs: The project now runs its specifications as part of its build
43
+ process.
44
+ * Test on newest ruby, on older ones don't: The project's tests are now run
45
+ only on the latest version of Ruby, with older versions being skipped.
46
+ * Align: The code has been aligned to follow best practices.
47
+
48
+ ## 2022-07-11 v0.19.4
49
+
50
+ * **Configuration File Handling Improvements**
51
+ + Replaced defaulting to `unsafe_load` with explicit usage, ensuring safer
52
+ handling of configuration files.
53
+
54
+ ## 2022-05-19 v0.19.3
55
+
56
+ * **New Feature**: Pass parameters to json generator, allowing for more dynamic
57
+ and customizable JSON output.
58
+ * **Improvement**: Use `all_images` for testing, improving the robustness and
59
+ accuracy of image-related tests.
60
+
61
+ ## 2021-10-28 v0.19.2
62
+
63
+ * **New Psych Support**
64
+ + Added support for newest Psych 4 library
65
+ + Defaults to disabling YAML alias feature
66
+ * **Psych API Update**
67
+ + Updated code to use new Psych/YAML API when Psych version < 4
68
+ + Retained behavior of evaluating aliases
69
+ * **Ruby Version Bump**
70
+ + Updated Ruby version in tool-versions to 3.0.2
71
+
72
+ ## 2021-04-09 v0.19.1
73
+
74
+ * **Breaking Change**: Updated code to adapt to the new keyword interface of
75
+ ERB for Ruby versions greater than or equal to 3.
76
+
77
+ ## 2021-01-05 v0.19.0
78
+
79
+ * Added two new methods:
80
+ + `get_attribute_by_name`
81
+ + `get_attributes_by_name`
82
+
83
+ ## 2020-08-26 v0.18.2
84
+
85
+ * **Bug Fix**: Resolved a similar issue, mirroring the fix introduced in
86
+ version 0.18.1.
87
+
88
+ ## 2020-08-26 v0.18.1
89
+
90
+ * **New Feature**: Added support for faking data, allowing users to simulate
91
+ scenarios without actual data.
92
+ + Implemented a new module `FakeIt` with methods for generating fake data.
93
+ + Updated relevant tests to include fake data scenarios.
94
+
95
+ ## 2020-01-07 v0.18.0
96
+
97
+ * **New Version Summary**
98
+ + Added support for Ruby 2.7.0
99
+ + Updated tests to include Ruby 2.7.0
100
+ + Refactored code to avoid string modifications
101
+ * Significant Changes:
102
+ * Support added for Ruby 2.7.0
103
+ * Tests updated to include Ruby 2.7.0
104
+ * String modification stopped
105
+
106
+ ## 2019-11-27 v0.17.1
107
+
108
+ * **Shared Settings Implementation**: The code now uses a more sane and
109
+ efficient approach for shared settings.
110
+
111
+ ## 2019-03-18 v0.17.0
112
+
113
+ * **Decoding Fix**: Corrected the decoding issue to ensure proper data
114
+ interpretation.
115
+
116
+ ## 2019-03-18 v0.16.2
117
+
118
+ * **New Feature**: Added support for handling complex scenarios
119
+ + Implemented a new logic to handle intricate cases
120
+ * Improved error handling and reporting
121
+ + Enhanced logging to provide more detailed information about errors
122
+ * Minor code refactoring
123
+ + Simplified some conditional statements
124
+
125
+ ## 2019-03-18 v0.16.1
126
+
127
+ * Improved error message for missing encryption key:
128
+ + Added more informative and user-friendly error message when encryption
129
+ key is not provided.
130
+
131
+ ## 2019-03-14 v0.16.0
132
+
133
+ * **New Features**
134
+ + Added support for `trim_mode` in legacy mode
135
+ + Enabled `trim_mode` by default
136
+ + Added `#to_json` method to settings objects
137
+ * **Changes**
138
+ + Updated code to use new `trim_mode` feature
139
+ + Modified settings objects to include `#to_json` method
140
+
141
+ ## 2019-03-14 v0.15.1
142
+
143
+ * **Fix**: Shared feature now works correctly even when the top-level settings
144
+ are empty.
145
+
146
+ ## 2018-12-07 v0.15.0
147
+
148
+ * **New Feature**: Allow recrypting a file in-place with options.
149
+ + Added functionality to enable recrypting a file without creating a new
150
+ copy.
151
+
152
+ ## 2018-12-07 v0.14.1
153
+
154
+ * **New Version**: Bumped version
155
+ * **Improved Error Handling**:
156
+ + Improved error handling if key isn't valid
157
+ + Raises `ComplexConfig::DecryptionFailed` for encrypted files
158
+ * **Compatibility**:
159
+ + Make this run on older rubies
160
+ * **Documentation**:
161
+ + Cleanup documentation
162
+ * **RubyGems**:
163
+ + Use newest rubygems
164
+
165
+ ## 2018-06-07 v0.14.0
166
+
167
+ * Added `complex_config` executable to handle configuration files.
168
+
169
+ ## 2018-02-23 v0.13.3
170
+
171
+ * **Changes in Evaluation Order**
172
+ + The evaluation order of key sources has been modified.
173
+
174
+ ## 2018-02-23 v0.13.2
175
+
176
+ * **Compatibility improvements**
177
+ + Be compatible with ancient rubies^3
178
+ + Be compatible with ancient rubies^2
179
+ + Be compatible with ancient rubies
180
+ * **Refactoring**
181
+ + Refactor key provision with source object
182
+
183
+ ## 2018-02-09 v0.13.1
184
+
185
+ * **New Features**
186
+ + Added information to README file
187
+ * **Significant Changes**
188
+ + Bumped version number
189
+ + Improved error reporting for encrypted files with missing keys
190
+
191
+ ## 2018-01-26 v0.13.0
192
+
193
+ * Improved the `write_config` interface
194
+ * Added more tests
195
+
196
+ ## 2017-11-17 v0.12.2
197
+
198
+ * **Output string keys on top level configs**:
199
+ * Added functionality to output string keys on top level configurations.
200
+
201
+ ## 2017-11-17 v0.12.1
202
+
203
+ * **New Feature**: Suppress newline output during encryption.
204
+
205
+ ## 2017-11-16 v0.12.0
206
+
207
+ * **New Features**
208
+ + Add support for writing configurations (encrypted or not)
209
+ * **Version Bump**
210
+ + Bump version to 0.12.0
211
+ * **Compatibility Improvements**
212
+ + Support older Rubies
213
+
214
+ ## 2017-11-02 v0.11.3
215
+
216
+ * **New Feature:** Added striping functionality.
217
+ * **Bug Fix:** Fixed issue where caches were not cleared when `deep_freeze` was
218
+ disabled.
219
+
220
+ ## 2017-10-30 v0.11.2
221
+
222
+ * **Behavioral Fix**:
223
+ * Fixed the behavior for incomplete key setup.
224
+
225
+ ## 2017-10-27 v0.11.1
226
+
227
+ * Added support for shared features.
228
+
229
+ ## 2017-10-27 v0.11.0
230
+
231
+ * **New Feature**: Support for encrypted YAML files, compatible with Rails'
232
+ encryption.
233
+ * **Test Update**: Added testing to ensure compatibility with Ruby 2.4.2.
234
+
235
+ ## 2017-02-02 v0.10.0
236
+
237
+ ## 2017-01-23 v0.9.2
238
+
239
+ * **New Version**: Released version 0.9.2.
240
+ * **Performance Improvement**:
241
+ + Memoized proxy object for improved performance.
242
+
243
+ ## 2016-11-23 v0.9.1
244
+
245
+ * **New Features**
246
+ + Use newest RubyGems
247
+ + Test on Ruby 2.3.3
248
+ * **Bug Fixes**
249
+ + Fix Travis builds
250
+ + travis fiddles with RAILS_ENV variable, breaking specs (resolved)
251
+ * **Testing Improvements**
252
+ + Test newer Rubies
253
+
254
+ ## 2016-11-22 v0.9.0
255
+
256
+ * **Gem Update**: Updated to newest gem_hadar.
257
+ * **Coverage Report**: Only send new coverage report on success.
258
+ * **Manual Run**: We are supposed to run this manually now.
259
+ * **Code Organization**: Moved provider shortcuts into its own module.
260
+
261
+ ## 2016-07-27 v0.8.0
262
+
263
+ * **New Feature**: Added support for replacing attributes in
264
+ `ComplexConfig::Settings` using the `#replace_attributes` method.
265
+
266
+ ## 2016-07-18 v0.7.0
267
+
268
+ * **New Features**
269
+ + Added new date functionality
270
+ * **Improvements**
271
+ + Simplified `ComplexConfig::Settings` interface by basing it on
272
+ `BasicObject` and reducing mixin usage
273
+ * **Documentation**
274
+ + Updated README.md with new changes
275
+
276
+ ## 2016-07-15 v0.6.0
277
+
278
+ * **Caching Improvements**
279
+ + Use `mize` for caching
280
+
281
+ ## 2016-06-23 v0.5.2
282
+
283
+ * **Index Access Feature**
284
+ + Fixed issue with incorrect indexing behavior (#56190d3)
285
+ + Improved performance and reliability of index access functionality
286
+
287
+ ## 2016-06-23 v0.5.1
288
+
289
+ * **New Features**
290
+ + Resolve index access via the plugin code path, making `foo.bar` and
291
+ `foo[:bar]` equivalent for a plugin key.
292
+ + Test on Ruby 2.3.1 and 2.4.0-preview1
293
+ * **Infrastructure Changes**
294
+ + Use new infrastructure
295
+ * **Bug Fixes**
296
+ + Fix typo
297
+
298
+ ## 2015-11-19 v0.5.0
299
+
300
+ * **New Features**
301
+ + Add configure method
302
+ + Add configuration example to README
303
+ * **Bug Fixes**
304
+ + Flush cache for every request in rails development
305
+ + Change the Changes
306
+ * **Improvements**
307
+ + Just always skip to avoid interference
308
+
309
+ ## 2015-11-17 v0.4.0
310
+
311
+ * **New Feature:** Implemented root object method call syntax.
312
+
313
+ ## 2015-11-03 v0.3.1
314
+
315
+ * **New Features**
316
+ + Add missing tins dependency
317
+ + Show improved settings output in README.md
318
+ + Adds a decent string representation for ComplexConfig::Settings objects
319
+ * **Dependency Updates**
320
+ + Use newest gem hadar
321
+ + Add some development_dependencies (including tins)
322
+ * **Code Improvements**
323
+ + Shorten codeclimate snippet
324
+
325
+ ## 2015-03-24 v0.3.0
326
+
327
+ ## 2015-03-24 v0.2.3
328
+
329
+ * **Typo Fix**: Corrected a typo in the `LoadErro(r)` method.
330
+ * **JRuby Update**: Updated JRuby version to use `jruby-head` and allowed it to
331
+ potentially fail.
332
+
333
+ ## 2015-02-25 v0.2.2
334
+
335
+ * Removed unnecessary `sprintf` format.
336
+
337
+ ## 2015-01-28 v0.2.1
338
+
339
+ * **New Version**:
340
+ * Added support for JRuby test target
341
+ * Removed always broken jruby-head
342
+ * Bumped version number to 0.2.0
343
+ * Bumped version to 0.2.1
344
+ * **Plugin Changes**:
345
+ * Skip the money plugin if monetize cannot be loaded (optional runtime
346
+ dependency)
347
+ * Remove require for plugins, allowing users to use the gem without requiring
348
+ the money gem
349
+ * Fixed requiring *with* plugins, enabling them to load correctly
350
+
351
+ ## 2015-01-27 v0.2.0
352
+
353
+ * **New Features**
354
+ + Added support for JRuby in tests
355
+ + Updated to newest Ruby 2.2
356
+ * **Improvements**
357
+ + Replaced mixin with delegation for Enumerable, allowing attribute names
358
+ like `zip`, `min`, or `max` without conflicts
359
+ * **Documentation**
360
+ + Added Apache license file
361
+
362
+ ## 2015-01-01 v0.1.1
363
+
364
+ * **New Version Summary**
365
+ + Use value from non-associative list arrays
366
+ + Fix `puts` method to call `to_ary` correctly
367
+ + Prevent cash leakage after flushing cache
368
+ + Add `to_ary` method for level on demand
369
+
370
+ ## 2014-12-15 v0.1.0
371
+
372
+ * **Significant Changes**:
373
+ + Freeze cached configuration by default (versioning)
374
+ + Add to-do list for future development
375
+ + Integrate CodeClimate for code analysis and improvement
376
+
377
+ ## 2014-12-12 v0.0.0
378
+
379
+ * Start
data/README.md CHANGED
@@ -30,21 +30,40 @@ Given a config file like this and named `config/products.yml`
30
30
  name: Flux Capacitor Version 2.0
31
31
  price_in_cents: 12_000_00
32
32
  manual_pdf_url: "http://brown-inc.com/manuals/fc_20.pdf"
33
+ components:
34
+ - Miniature Chrono-Levitation Chamber (mCLC)
35
+ - Single Gravitational Displacement Coil (SGDC)
36
+ - Simple Quantum Flux Transducer (SQFT)
37
+ - Basic Time-Space Navigation System (BTN)
33
38
  pro_version:
34
39
  name: Flux Capacitor Professional
35
40
  price_in_cents: 23_000_00
36
41
  manual_pdf_url: "http://brown-inc.com/manuals/fc_pro.pdf"
42
+ components:
43
+ - Advanced Chrono-Levitation Chamber (ACL)
44
+ - Dual Gravitational Displacement Coils (DGDCs)
45
+ - Advanced Quantum Flux Transducer (AQFT)
46
+ - Professional Time-Space Navigation System (PTNS)
37
47
  enterprise_version:
38
48
  name: Flux Capacitor Enterpise
39
49
  price_in_cents: 1_600_000_00
40
50
  manual_pdf_url: "http://brown-inc.com/manuals/fc_enterprise.pdf"
41
-
51
+ components:
52
+ - Super-Advanced Chrono-Levitation Chamber (SACL)
53
+ - Quadruple Gravitational Displacement Coils (QGDCs)
54
+ - Ultra-Advanced Quantum Flux Transducer (UAQFT)
55
+ - Enterprise Time-Space Navigation System (ETNS)
42
56
  test:
43
57
  flux_capacitor:
44
58
  test_version:
45
59
  name: Yadayada
46
60
  price_in_cents: 6_66
47
61
  manual_pdf_url: "http://staging.brown-inc.com/manuals/fc_10.pdf"
62
+ components:
63
+ - Experimental Chrono-Levitation Chamber (ECLC)
64
+ - Modular Gravitational Displacement Coils (MGDCs)
65
+ - Variable Quantum Flux Transducer (VQFT)
66
+ - Development Time-Space Navigation System (DTNS)
48
67
 
49
68
  and using `require "complex_config/rude"` in the `"development"` environment you
50
69
  can now access the configuration.
@@ -79,9 +98,17 @@ plugin return an URI instance:
79
98
  You can also fetch config settings from a different environment:
80
99
 
81
100
  >> pp cc.products(:test); nil
82
- products.flux_capacitor.test_version.name = "Yadayada"
83
- products.flux_capacitor.test_version.price_in_cents = 666
84
- products.flux_capacitor.test_version.manual_pdf_url = "http://staging.brown-inc.com/manuals/fc_10.pdf"
101
+ products
102
+ └─ flux_capacitor
103
+ └─ test_version
104
+ ├─ name = "Yadayada"
105
+ ├─ price_in_cents = 666
106
+ ├─ manual_pdf_url = "http://staging.brown-inc.com/manuals/fc_10.pdf"
107
+ └─ components
108
+ ├─ "Experimental Chrono-Levitation Chamber (ECLC)"
109
+ ├─ "Modular Gravitational Displacement Coils (MGDCs)"
110
+ ├─ "Variable Quantum Flux Transducer (VQFT)"
111
+ └─ "Development Time-Space Navigation System (DTNS)"kk
85
112
 
86
113
  Calling `complex_config.products.` instead of `cc(…)` would skip the implicite
87
114
  namespacing via the `RAILS_ENV` environment, so
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ GemHadar do
12
12
  executables 'complex_config'
13
13
  test_dir 'spec'
14
14
  ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', 'coverage', '.rvmrc',
15
- '.AppleDouble', '.DS_Store', '.byebug_history', 'errors.lst', 'tags'
15
+ '.AppleDouble', '.DS_Store', 'errors.lst', 'tags'
16
16
  package_ignore '.all_images', '.utilsrc', '.rspec', '.tool-versions',
17
17
  '.gitignore'
18
18
 
@@ -20,6 +20,8 @@ GemHadar do
20
20
  title "#{name.camelize} -- configuration library"
21
21
  licenses << 'Apache-2.0'
22
22
 
23
+ clobber 'coverage'
24
+
23
25
  dependency 'json'
24
26
  dependency 'tins'
25
27
  dependency 'mize', '~> 0.3', '>= 0.3.4'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.20.0
1
+ 0.21.1
@@ -1,29 +1,29 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: complex_config 0.20.0 ruby lib
2
+ # stub: complex_config 0.21.1 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "complex_config".freeze
6
- s.version = "0.20.0".freeze
6
+ s.version = "0.21.1".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]
10
10
  s.authors = ["Florian Frank".freeze]
11
- s.date = "2024-04-17"
11
+ s.date = "2024-09-09"
12
12
  s.description = "This library allows you to access configuration files via a simple interface".freeze
13
13
  s.email = "flori@ping.de".freeze
14
14
  s.executables = ["complex_config".freeze]
15
- s.extra_rdoc_files = ["README.md".freeze, "lib/complex_config.rb".freeze, "lib/complex_config/config.rb".freeze, "lib/complex_config/encryption.rb".freeze, "lib/complex_config/errors.rb".freeze, "lib/complex_config/key_source.rb".freeze, "lib/complex_config/plugins.rb".freeze, "lib/complex_config/plugins/enable.rb".freeze, "lib/complex_config/plugins/money.rb".freeze, "lib/complex_config/plugins/uri.rb".freeze, "lib/complex_config/provider.rb".freeze, "lib/complex_config/provider/shortcuts.rb".freeze, "lib/complex_config/proxy.rb".freeze, "lib/complex_config/railtie.rb".freeze, "lib/complex_config/rude.rb".freeze, "lib/complex_config/settings.rb".freeze, "lib/complex_config/shortcuts.rb".freeze, "lib/complex_config/version.rb".freeze]
16
- s.files = [".all_images.yml".freeze, "COPYING".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/complex_config".freeze, "complex_config.gemspec".freeze, "config/products.yml".freeze, "lib/complex_config.rb".freeze, "lib/complex_config/config.rb".freeze, "lib/complex_config/encryption.rb".freeze, "lib/complex_config/errors.rb".freeze, "lib/complex_config/key_source.rb".freeze, "lib/complex_config/plugins.rb".freeze, "lib/complex_config/plugins/enable.rb".freeze, "lib/complex_config/plugins/money.rb".freeze, "lib/complex_config/plugins/uri.rb".freeze, "lib/complex_config/provider.rb".freeze, "lib/complex_config/provider/shortcuts.rb".freeze, "lib/complex_config/proxy.rb".freeze, "lib/complex_config/railtie.rb".freeze, "lib/complex_config/rude.rb".freeze, "lib/complex_config/settings.rb".freeze, "lib/complex_config/shortcuts.rb".freeze, "lib/complex_config/version.rb".freeze, "spec/complex_config/config_spec.rb".freeze, "spec/complex_config/encryption_spec.rb".freeze, "spec/complex_config/key_source_spec.rb".freeze, "spec/complex_config/plugins_spec.rb".freeze, "spec/complex_config/provider_spec.rb".freeze, "spec/complex_config/settings_spec.rb".freeze, "spec/complex_config/shortcuts_spec.rb".freeze, "spec/config/broken_config.yml".freeze, "spec/config/config.yml".freeze, "spec/config/config_with_alias.yml".freeze, "spec/config/legacy_classes.yml".freeze, "spec/config/master.key".freeze, "spec/config/with-key-file.yml.enc".freeze, "spec/config/with-key-file.yml.key".freeze, "spec/config/without-key-file.yml.enc".freeze, "spec/spec_helper.rb".freeze]
15
+ s.extra_rdoc_files = ["README.md".freeze, "lib/complex_config.rb".freeze, "lib/complex_config/config.rb".freeze, "lib/complex_config/encryption.rb".freeze, "lib/complex_config/errors.rb".freeze, "lib/complex_config/key_source.rb".freeze, "lib/complex_config/plugins.rb".freeze, "lib/complex_config/plugins/enable.rb".freeze, "lib/complex_config/plugins/money.rb".freeze, "lib/complex_config/plugins/uri.rb".freeze, "lib/complex_config/provider.rb".freeze, "lib/complex_config/provider/shortcuts.rb".freeze, "lib/complex_config/proxy.rb".freeze, "lib/complex_config/railtie.rb".freeze, "lib/complex_config/rude.rb".freeze, "lib/complex_config/settings.rb".freeze, "lib/complex_config/shortcuts.rb".freeze, "lib/complex_config/tree.rb".freeze, "lib/complex_config/version.rb".freeze]
16
+ s.files = [".all_images.yml".freeze, "CHANGES.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/complex_config".freeze, "complex_config.gemspec".freeze, "config/products.yml".freeze, "lib/complex_config.rb".freeze, "lib/complex_config/config.rb".freeze, "lib/complex_config/encryption.rb".freeze, "lib/complex_config/errors.rb".freeze, "lib/complex_config/key_source.rb".freeze, "lib/complex_config/plugins.rb".freeze, "lib/complex_config/plugins/enable.rb".freeze, "lib/complex_config/plugins/money.rb".freeze, "lib/complex_config/plugins/uri.rb".freeze, "lib/complex_config/provider.rb".freeze, "lib/complex_config/provider/shortcuts.rb".freeze, "lib/complex_config/proxy.rb".freeze, "lib/complex_config/railtie.rb".freeze, "lib/complex_config/rude.rb".freeze, "lib/complex_config/settings.rb".freeze, "lib/complex_config/shortcuts.rb".freeze, "lib/complex_config/tree.rb".freeze, "lib/complex_config/version.rb".freeze, "spec/complex_config/config_spec.rb".freeze, "spec/complex_config/encryption_spec.rb".freeze, "spec/complex_config/key_source_spec.rb".freeze, "spec/complex_config/plugins_spec.rb".freeze, "spec/complex_config/provider_spec.rb".freeze, "spec/complex_config/settings_spec.rb".freeze, "spec/complex_config/shortcuts_spec.rb".freeze, "spec/config/broken_config.yml".freeze, "spec/config/config.yml".freeze, "spec/config/config_with_alias.yml".freeze, "spec/config/empty_config.yml".freeze, "spec/config/legacy_classes.yml".freeze, "spec/config/master.key".freeze, "spec/config/with-key-file.yml.enc".freeze, "spec/config/with-key-file.yml.key".freeze, "spec/config/without-key-file.yml.enc".freeze, "spec/spec_helper.rb".freeze]
17
17
  s.homepage = "https://github.com/flori/complex_config".freeze
18
18
  s.licenses = ["Apache-2.0".freeze]
19
19
  s.rdoc_options = ["--title".freeze, "ComplexConfig -- configuration library".freeze, "--main".freeze, "README.md".freeze]
20
- s.rubygems_version = "3.5.3".freeze
20
+ s.rubygems_version = "3.5.18".freeze
21
21
  s.summary = "configuration library".freeze
22
22
  s.test_files = ["spec/complex_config/config_spec.rb".freeze, "spec/complex_config/encryption_spec.rb".freeze, "spec/complex_config/key_source_spec.rb".freeze, "spec/complex_config/plugins_spec.rb".freeze, "spec/complex_config/provider_spec.rb".freeze, "spec/complex_config/settings_spec.rb".freeze, "spec/complex_config/shortcuts_spec.rb".freeze, "spec/spec_helper.rb".freeze]
23
23
 
24
24
  s.specification_version = 4
25
25
 
26
- s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.15.0".freeze])
26
+ s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.17.0".freeze])
27
27
  s.add_development_dependency(%q<rake>.freeze, [">= 0".freeze])
28
28
  s.add_development_dependency(%q<simplecov>.freeze, [">= 0".freeze])
29
29
  s.add_development_dependency(%q<rspec>.freeze, [">= 0".freeze])
data/config/products.yml CHANGED
@@ -4,18 +4,37 @@ development:
4
4
  name: Flux Capacitor Version 2.0
5
5
  price_in_cents: 12_000_00
6
6
  manual_pdf_url: "http://brown-inc.com/manuals/fc_20.pdf"
7
+ components:
8
+ - Miniature Chrono-Levitation Chamber (mCLC)
9
+ - Single Gravitational Displacement Coil (SGDC)
10
+ - Simple Quantum Flux Transducer (SQFT)
11
+ - Basic Time-Space Navigation System (BTN)
7
12
  pro_version:
8
13
  name: Flux Capacitor Professional
9
14
  price_in_cents: 23_000_00
10
15
  manual_pdf_url: "http://brown-inc.com/manuals/fc_pro.pdf"
16
+ components:
17
+ - Advanced Chrono-Levitation Chamber (ACL)
18
+ - Dual Gravitational Displacement Coils (DGDCs)
19
+ - Advanced Quantum Flux Transducer (AQFT)
20
+ - Professional Time-Space Navigation System (PTNS)
11
21
  enterprise_version:
12
22
  name: Flux Capacitor Enterpise
13
23
  price_in_cents: 1_600_000_00
14
24
  manual_pdf_url: "http://brown-inc.com/manuals/fc_enterprise.pdf"
15
-
25
+ components:
26
+ - Super-Advanced Chrono-Levitation Chamber (SACL)
27
+ - Quadruple Gravitational Displacement Coils (QGDCs)
28
+ - Ultra-Advanced Quantum Flux Transducer (UAQFT)
29
+ - Enterprise Time-Space Navigation System (ETNS)
16
30
  test:
17
31
  flux_capacitor:
18
32
  test_version:
19
33
  name: Yadayada
20
34
  price_in_cents: 6_66
21
35
  manual_pdf_url: "http://staging.brown-inc.com/manuals/fc_10.pdf"
36
+ components:
37
+ - Experimental Chrono-Levitation Chamber (ECLC)
38
+ - Modular Gravitational Displacement Coils (MGDCs)
39
+ - Variable Quantum Flux Transducer (VQFT)
40
+ - Development Time-Space Navigation System (DTNS)
@@ -4,6 +4,7 @@ require 'pathname'
4
4
  require 'yaml'
5
5
  require 'mize'
6
6
  require 'tins/xt/secure_write'
7
+ require 'tins/xt/ask_and_send'
7
8
 
8
9
  class ComplexConfig::Provider
9
10
  include Tins::SexySingleton
@@ -28,6 +28,7 @@ class ComplexConfig::Settings < BasicObject
28
28
 
29
29
  def build(name, hash)
30
30
  name.nil? or self.name_prefix = name.to_sym
31
+ hash.respond_to?(:to_hash) or raise TypeError, 'require hash to build'
31
32
  from_hash(hash)
32
33
  ensure
33
34
  self.name_prefix = nil
@@ -122,6 +123,10 @@ class ComplexConfig::Settings < BasicObject
122
123
  to_h.to_json(*a)
123
124
  end
124
125
 
126
+ def to_tree
127
+ ::ComplexConfig::Tree.convert(name_prefix, self)
128
+ end
129
+
125
130
  def size
126
131
  each.count
127
132
  end
@@ -130,13 +135,18 @@ class ComplexConfig::Settings < BasicObject
130
135
  size == 0
131
136
  end
132
137
 
133
- def to_s(pair_sep: ' = ', path_sep: ?.)
138
+ def list(pair_sep: ' = ', path_sep: ?.)
134
139
  empty? and return self.class.name
135
140
  pathes(path_sep: path_sep).inject('') do |result, (path, value)|
136
141
  result + "#{path}#{pair_sep}#{value.inspect}\n"
137
142
  end
138
143
  end
139
144
 
145
+ def to_s(*)
146
+ empty? and return self.class.name
147
+ to_tree.to_s
148
+ end
149
+
140
150
  def pathes(hash = table, path_sep: ?., prefix: name_prefix.to_s, result: {})
141
151
  hash.each do |key, value|
142
152
  path = prefix.empty? ? key.to_s : "#{prefix}#{path_sep}#{key}"
@@ -0,0 +1,80 @@
1
+ module ComplexConfig
2
+ class Tree
3
+ def self.convert(name, value)
4
+ case value
5
+ when ComplexConfig::Settings
6
+ convert(name, value.to_h)
7
+ when Hash
8
+ obj = new(name.to_s)
9
+ value.each do |name, value|
10
+ obj << convert(name, value)
11
+ end
12
+ obj
13
+ when Array
14
+ obj = new(name.to_s)
15
+ value.each_with_index do |value, i|
16
+ obj << convert(i, value)
17
+ end
18
+ obj
19
+ else
20
+ if name.is_a?(Integer)
21
+ new value.inspect
22
+ else
23
+ new "#{name} = #{value.inspect}"
24
+ end
25
+ end
26
+ end
27
+
28
+ def initialize(name)
29
+ @name = name
30
+ @children = []
31
+ end
32
+
33
+ private
34
+
35
+ def inner_child_prefix(i)
36
+ i.zero? ? "├─ " : "│ "
37
+ end
38
+
39
+ def last_child_prefix(i)
40
+ i.zero? ? "└─ " : " "
41
+ end
42
+
43
+ public
44
+
45
+ def to_enum
46
+ Enumerator.new do |y|
47
+ y.yield @name
48
+
49
+ @children.each_with_index do |child, child_index|
50
+ children_enum = child.to_enum
51
+ if child_index < @children.size - 1
52
+ children_enum.each_with_index do |setting, i|
53
+ y.yield "#{inner_child_prefix(i)}#{setting}"
54
+ end
55
+ else
56
+ children_enum.each_with_index do |setting, i|
57
+ y.yield "#{last_child_prefix(i)}#{setting}"
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ def <<(child)
65
+ @children << child
66
+ end
67
+
68
+ def to_ary
69
+ to_enum.to_a
70
+ end
71
+
72
+ alias to_a to_ary
73
+
74
+ def to_str
75
+ to_ary * ?\n
76
+ end
77
+
78
+ alias to_s to_str
79
+ end
80
+ end
@@ -1,6 +1,6 @@
1
1
  module ComplexConfig
2
2
  # ComplexConfig version
3
- VERSION = '0.20.0'
3
+ VERSION = '0.21.1'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -6,6 +6,7 @@ end
6
6
  require 'complex_config/version'
7
7
  require 'complex_config/errors'
8
8
  require 'complex_config/proxy'
9
+ require 'complex_config/tree'
9
10
  require 'complex_config/settings'
10
11
  require 'complex_config/config'
11
12
  require 'complex_config/key_source'
@@ -84,6 +84,12 @@ RSpec.describe ComplexConfig::Provider do
84
84
  ).to be_a ComplexConfig::Settings
85
85
  end
86
86
 
87
+ it 'cannot read from an empty configuration file' do
88
+ expect {
89
+ described_class.config(asset('empty_config.yml'))
90
+ }.to raise_error(TypeError)
91
+ end
92
+
87
93
  it 'has deep frozen settings' do
88
94
  settings = described_class.config(asset('config.yml'))
89
95
  expect(settings).to be_frozen
@@ -7,7 +7,7 @@ RSpec.describe ComplexConfig::Settings do
7
7
  end
8
8
 
9
9
  let :settings do
10
- described_class[
10
+ obj = described_class[
11
11
  foo: {
12
12
  bar: {
13
13
  baz: true
@@ -15,6 +15,8 @@ RSpec.describe ComplexConfig::Settings do
15
15
  qux: 'quux'
16
16
  }
17
17
  ]
18
+ obj.name_prefix = 'root'
19
+ obj
18
20
  end
19
21
 
20
22
  it 'can be initialized with a hash' do
@@ -79,36 +81,58 @@ RSpec.describe ComplexConfig::Settings do
79
81
 
80
82
  it 'can return a hash with pathes as keys' do
81
83
  expect(settings.pathes(path_sep: ?:)).to eq(
82
- 'foo:bar:baz' => true,
83
- 'foo:qux' => "quux"
84
+ 'root:foo:bar:baz' => true,
85
+ 'root:foo:qux' => "quux"
84
86
  )
85
87
  end
86
88
 
87
- it 'can be represented as a string' do
88
- expect(settings.to_s(pair_sep: ' → ', path_sep: ?/)).to eq <<EOT
89
- foo/bar/baz → true
90
- foo/qux → "quux"
91
- EOT
89
+ it 'can be listed as string' do
90
+ expect(settings.list(pair_sep: ' → ', path_sep: ?/)).to eq <<~EOT
91
+ root/foo/bar/baz → true
92
+ root/foo/qux → "quux"
93
+ EOT
92
94
  end
93
95
 
94
96
  it 'responds with class name if #to_s is called on empty settigs' do
95
97
  expect(described_class.new.to_s).to eq described_class.name
96
98
  end
97
99
 
98
- it 'can be represented as a string if it has arrays' do
100
+ it 'can be listesd as a string if it has arrays' do
99
101
  settings[:ary] = described_class[ [ 1, { nested: 2 }, 3 ] ]
100
- expect(settings.to_s).to eq <<EOT
101
- foo.bar.baz = true
102
- foo.qux = "quux"
103
- ary[0] = 1
104
- ary[1].nested = 2
105
- ary[2] = 3
106
- EOT
102
+ expect(settings.list).to eq <<~EOT
103
+ root.foo.bar.baz = true
104
+ root.foo.qux = "quux"
105
+ root.ary[0] = 1
106
+ root.ary[1].nested = 2
107
+ root.ary[2] = 3
108
+ EOT
109
+ end
110
+
111
+ it 'can be represented as tree' do
112
+ settings[:ary] = described_class[ [ 1, { nested: 2 }, 3 ] ]
113
+ expect(settings.to_tree.to_s).to eq <<~EOT.chomp
114
+ root
115
+ ├─ foo
116
+ │ ├─ bar
117
+ │ │ └─ baz = true
118
+ │ └─ qux = "quux"
119
+ └─ ary
120
+ ├─ 1
121
+ ├─ 1
122
+ │ └─ nested = 2
123
+ └─ 3
124
+ EOT
107
125
  end
108
126
 
109
127
  it 'can be pretty printed' do
110
128
  q = double
111
- expect(q).to receive(:text).with("foo.bar.baz = true\nfoo.qux = \"quux\"\n")
129
+ expect(q).to receive(:text).with(<<~EOT.chomp)
130
+ root
131
+ └─ foo
132
+ ├─ bar
133
+ │ └─ baz = true
134
+ └─ qux = "quux"
135
+ EOT
112
136
  settings.pretty_print(q)
113
137
  end
114
138
 
File without changes
data/spec/spec_helper.rb CHANGED
@@ -6,7 +6,7 @@ if ENV['START_SIMPLECOV'].to_i == 1
6
6
  end
7
7
  require 'rspec'
8
8
  begin
9
- require 'byebug'
9
+ require 'debug'
10
10
  rescue LoadError
11
11
  end
12
12
  require 'complex_config'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: complex_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.21.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-17 00:00:00.000000000 Z
11
+ date: 2024-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.15.0
19
+ version: 1.17.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.15.0
26
+ version: 1.17.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -193,11 +193,13 @@ extra_rdoc_files:
193
193
  - lib/complex_config/rude.rb
194
194
  - lib/complex_config/settings.rb
195
195
  - lib/complex_config/shortcuts.rb
196
+ - lib/complex_config/tree.rb
196
197
  - lib/complex_config/version.rb
197
198
  files:
198
199
  - ".all_images.yml"
199
- - COPYING
200
+ - CHANGES.md
200
201
  - Gemfile
202
+ - LICENSE
201
203
  - README.md
202
204
  - Rakefile
203
205
  - VERSION
@@ -220,6 +222,7 @@ files:
220
222
  - lib/complex_config/rude.rb
221
223
  - lib/complex_config/settings.rb
222
224
  - lib/complex_config/shortcuts.rb
225
+ - lib/complex_config/tree.rb
223
226
  - lib/complex_config/version.rb
224
227
  - spec/complex_config/config_spec.rb
225
228
  - spec/complex_config/encryption_spec.rb
@@ -231,6 +234,7 @@ files:
231
234
  - spec/config/broken_config.yml
232
235
  - spec/config/config.yml
233
236
  - spec/config/config_with_alias.yml
237
+ - spec/config/empty_config.yml
234
238
  - spec/config/legacy_classes.yml
235
239
  - spec/config/master.key
236
240
  - spec/config/with-key-file.yml.enc
@@ -260,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
260
264
  - !ruby/object:Gem::Version
261
265
  version: '0'
262
266
  requirements: []
263
- rubygems_version: 3.5.3
267
+ rubygems_version: 3.5.18
264
268
  signing_key:
265
269
  specification_version: 4
266
270
  summary: configuration library
File without changes