complex_config 0.21.0 → 0.21.2

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: 432209a0d29d4d47874c82ebe27f311e3a545b1aac932bcf31e0307f8b3dc1fb
4
- data.tar.gz: 6ed546fc3bbb9032503dc501c7d8350e145255756ca5cbcea18c10758e982577
3
+ metadata.gz: 6474060cd0f183904552779ab98ae7cb6fb9db5599fc482a903f3d392275179b
4
+ data.tar.gz: 035c81f9e729450c78768c37db1d4e59d22e3e2836e024bc673ade290bde3d78
5
5
  SHA512:
6
- metadata.gz: b7a1a956b49424098d206442242850356de73db068d715d1d9bcfa0659cb336043d6d65af530c7ef0c6d7a021a91122bcaf2baba1998bbc49c0ea7266b582b55
7
- data.tar.gz: c07a01e3c26ce55862c34a9b42caff05dfa7ed7730be92684eb1eacd335f4badf82c2dcaabe042429610ba4ac3324a2b62b3903dc8c89e428568e4fa230ffe16
6
+ metadata.gz: 1354001406f48dd90e2cdefa85aace10f96bdcbaadc1f64fcd470bdbcd3cc8a7c82a9db56766b61cb37c944d4a465838c9157c369f6213c476797b8003647d91
7
+ data.tar.gz: 81cedae129b2079be7bd94b473d6d17ce53d292fc83493ee491bb73b86e5f7690849bf66f5d7a25c5ba36101210294a932b3857ac10512cf8c21a0f1311fcd70
data/CHANGES.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changes
2
2
 
3
+ ## 2024-09-09 v0.21.2
4
+
5
+ * **Settings List Method**:
6
+ + Renamed `list` to `attributes_list`.
7
+ + Updated tests in `settings_spec.rb` to use the new method name.
8
+
9
+ ## 2024-09-09 v0.21.1
10
+
11
+ * **API Changes**:
12
+ * The default string representation of ComplexConfig has been changed to a tree-like structure.
13
+ * The `to_s` method in ComplexConfig::Settings has been renamed to `list`.
14
+ * A new `list` method has been added to ComplexConfig::Settings for listing settings as a string.
15
+
3
16
  ## 2024-09-09 v0.21.0
4
17
 
5
18
  * **Tree Representation**:
data/README.md CHANGED
@@ -98,13 +98,17 @@ plugin return an URI instance:
98
98
  You can also fetch config settings from a different environment:
99
99
 
100
100
  >> pp cc.products(:test); nil
101
- products.flux_capacitor.test_version.name = "Yadayada"
102
- products.flux_capacitor.test_version.price_in_cents = 666
103
- products.flux_capacitor.test_version.manual_pdf_url = "http://staging.brown-inc.com/manuals/fc_10.pdf"
104
- products.flux_capacitor.test_version.components[0] = "Experimental Chrono-Levitation Chamber (ECLC)"
105
- products.flux_capacitor.test_version.components[1] = "Modular Gravitational Displacement Coils (MGDCs)"
106
- products.flux_capacitor.test_version.components[2] = "Variable Quantum Flux Transducer (VQFT)"
107
- products.flux_capacitor.test_version.components[3] = "Development Time-Space Navigation System (DTNS)"
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
108
112
 
109
113
  Calling `complex_config.products.` instead of `cc(…)` would skip the implicite
110
114
  namespacing via the `RAILS_ENV` environment, so
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.21.0
1
+ 0.21.2
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: complex_config 0.21.0 ruby lib
2
+ # stub: complex_config 0.21.2 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "complex_config".freeze
6
- s.version = "0.21.0".freeze
6
+ s.version = "0.21.2".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]
@@ -135,13 +135,18 @@ class ComplexConfig::Settings < BasicObject
135
135
  size == 0
136
136
  end
137
137
 
138
- def to_s(pair_sep: ' = ', path_sep: ?.)
138
+ def attributes_list(pair_sep: ' = ', path_sep: ?.)
139
139
  empty? and return self.class.name
140
140
  pathes(path_sep: path_sep).inject('') do |result, (path, value)|
141
141
  result + "#{path}#{pair_sep}#{value.inspect}\n"
142
142
  end
143
143
  end
144
144
 
145
+ def to_s(*)
146
+ empty? and return self.class.name
147
+ to_tree.to_s
148
+ end
149
+
145
150
  def pathes(hash = table, path_sep: ?., prefix: name_prefix.to_s, result: {})
146
151
  hash.each do |key, value|
147
152
  path = prefix.empty? ? key.to_s : "#{prefix}#{path_sep}#{key}"
@@ -1,6 +1,6 @@
1
1
  module ComplexConfig
2
2
  # ComplexConfig version
3
- VERSION = '0.21.0'
3
+ VERSION = '0.21.2'
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:
@@ -86,47 +86,53 @@ RSpec.describe ComplexConfig::Settings do
86
86
  )
87
87
  end
88
88
 
89
- it 'can be represented as a string' do
90
- expect(settings.to_s(pair_sep: ' → ', path_sep: ?/)).to eq <<EOT
91
- root/foo/bar/baz → true
92
- root/foo/qux → "quux"
93
- EOT
89
+ it 'can be listed as string' do
90
+ expect(settings.attributes_list(pair_sep: ' → ', path_sep: ?/)).to eq <<~EOT
91
+ root/foo/bar/baz → true
92
+ root/foo/qux → "quux"
93
+ EOT
94
94
  end
95
95
 
96
96
  it 'responds with class name if #to_s is called on empty settigs' do
97
97
  expect(described_class.new.to_s).to eq described_class.name
98
98
  end
99
99
 
100
- 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
101
101
  settings[:ary] = described_class[ [ 1, { nested: 2 }, 3 ] ]
102
- expect(settings.to_s).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
102
+ expect(settings.attributes_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
109
  end
110
110
 
111
111
  it 'can be represented as tree' do
112
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
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
125
125
  end
126
126
 
127
127
  it 'can be pretty printed' do
128
128
  q = double
129
- expect(q).to receive(:text).with("root.foo.bar.baz = true\nroot.foo.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
130
136
  settings.pretty_print(q)
131
137
  end
132
138
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: complex_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.0
4
+ version: 0.21.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank