complex_config 0.23.0 → 0.25.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 +28 -1
- data/README.md +20 -0
- data/VERSION +1 -1
- data/bin/complex_config +32 -17
- data/complex_config.gemspec +4 -4
- data/lib/complex_config/plugins/money.rb +2 -1
- data/lib/complex_config/version.rb +1 -1
- data/spec/complex_config/plugins_spec.rb +53 -22
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a31f4ffa0d9542e26c19f2a3e6e664e996ebc69d4c700832159bbf4448d3e881
|
|
4
|
+
data.tar.gz: c81b874b5e802bb66b888727ed63c0573be0ee68e9b141d4ef54478b352d6406
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6de56cb12568bbb945ddc06fae9065e98de0e09ba48d18a7bb1c0ec05b47e5e8995f1413a46fb425f0e02392b427ad35f763dd7d668d00a0565ea998b85484f9
|
|
7
|
+
data.tar.gz: abb1787b14b12a6565134a95480cff03cc69efac45cbb455c6ddb774a5911fa891b90d91e02c6518b43817e3cc56b9880f8af40f22d213a8e6f5b03081ac375f
|
data/CHANGES.md
CHANGED
|
@@ -1,4 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
## 2025-12-19 v0.25.0
|
|
2
|
+
|
|
3
|
+
- Added support for Ruby **4.0**-rc-alpine image in test matrix
|
|
4
|
+
- Enhanced `ComplexConfig::Plugins::MONEY` plugin to support configurable
|
|
5
|
+
default currency via `COMPLEX_CONFIG_MONEY_DEFAULT_CURRENCY` environment
|
|
6
|
+
variable
|
|
7
|
+
- Changed money gem usage from `Money.new(cents)` to `Money.from_cents(cents,
|
|
8
|
+
currency.upcase)` for proper currency handling
|
|
9
|
+
- Updated plugin to default to **EUR** currency when no environment variable is set
|
|
10
|
+
- Added comprehensive test coverage for default **EUR** and custom **BTC**
|
|
11
|
+
currency scenarios
|
|
12
|
+
- Implemented proper environment variable isolation in tests using `around`
|
|
13
|
+
blocks
|
|
14
|
+
- Updated `s.rubygems_version` from **3.7.2** to **4.0.2**
|
|
15
|
+
- Updated `gem_hadar` development dependency from version **2.8** to **2.10**
|
|
16
|
+
- Changed `bundle update` to `bundle update --all` in `.all_images.yml` to
|
|
17
|
+
ensure all gems are updated
|
|
18
|
+
|
|
19
|
+
## 2025-11-24 v0.24.0
|
|
20
|
+
|
|
21
|
+
- Added `-O` option to `complex_config` decrypt command to write output to stdout
|
|
22
|
+
- Added `-I` option to `complex_config` encrypt command to read input from stdin
|
|
23
|
+
- Modified `decrypt` command to handle stdout output when `-O` flag is present
|
|
24
|
+
- Marked `display` as alias for `decrypt -O` in help text
|
|
25
|
+
- Replaced custom `did_not_change` exception with `catch`/`throw` mechanism in edit command
|
|
26
|
+
- Updated `rubygems_version` from **3.6.9** to **3.7.2**
|
|
27
|
+
- Updated `gem_hadar` development dependency from **~> 2.6** to **~> 2.8**
|
|
28
|
+
- Added `openssl-dev` to apk packages in `.all_images.yml`
|
|
2
29
|
|
|
3
30
|
## 2025-09-14 v0.23.0
|
|
4
31
|
|
data/README.md
CHANGED
|
@@ -674,6 +674,26 @@ module ComplexConfig::Plugins
|
|
|
674
674
|
end
|
|
675
675
|
```
|
|
676
676
|
|
|
677
|
+
### MONEY Plugin Configuration
|
|
678
|
+
|
|
679
|
+
The `MONEY` plugin supports configurable default currencies through the
|
|
680
|
+
`COMPLEX_CONFIG_MONEY_DEFAULT_CURRENCY` environment variable:
|
|
681
|
+
|
|
682
|
+
```ruby
|
|
683
|
+
# Default behavior - uses EUR if no environment variable is set
|
|
684
|
+
MONEY = -> id, currency = ENV.fetch('COMPLEX_CONFIG_MONEY_DEFAULT_CURRENCY', 'EUR') do
|
|
685
|
+
if cents = ask_and_send("#{id}_in_cents")
|
|
686
|
+
Money.from_cents(cents, currency.upcase)
|
|
687
|
+
else
|
|
688
|
+
skip
|
|
689
|
+
end
|
|
690
|
+
end
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
**Important Note**: Modern versions of the `money` gem require explicit
|
|
694
|
+
currency specification. The plugin now uses `Money.from_cents(cents, currency)`
|
|
695
|
+
instead of `Money.new(cents)` to ensure proper currency handling.
|
|
696
|
+
|
|
677
697
|
## Download 📥
|
|
678
698
|
|
|
679
699
|
The homepage of this library is located at
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.25.0
|
data/bin/complex_config
CHANGED
|
@@ -17,7 +17,7 @@ require 'tempfile'
|
|
|
17
17
|
require 'fileutils'
|
|
18
18
|
include FileUtils
|
|
19
19
|
|
|
20
|
-
$opts = go 'o:n:
|
|
20
|
+
$opts = go 'o:n:IOh'
|
|
21
21
|
|
|
22
22
|
# The usage method displays help information and exits the program
|
|
23
23
|
#
|
|
@@ -37,13 +37,15 @@ def usage(msg: 'Displaying help', rc: 0)
|
|
|
37
37
|
edit edit encrypted file FILENAME (suffix .enc)
|
|
38
38
|
encrypt encrypt file FILENAME (suffix not .enc)
|
|
39
39
|
decrypt decrypt file FILENAME (suffix .enc)
|
|
40
|
-
display
|
|
40
|
+
display alias for for decrypt -O
|
|
41
41
|
new_key generate a new key and display it
|
|
42
42
|
recrypt recrypt a file, -o OLD_KEY to decrypt, -n NEW_KEY to encrypt
|
|
43
43
|
|
|
44
44
|
Options are
|
|
45
45
|
|
|
46
46
|
-c CONFIG_DIR set CONFIG_DIR (default: "./config")
|
|
47
|
+
-I read input from stdin instead of file (encrypt)
|
|
48
|
+
-O write output to stdout instead of file (decrypt)
|
|
47
49
|
-h this help
|
|
48
50
|
|
|
49
51
|
end
|
|
@@ -59,7 +61,7 @@ end
|
|
|
59
61
|
#
|
|
60
62
|
# @param suffix [TrueClass, FalseClass] whether to validate or remove the .enc suffix
|
|
61
63
|
# @return [String] the validated filename without the .enc suffix if requested
|
|
62
|
-
def fetch_filename(suffix: true)
|
|
64
|
+
def fetch_filename(suffix: true, check_exist: true)
|
|
63
65
|
fn = ARGV.shift.dup or usage msg: "config filename required", rc: 1
|
|
64
66
|
if suffix
|
|
65
67
|
unless fn.end_with?('.enc')
|
|
@@ -70,7 +72,9 @@ def fetch_filename(suffix: true)
|
|
|
70
72
|
usage msg: "config filename seems to be already encrypted with suffix .enc", rc: 1
|
|
71
73
|
end
|
|
72
74
|
end
|
|
73
|
-
|
|
75
|
+
if check_exist
|
|
76
|
+
File.exist?(fn) or usage msg: "config filename #{fn} doesn't exist", rc: 1
|
|
77
|
+
end
|
|
74
78
|
suffix and fn.sub!(/\.enc\z/, '')
|
|
75
79
|
fn
|
|
76
80
|
end
|
|
@@ -81,8 +85,7 @@ ComplexConfig::Provider.config_dir = File.expand_path($opts[?c] || './config')
|
|
|
81
85
|
case command = ARGV.shift
|
|
82
86
|
when 'edit'
|
|
83
87
|
fn = fetch_filename
|
|
84
|
-
did_not_change
|
|
85
|
-
begin
|
|
88
|
+
catch :did_not_change do
|
|
86
89
|
File.secure_write(fn + '.enc') do |f|
|
|
87
90
|
Tempfile.open('complex_config') do |t|
|
|
88
91
|
config = ComplexConfig::Provider.decrypt_config(fn)
|
|
@@ -92,31 +95,43 @@ when 'edit'
|
|
|
92
95
|
new_config = IO.binread(t.path)
|
|
93
96
|
if config == new_config
|
|
94
97
|
puts "Configuration hasn't been changed."
|
|
95
|
-
|
|
98
|
+
throw :did_not_change
|
|
96
99
|
else
|
|
97
100
|
f.write ComplexConfig::Provider.encrypt_config(fn, new_config)
|
|
98
101
|
puts "New configuration has been written."
|
|
99
102
|
end
|
|
100
103
|
end
|
|
101
104
|
end
|
|
102
|
-
rescue did_not_change
|
|
103
105
|
end
|
|
104
106
|
when 'decrypt'
|
|
105
107
|
fn = fetch_filename
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
if $opts[?O]
|
|
109
|
+
$stdout.puts ComplexConfig::Provider.decrypt_config(fn)
|
|
110
|
+
else
|
|
111
|
+
File.exist?(fn) and usage msg: "decrypted config #{fn.inspect} already exists", rc: 1
|
|
112
|
+
File.secure_write(fn) do |f|
|
|
113
|
+
f.write ComplexConfig::Provider.decrypt_config(fn)
|
|
114
|
+
end
|
|
115
|
+
puts "File was decrypted to #{fn.inspect}. You can remove #{(fn + '.enc').inspect} now."
|
|
109
116
|
end
|
|
110
|
-
puts "File was decrypted to #{fn.inspect}. You can remove #{(fn + '.enc').inspect} now."
|
|
111
117
|
when 'display'
|
|
112
|
-
puts ComplexConfig::Provider.decrypt_config(fetch_filename)
|
|
118
|
+
$stdout.puts ComplexConfig::Provider.decrypt_config(fetch_filename)
|
|
113
119
|
when 'encrypt'
|
|
114
|
-
fn = fetch_filename suffix: false
|
|
120
|
+
fn = fetch_filename suffix: false, check_exist: !$opts[?I]
|
|
115
121
|
File.exist?(fn + '.enc') and usage msg: "encrypted config #{(fn + '.enc').inspect} already exists", rc: 1
|
|
116
|
-
|
|
117
|
-
|
|
122
|
+
if $opts[?I]
|
|
123
|
+
encrypted_data = ComplexConfig::Provider.encrypt_config(fn, $stdin.read)
|
|
124
|
+
File.secure_write(fn + '.enc') do |f|
|
|
125
|
+
f.write encrypted_data
|
|
126
|
+
end
|
|
127
|
+
puts "File was encrypted to #{(fn + '.enc').inspect} from stdin."
|
|
128
|
+
else
|
|
129
|
+
encrypted_data = ComplexConfig::Provider.encrypt_config(fn, IO.binread(fn))
|
|
130
|
+
File.secure_write(fn + '.enc') do |f|
|
|
131
|
+
f.write encrypted_data
|
|
132
|
+
end
|
|
133
|
+
puts "File was encrypted to #{(fn + '.enc').inspect}. You can remove #{fn.inspect} now."
|
|
118
134
|
end
|
|
119
|
-
puts "File was encrypted to #{(fn + '.enc').inspect}. You can remove #{fn.inspect} now."
|
|
120
135
|
when 'new_key'
|
|
121
136
|
puts ComplexConfig::Provider.new_key
|
|
122
137
|
when 'recrypt'
|
data/complex_config.gemspec
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: complex_config 0.
|
|
2
|
+
# stub: complex_config 0.25.0 ruby lib
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = "complex_config".freeze
|
|
6
|
-
s.version = "0.
|
|
6
|
+
s.version = "0.25.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]
|
|
@@ -17,13 +17,13 @@ Gem::Specification.new do |s|
|
|
|
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 = "
|
|
20
|
+
s.rubygems_version = "4.0.2".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, ["~> 2.
|
|
26
|
+
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 2.10".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])
|
|
@@ -8,8 +8,9 @@ rescue LoadError
|
|
|
8
8
|
else
|
|
9
9
|
module ComplexConfig::Plugins
|
|
10
10
|
MONEY = -> id do
|
|
11
|
+
currency = ENV.fetch('COMPLEX_CONFIG_MONEY_DEFAULT_CURRENCY', 'EUR')
|
|
11
12
|
if cents = ask_and_send("#{id}_in_cents")
|
|
12
|
-
Money.
|
|
13
|
+
Money.from_cents(cents, currency.upcase)
|
|
13
14
|
else
|
|
14
15
|
skip
|
|
15
16
|
end
|
|
@@ -6,40 +6,71 @@ describe ComplexConfig::Plugins do
|
|
|
6
6
|
ComplexConfig::Provider
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
context described_class::URI do
|
|
19
|
-
it 'can return an URL string' do
|
|
20
|
-
expect(settings.foo.test_url).to eq 'http://www.ping.de'
|
|
9
|
+
context 'with EUR default' do
|
|
10
|
+
let :settings do
|
|
11
|
+
ComplexConfig::Settings[
|
|
12
|
+
foo: {
|
|
13
|
+
test_url: 'http://www.ping.de',
|
|
14
|
+
cash_in_cents: 100.to_money('EUR').cents
|
|
15
|
+
}
|
|
16
|
+
]
|
|
21
17
|
end
|
|
22
18
|
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
around do |example|
|
|
20
|
+
old = ENV['COMPLEX_CONFIG_MONEY_DEFAULT_CURRENCY']
|
|
21
|
+
ENV.delete('COMPLEX_CONFIG_MONEY_DEFAULT_CURRENCY')
|
|
22
|
+
example.run
|
|
23
|
+
ensure
|
|
24
|
+
ENV['COMPLEX_CONFIG_MONEY_DEFAULT_CURRENCY'] = old
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
context described_class::URI do
|
|
28
|
+
it 'can return an URL string' do
|
|
29
|
+
expect(settings.foo.test_url).to eq 'http://www.ping.de'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'can return an URI' do
|
|
33
|
+
expect(settings.foo.test_uri).to eq URI.parse('http://www.ping.de')
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'can return an URI' do
|
|
37
|
+
expect(settings.foo[:test_uri]).to eq URI.parse('http://www.ping.de')
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'can skips if blub' do
|
|
41
|
+
expect { settings.foo.nix_uri }.to raise_error(ComplexConfig::AttributeMissing)
|
|
42
|
+
end
|
|
29
43
|
end
|
|
30
44
|
|
|
31
|
-
|
|
32
|
-
|
|
45
|
+
context described_class::MONEY do
|
|
46
|
+
it 'can return a Fixnum' do
|
|
47
|
+
expect(settings.foo.cash_in_cents).to eq 100_00
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'can return a Money instance' do
|
|
51
|
+
expect(settings.foo.cash).to eq 100.to_money('EUR')
|
|
52
|
+
end
|
|
33
53
|
end
|
|
34
54
|
end
|
|
35
55
|
|
|
36
|
-
context
|
|
37
|
-
|
|
38
|
-
|
|
56
|
+
context 'with BTC' do
|
|
57
|
+
let :settings do
|
|
58
|
+
ComplexConfig::Settings[
|
|
59
|
+
foo: {
|
|
60
|
+
test_url: 'http://www.ping.de',
|
|
61
|
+
cash_in_cents: 100.to_money('BTC').cents
|
|
62
|
+
}
|
|
63
|
+
]
|
|
39
64
|
end
|
|
40
65
|
|
|
66
|
+
around do |example|
|
|
67
|
+
old, ENV['COMPLEX_CONFIG_MONEY_DEFAULT_CURRENCY'] = ENV['COMPLEX_CONFIG_MONEY_DEFAULT_CURRENCY'], 'BTC'
|
|
68
|
+
example.run
|
|
69
|
+
ensure
|
|
70
|
+
ENV['COMPLEX_CONFIG_MONEY_DEFAULT_CURRENCY'] = old
|
|
71
|
+
end
|
|
41
72
|
it 'can return a Money instance' do
|
|
42
|
-
expect(settings.foo.cash).to eq 100.to_money
|
|
73
|
+
expect(settings.foo.cash).to eq 100.to_money('BTC')
|
|
43
74
|
end
|
|
44
75
|
end
|
|
45
76
|
end
|
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.
|
|
4
|
+
version: 0.25.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florian Frank
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '2.
|
|
18
|
+
version: '2.10'
|
|
19
19
|
type: :development
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '2.
|
|
25
|
+
version: '2.10'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: rake
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -269,7 +269,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
269
269
|
- !ruby/object:Gem::Version
|
|
270
270
|
version: '0'
|
|
271
271
|
requirements: []
|
|
272
|
-
rubygems_version:
|
|
272
|
+
rubygems_version: 4.0.2
|
|
273
273
|
specification_version: 4
|
|
274
274
|
summary: configuration library
|
|
275
275
|
test_files:
|