complex_config 0.21.1 → 0.22.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1be2d6a3e3fa81319f6455a9e4f158f45d096c322a3d224e8547fe81a4490b33
4
- data.tar.gz: fc4bfec9fac1f616f51818f3bcd1ebf0ca4db5102d7430b09207339746472293
3
+ metadata.gz: 87d37380ff1a936489b129f9b8c880809a8aa5d4f36ab5f150ceb2e639bc56e7
4
+ data.tar.gz: edabf53e8b9ed1e6a1bec250ed5abe66a451c9da14a5ac253eb6797cd588dec2
5
5
  SHA512:
6
- metadata.gz: 65f0b0f8c29597bda6a31a2c80285e02caeccb7068e184f8385dfa8849233623382a6667407328fcc3b2c5a91f108885daba55f4b4eb70f7ea7f1b241e82833a
7
- data.tar.gz: 23fbb4f4bc736e10606cd001ec1af90bba397ad939720d148354e9fada7cbb4a0b6b849ffe7592d7692247a4d615d600f430ddbc39c11423d33e3ce360be902b
6
+ metadata.gz: 924206444ddc739ef51bb9367974947ccd63d883e4ed58a16f499ca8bee103ed3fab8d5b1e008e8c69ca7b6eee8ba235ef6ec59886c728c0fa46bf0a6fbce390
7
+ data.tar.gz: 4f7e39f2a7e46024c7bdedb762d252d6e6b0f867b492a38a29dfdb64d835973948fb7df376d468d8574b256bac0f0c539c091e0489e30414f317eb5c04d88c01
data/CHANGES.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changes
2
2
 
3
+ ## 2024-09-12 v0.22.0
4
+
5
+ * **New Feature: UTF-8 Support**
6
+ + Added `utf8` parameter to `Tree#initialize`
7
+ + Introduced `default_utf8` method to determine default encoding based on environment variables
8
+ + Modified `inner_child_prefix` and `last_child_prefix` methods for UTF-8 and ASCII encodings
9
+ + Updated tests in `spec/complex_config/settings_spec.rb`
10
+
11
+ ## 2024-09-09 v0.21.2
12
+
13
+ * **Settings List Method**:
14
+ + Renamed `list` to `attributes_list`.
15
+ + Updated tests in `settings_spec.rb` to use the new method name.
16
+
3
17
  ## 2024-09-09 v0.21.1
4
18
 
5
19
  * **API Changes**:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.21.1
1
+ 0.22.0
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: complex_config 0.21.1 ruby lib
2
+ # stub: complex_config 0.22.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "complex_config".freeze
6
- s.version = "0.21.1".freeze
6
+ s.version = "0.22.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]
10
10
  s.authors = ["Florian Frank".freeze]
11
- s.date = "2024-09-09"
11
+ s.date = "2024-09-12"
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]
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
 
24
24
  s.specification_version = 4
25
25
 
26
- s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.17.0".freeze])
26
+ s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.17.1".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])
@@ -135,7 +135,7 @@ class ComplexConfig::Settings < BasicObject
135
135
  size == 0
136
136
  end
137
137
 
138
- def list(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"
@@ -25,19 +25,32 @@ module ComplexConfig
25
25
  end
26
26
  end
27
27
 
28
- def initialize(name)
28
+ def initialize(name, utf8: default_utf8)
29
29
  @name = name
30
+ @utf8 = utf8
30
31
  @children = []
31
32
  end
32
33
 
34
+ def default_utf8
35
+ !!(ENV['LANG'] =~ /utf-8\z/i)
36
+ end
37
+
33
38
  private
34
39
 
35
40
  def inner_child_prefix(i)
36
- i.zero? ? "├─ " : "│ "
41
+ if @utf8
42
+ i.zero? ? "├─ " : "│ "
43
+ else
44
+ i.zero? ? "+- " : "| "
45
+ end
37
46
  end
38
47
 
39
48
  def last_child_prefix(i)
40
- i.zero? ? "└─ " : " "
49
+ if @utf8
50
+ i.zero? ? "└─ " : " "
51
+ else
52
+ i.zero? ? "`- " : " "
53
+ end
41
54
  end
42
55
 
43
56
  public
@@ -1,6 +1,6 @@
1
1
  module ComplexConfig
2
2
  # ComplexConfig version
3
- VERSION = '0.21.1'
3
+ VERSION = '0.22.0'
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,13 @@ RSpec.describe ComplexConfig::Settings do
6
6
  allow(ComplexConfig::Provider.instance).to receive(:plugins).and_return([])
7
7
  end
8
8
 
9
+ around do |example|
10
+ old_locale, ENV['LOCAL'] = 'en_US.UTF-8', ENV['LANG']
11
+ example.run
12
+ ensure
13
+ ENV['LOCAL'] = old_locale
14
+ end
15
+
9
16
  let :settings do
10
17
  obj = described_class[
11
18
  foo: {
@@ -87,7 +94,7 @@ RSpec.describe ComplexConfig::Settings do
87
94
  end
88
95
 
89
96
  it 'can be listed as string' do
90
- expect(settings.list(pair_sep: ' → ', path_sep: ?/)).to eq <<~EOT
97
+ expect(settings.attributes_list(pair_sep: ' → ', path_sep: ?/)).to eq <<~EOT
91
98
  root/foo/bar/baz → true
92
99
  root/foo/qux → "quux"
93
100
  EOT
@@ -99,7 +106,7 @@ RSpec.describe ComplexConfig::Settings do
99
106
 
100
107
  it 'can be listesd as a string if it has arrays' do
101
108
  settings[:ary] = described_class[ [ 1, { nested: 2 }, 3 ] ]
102
- expect(settings.list).to eq <<~EOT
109
+ expect(settings.attributes_list).to eq <<~EOT
103
110
  root.foo.bar.baz = true
104
111
  root.foo.qux = "quux"
105
112
  root.ary[0] = 1
@@ -124,7 +131,7 @@ RSpec.describe ComplexConfig::Settings do
124
131
  EOT
125
132
  end
126
133
 
127
- it 'can be pretty printed' do
134
+ it 'can be pretty printed with utf8' do
128
135
  q = double
129
136
  expect(q).to receive(:text).with(<<~EOT.chomp)
130
137
  root
@@ -136,6 +143,19 @@ RSpec.describe ComplexConfig::Settings do
136
143
  settings.pretty_print(q)
137
144
  end
138
145
 
146
+ it 'can be pretty printed with ASCII7' do
147
+ q = double
148
+ expect(q).to receive(:text).with(<<~EOT.chomp)
149
+ root
150
+ `- foo
151
+ +- bar
152
+ | `- baz = true
153
+ `- qux = "quux"
154
+ EOT
155
+ ENV['LANG'] = 'de_DE.ISO8859-15'
156
+ settings.pretty_print(q)
157
+ end
158
+
139
159
  it 'can be converted into YAML' do
140
160
  expect(settings.to_yaml).to eq <<EOT
141
161
  ---
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.21.1
4
+ version: 0.22.0
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-09-09 00:00:00.000000000 Z
11
+ date: 2024-09-12 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.17.0
19
+ version: 1.17.1
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.17.0
26
+ version: 1.17.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement