complex_config 0.21.2 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6474060cd0f183904552779ab98ae7cb6fb9db5599fc482a903f3d392275179b
4
- data.tar.gz: 035c81f9e729450c78768c37db1d4e59d22e3e2836e024bc673ade290bde3d78
3
+ metadata.gz: 87d37380ff1a936489b129f9b8c880809a8aa5d4f36ab5f150ceb2e639bc56e7
4
+ data.tar.gz: edabf53e8b9ed1e6a1bec250ed5abe66a451c9da14a5ac253eb6797cd588dec2
5
5
  SHA512:
6
- metadata.gz: 1354001406f48dd90e2cdefa85aace10f96bdcbaadc1f64fcd470bdbcd3cc8a7c82a9db56766b61cb37c944d4a465838c9157c369f6213c476797b8003647d91
7
- data.tar.gz: 81cedae129b2079be7bd94b473d6d17ce53d292fc83493ee491bb73b86e5f7690849bf66f5d7a25c5ba36101210294a932b3857ac10512cf8c21a0f1311fcd70
6
+ metadata.gz: 924206444ddc739ef51bb9367974947ccd63d883e4ed58a16f499ca8bee103ed3fab8d5b1e008e8c69ca7b6eee8ba235ef6ec59886c728c0fa46bf0a6fbce390
7
+ data.tar.gz: 4f7e39f2a7e46024c7bdedb762d252d6e6b0f867b492a38a29dfdb64d835973948fb7df376d468d8574b256bac0f0c539c091e0489e30414f317eb5c04d88c01
data/CHANGES.md CHANGED
@@ -1,5 +1,13 @@
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
+
3
11
  ## 2024-09-09 v0.21.2
4
12
 
5
13
  * **Settings List Method**:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.21.2
1
+ 0.22.0
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: complex_config 0.21.2 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.2".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])
@@ -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.2'
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: {
@@ -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.2
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