qonfig 0.29.0 → 0.30.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +48 -0
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +10 -0
- data/Gemfile +0 -3
- data/Gemfile.lock +77 -98
- data/LICENSE.txt +1 -1
- data/README.md +3 -2
- data/gemfiles/with_external_deps.gemfile +2 -0
- data/gemfiles/with_external_deps.gemfile.lock +84 -99
- data/gemfiles/without_external_deps.gemfile.lock +78 -95
- data/lib/qonfig/commands/definition/load_from_env/value_converter.rb +6 -6
- data/lib/qonfig/commands/instantiation/values_file.rb +4 -6
- data/lib/qonfig/imports/direct_key.rb +4 -4
- data/lib/qonfig/imports/mappings.rb +4 -4
- data/lib/qonfig/plugins/pretty_print/requirements.rb +1 -1
- data/lib/qonfig/plugins/toml/loaders/dynamic.rb +1 -1
- data/lib/qonfig/plugins/toml/loaders.rb +1 -1
- data/lib/qonfig/plugins.rb +2 -4
- data/lib/qonfig/settings.rb +5 -7
- data/lib/qonfig/uploaders/yaml.rb +1 -1
- data/lib/qonfig/validation/building/instance_builder/attribute_consistency.rb +2 -2
- data/lib/qonfig/version.rb +1 -1
- data/lib/qonfig.rb +1 -0
- data/qonfig.gemspec +8 -8
- data/spec/features/config_definition_and_representation_spec.rb +7 -7
- data/spec/features/freeze_state_spec.rb +10 -10
- data/spec/features/plugins/pretty_print_spec.rb +15 -15
- data/spec/features/plugins/toml/save_to_toml_spec.rb +1 -1
- data/spec/features/plugins/vault/expose_vault_spec.rb +1 -1
- data/spec/features/save_to_file/save_to_json_spec.rb +2 -4
- metadata +36 -45
- data/.github/workflows/test.yml +0 -62
- data/sig/.keep +0 -0
@@ -1,139 +1,122 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
qonfig (0.
|
4
|
+
qonfig (0.29.1)
|
5
|
+
base64 (>= 0.2)
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
8
9
|
specs:
|
9
|
-
activesupport (7.
|
10
|
+
activesupport (6.1.7.10)
|
10
11
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
11
12
|
i18n (>= 1.6, < 2)
|
12
13
|
minitest (>= 5.1)
|
13
14
|
tzinfo (~> 2.0)
|
14
|
-
|
15
|
-
|
16
|
-
rubocop
|
17
|
-
rubocop-
|
15
|
+
zeitwerk (~> 2.3)
|
16
|
+
armitage-rubocop (1.68.0.2)
|
17
|
+
rubocop (= 1.68.0)
|
18
|
+
rubocop-capybara (= 2.21.0)
|
19
|
+
rubocop-factory_bot (= 2.26.1)
|
20
|
+
rubocop-performance (= 1.23.0)
|
21
|
+
rubocop-rails (= 2.27.0)
|
18
22
|
rubocop-rake (= 0.6.0)
|
19
|
-
rubocop-rspec (= 2.
|
23
|
+
rubocop-rspec (= 3.2.0)
|
24
|
+
rubocop-rspec_rails (= 2.30.0)
|
20
25
|
ast (2.4.2)
|
21
|
-
|
22
|
-
bundler (>= 1.2.0, < 3)
|
23
|
-
thor (~> 1.0)
|
24
|
-
ci-helper (0.5.0)
|
25
|
-
colorize (~> 0.8)
|
26
|
-
dry-inflector (~> 0.2)
|
27
|
-
umbrellio-sequel-plugins (~> 0.4)
|
26
|
+
base64 (0.2.0)
|
28
27
|
coderay (1.1.3)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
dry-inflector (0.2.1)
|
34
|
-
ffi (1.15.5)
|
35
|
-
i18n (1.10.0)
|
28
|
+
concurrent-ruby (1.3.4)
|
29
|
+
diff-lcs (1.5.1)
|
30
|
+
docile (1.4.1)
|
31
|
+
i18n (1.14.6)
|
36
32
|
concurrent-ruby (~> 1.0)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
parallel (1.22.1)
|
44
|
-
parser (3.1.2.0)
|
33
|
+
json (2.9.0)
|
34
|
+
language_server-protocol (3.17.0.3)
|
35
|
+
method_source (1.1.0)
|
36
|
+
minitest (5.25.4)
|
37
|
+
parallel (1.26.3)
|
38
|
+
parser (3.3.6.0)
|
45
39
|
ast (~> 2.4.1)
|
46
|
-
|
40
|
+
racc
|
41
|
+
pry (0.15.0)
|
47
42
|
coderay (~> 1.1)
|
48
43
|
method_source (~> 1.0)
|
49
|
-
|
44
|
+
racc (1.8.1)
|
45
|
+
rack (3.1.8)
|
50
46
|
rainbow (3.1.1)
|
51
|
-
rake (13.
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
rspec-expectations (~> 3.11.0)
|
61
|
-
rspec-mocks (~> 3.11.0)
|
62
|
-
rspec-core (3.11.0)
|
63
|
-
rspec-support (~> 3.11.0)
|
64
|
-
rspec-expectations (3.11.0)
|
47
|
+
rake (13.2.1)
|
48
|
+
regexp_parser (2.9.3)
|
49
|
+
rspec (3.13.0)
|
50
|
+
rspec-core (~> 3.13.0)
|
51
|
+
rspec-expectations (~> 3.13.0)
|
52
|
+
rspec-mocks (~> 3.13.0)
|
53
|
+
rspec-core (3.13.2)
|
54
|
+
rspec-support (~> 3.13.0)
|
55
|
+
rspec-expectations (3.13.3)
|
65
56
|
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
-
rspec-support (~> 3.
|
67
|
-
rspec-mocks (3.
|
57
|
+
rspec-support (~> 3.13.0)
|
58
|
+
rspec-mocks (3.13.2)
|
68
59
|
diff-lcs (>= 1.2.0, < 2.0)
|
69
|
-
rspec-support (~> 3.
|
70
|
-
rspec-support (3.
|
71
|
-
rubocop (1.
|
60
|
+
rspec-support (~> 3.13.0)
|
61
|
+
rspec-support (3.13.2)
|
62
|
+
rubocop (1.68.0)
|
63
|
+
json (~> 2.3)
|
64
|
+
language_server-protocol (>= 3.17.0)
|
72
65
|
parallel (~> 1.10)
|
73
|
-
parser (>= 3.
|
66
|
+
parser (>= 3.3.0.2)
|
74
67
|
rainbow (>= 2.2.2, < 4.0)
|
75
|
-
regexp_parser (>=
|
76
|
-
|
77
|
-
rubocop-ast (>= 1.18.0, < 2.0)
|
68
|
+
regexp_parser (>= 2.4, < 3.0)
|
69
|
+
rubocop-ast (>= 1.32.2, < 2.0)
|
78
70
|
ruby-progressbar (~> 1.7)
|
79
|
-
unicode-display_width (>=
|
80
|
-
rubocop-ast (1.
|
81
|
-
parser (>= 3.
|
82
|
-
rubocop-
|
83
|
-
rubocop (
|
84
|
-
|
85
|
-
|
71
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
72
|
+
rubocop-ast (1.37.0)
|
73
|
+
parser (>= 3.3.1.0)
|
74
|
+
rubocop-capybara (2.21.0)
|
75
|
+
rubocop (~> 1.41)
|
76
|
+
rubocop-factory_bot (2.26.1)
|
77
|
+
rubocop (~> 1.61)
|
78
|
+
rubocop-performance (1.23.0)
|
79
|
+
rubocop (>= 1.48.1, < 2.0)
|
80
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
81
|
+
rubocop-rails (2.27.0)
|
86
82
|
activesupport (>= 4.2.0)
|
87
83
|
rack (>= 1.1)
|
88
|
-
rubocop (>= 1.
|
84
|
+
rubocop (>= 1.52.0, < 2.0)
|
85
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
89
86
|
rubocop-rake (0.6.0)
|
90
87
|
rubocop (~> 1.0)
|
91
|
-
rubocop-rspec (2.
|
92
|
-
rubocop (~> 1.
|
93
|
-
|
94
|
-
|
95
|
-
|
88
|
+
rubocop-rspec (3.2.0)
|
89
|
+
rubocop (~> 1.61)
|
90
|
+
rubocop-rspec_rails (2.30.0)
|
91
|
+
rubocop (~> 1.61)
|
92
|
+
rubocop-rspec (~> 3, >= 3.0.1)
|
93
|
+
ruby-progressbar (1.13.0)
|
94
|
+
simplecov (0.22.0)
|
96
95
|
docile (~> 1.1)
|
97
96
|
simplecov-html (~> 0.11)
|
98
97
|
simplecov_json_formatter (~> 0.1)
|
99
|
-
simplecov-html (0.
|
98
|
+
simplecov-html (0.13.1)
|
100
99
|
simplecov-lcov (0.8.0)
|
101
100
|
simplecov_json_formatter (0.1.4)
|
102
|
-
|
103
|
-
activesupport (>= 5.1)
|
104
|
-
language_server-protocol (>= 3.15, < 4.0)
|
105
|
-
listen (~> 3.0)
|
106
|
-
parallel (>= 1.0.0)
|
107
|
-
parser (>= 3.0)
|
108
|
-
rainbow (>= 2.2.2, < 4.0)
|
109
|
-
rbs (>= 2.3.2)
|
110
|
-
terminal-table (>= 2, < 4)
|
111
|
-
symbiont-ruby (0.7.0)
|
112
|
-
terminal-table (3.0.2)
|
113
|
-
unicode-display_width (>= 1.1.1, < 3)
|
114
|
-
thor (1.2.1)
|
115
|
-
tzinfo (2.0.4)
|
101
|
+
tzinfo (2.0.6)
|
116
102
|
concurrent-ruby (~> 1.0)
|
117
|
-
|
118
|
-
|
119
|
-
symbiont-ruby
|
120
|
-
unicode-display_width (2.1.0)
|
103
|
+
unicode-display_width (2.6.0)
|
104
|
+
zeitwerk (2.7.1)
|
121
105
|
|
122
106
|
PLATFORMS
|
123
|
-
arm64-darwin-
|
107
|
+
arm64-darwin-24
|
108
|
+
ruby
|
124
109
|
|
125
110
|
DEPENDENCIES
|
126
|
-
|
111
|
+
activesupport (~> 6, < 8)
|
112
|
+
armitage-rubocop (~> 1.59)
|
127
113
|
bundler (>= 1)
|
128
|
-
|
129
|
-
ci-helper (~> 0.5)
|
130
|
-
pry (~> 0.14)
|
114
|
+
pry (~> 0.15)
|
131
115
|
qonfig!
|
132
116
|
rake (>= 13)
|
133
|
-
rspec (~> 3.
|
134
|
-
simplecov (~> 0.
|
117
|
+
rspec (~> 3.2)
|
118
|
+
simplecov (~> 0.22)
|
135
119
|
simplecov-lcov (~> 0.8)
|
136
|
-
steep (~> 1.0)
|
137
120
|
|
138
121
|
BUNDLED WITH
|
139
|
-
2.
|
122
|
+
2.5.23
|
@@ -8,37 +8,37 @@ module Qonfig::Commands::Definition::LoadFromENV::ValueConverter
|
|
8
8
|
#
|
9
9
|
# @api private
|
10
10
|
# @since 0.2.0
|
11
|
-
INTEGER_PATTERN = /\A\d+\z
|
11
|
+
INTEGER_PATTERN = /\A\d+\z/
|
12
12
|
|
13
13
|
# @return [Regexp]
|
14
14
|
#
|
15
15
|
# @api private
|
16
16
|
# @since 0.2.0
|
17
|
-
FLOAT_PATTERN = /\A\d+\.\d+\z
|
17
|
+
FLOAT_PATTERN = /\A\d+\.\d+\z/
|
18
18
|
|
19
19
|
# @return [Regexp]
|
20
20
|
#
|
21
21
|
# @api private
|
22
22
|
# @since 0.2.0
|
23
|
-
TRUE_PATTERN = /\A(t|true)\z/i
|
23
|
+
TRUE_PATTERN = /\A(t|true)\z/i
|
24
24
|
|
25
25
|
# @return [Regexp]
|
26
26
|
#
|
27
27
|
# @api private
|
28
28
|
# @since 0.2.0
|
29
|
-
FALSE_PATTERN = /\A(f|false)\z/i
|
29
|
+
FALSE_PATTERN = /\A(f|false)\z/i
|
30
30
|
|
31
31
|
# @return [Regexp]
|
32
32
|
#
|
33
33
|
# @api private
|
34
34
|
# @since 0.2.0
|
35
|
-
ARRAY_PATTERN = /\A[^'"].*\s*,\s*.*[^'"]\z
|
35
|
+
ARRAY_PATTERN = /\A[^'"].*\s*,\s*.*[^'"]\z/
|
36
36
|
|
37
37
|
# @return [Regexp]
|
38
38
|
#
|
39
39
|
# @api private
|
40
40
|
# @since 0.2.0
|
41
|
-
QUOTED_STRING_PATTERN = /\A['"].*['"]\z
|
41
|
+
QUOTED_STRING_PATTERN = /\A['"].*['"]\z/
|
42
42
|
|
43
43
|
class << self
|
44
44
|
# @param env_data [Hash]
|
@@ -96,7 +96,7 @@ class Qonfig::Commands::Instantiation::ValuesFile < Qonfig::Commands::Base
|
|
96
96
|
def call(data_set, settings)
|
97
97
|
settings_values = load_settings_values
|
98
98
|
return unless settings_values
|
99
|
-
settings_values =
|
99
|
+
settings_values = settings_values[expose.to_sym] || settings_values[expose.to_s] if expose
|
100
100
|
data_set.configure(settings_values) if settings_values
|
101
101
|
end
|
102
102
|
|
@@ -156,11 +156,9 @@ class Qonfig::Commands::Instantiation::ValuesFile < Qonfig::Commands::Base
|
|
156
156
|
# @version 0.22.0
|
157
157
|
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
158
158
|
def prevent_incompatible_attributes!(file_path, format, strict, expose)
|
159
|
-
unless (
|
160
|
-
|
161
|
-
|
162
|
-
file_path == SELF_LOCATED_FILE_DEFINITION
|
163
|
-
)
|
159
|
+
unless file_path.is_a?(String) ||
|
160
|
+
file_path.is_a?(Pathname) ||
|
161
|
+
file_path == SELF_LOCATED_FILE_DEFINITION
|
164
162
|
raise Qonfig::ArgumentError, 'Incorrect file path'
|
165
163
|
end
|
166
164
|
|
@@ -43,9 +43,9 @@ class Qonfig::Imports::DirectKey < Qonfig::Imports::Abstract
|
|
43
43
|
raise(
|
44
44
|
Qonfig::UnknownSettingError,
|
45
45
|
"Setting with <#{key_matcher.scope_pattern}> key does not exist!"
|
46
|
-
) unless
|
46
|
+
) unless imported_config.keys(all_variants: true).any? do |setting_key|
|
47
47
|
key_matcher.match?(setting_key)
|
48
|
-
end || key_matcher.generic?
|
48
|
+
end || key_matcher.generic?
|
49
49
|
|
50
50
|
imported_config.keys(all_variants: true).each do |setting_key|
|
51
51
|
next unless key_matcher.match?(setting_key)
|
@@ -69,13 +69,13 @@ class Qonfig::Imports::DirectKey < Qonfig::Imports::Abstract
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
define_method("#{access_method_name}?") do
|
72
|
+
define_method(:"#{access_method_name}?") do
|
73
73
|
# NOTE: based on Qonfig::Settings#__define_option_predicate__ realization
|
74
74
|
!!imported_config[setting_key]
|
75
75
|
end
|
76
76
|
|
77
77
|
if accessor
|
78
|
-
define_method("#{access_method_name}=") do |value|
|
78
|
+
define_method(:"#{access_method_name}=") do |value|
|
79
79
|
imported_config[setting_key] = value
|
80
80
|
end
|
81
81
|
end
|
@@ -49,9 +49,9 @@ class Qonfig::Imports::Mappings < Qonfig::Imports::Abstract
|
|
49
49
|
raise(
|
50
50
|
Qonfig::UnknownSettingError,
|
51
51
|
"Setting with <#{key_matcher.scope_pattern}> key does not exist!"
|
52
|
-
) unless
|
52
|
+
) unless imported_config.keys(all_variants: true).any? do |setting_key|
|
53
53
|
key_matcher.match?(setting_key)
|
54
|
-
end || key_matcher.generic?
|
54
|
+
end || key_matcher.generic?
|
55
55
|
|
56
56
|
imported_config.keys(all_variants: true).each do |setting_key|
|
57
57
|
next unless key_matcher.match?(setting_key)
|
@@ -74,13 +74,13 @@ class Qonfig::Imports::Mappings < Qonfig::Imports::Abstract
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
define_method("#{mapped_method_name}?") do
|
77
|
+
define_method(:"#{mapped_method_name}?") do
|
78
78
|
# NOTE: based on Qonfig::Settings#__define_option_predicate__ realization
|
79
79
|
!!imported_config[setting_key]
|
80
80
|
end
|
81
81
|
|
82
82
|
if accessor
|
83
|
-
define_method("#{mapped_method_name}=") do |value|
|
83
|
+
define_method(:"#{mapped_method_name}=") do |value|
|
84
84
|
imported_config[setting_key] = value
|
85
85
|
end
|
86
86
|
end
|
data/lib/qonfig/plugins.rb
CHANGED
@@ -31,10 +31,8 @@ module Qonfig::Plugins
|
|
31
31
|
# @since 0.19.0
|
32
32
|
def loaded_plugins
|
33
33
|
thread_safe do
|
34
|
-
plugin_registry.
|
35
|
-
plugin_module.loaded?
|
36
|
-
end.map do |plugin_name, _plugin_module|
|
37
|
-
plugin_name
|
34
|
+
plugin_registry.filter_map do |plugin_name, plugin_module|
|
35
|
+
plugin_name if plugin_module.loaded?
|
38
36
|
end
|
39
37
|
end
|
40
38
|
end
|
data/lib/qonfig/settings.rb
CHANGED
@@ -14,13 +14,13 @@ class Qonfig::Settings # NOTE: Layout/ClassStructure is disabled only for CORE_M
|
|
14
14
|
#
|
15
15
|
# @api private
|
16
16
|
# @since 0.11.0
|
17
|
-
BASIC_SETTING_KEY_TRANSFORMER =
|
17
|
+
BASIC_SETTING_KEY_TRANSFORMER = proc { |value| value }.freeze
|
18
18
|
|
19
19
|
# @return [Proc]
|
20
20
|
#
|
21
21
|
# @api private
|
22
22
|
# @since 0.11.0
|
23
|
-
BASIC_SETTING_VALUE_TRANSFORMER =
|
23
|
+
BASIC_SETTING_VALUE_TRANSFORMER = proc { |value| value }.freeze
|
24
24
|
|
25
25
|
# @return [Boolean]
|
26
26
|
#
|
@@ -100,7 +100,6 @@ class Qonfig::Settings # NOTE: Layout/ClassStructure is disabled only for CORE_M
|
|
100
100
|
|
101
101
|
__prevent_core_method_intersection__(key)
|
102
102
|
|
103
|
-
# rubocop:disable Lint/DuplicateBranch
|
104
103
|
case
|
105
104
|
when with_redefinition || !__options__.key?(key)
|
106
105
|
__options__[key] = value
|
@@ -109,7 +108,6 @@ class Qonfig::Settings # NOTE: Layout/ClassStructure is disabled only for CORE_M
|
|
109
108
|
else
|
110
109
|
__options__[key] = value
|
111
110
|
end
|
112
|
-
# rubocop:enable Lint/DuplicateBranch
|
113
111
|
|
114
112
|
__define_option_reader__(key)
|
115
113
|
__define_option_writer__(key)
|
@@ -600,7 +598,7 @@ class Qonfig::Settings # NOTE: Layout/ClassStructure is disabled only for CORE_M
|
|
600
598
|
rest_keys = Array(keys[(key_parts_slice_boundary + 1)..-1])
|
601
599
|
break
|
602
600
|
rescue Qonfig::UnknownSettingError => error
|
603
|
-
key_parts_boundary == key_parts_slice_boundary ? raise(error) : next
|
601
|
+
(key_parts_boundary == key_parts_slice_boundary) ? raise(error) : next
|
604
602
|
end
|
605
603
|
end
|
606
604
|
|
@@ -771,7 +769,7 @@ class Qonfig::Settings # NOTE: Layout/ClassStructure is disabled only for CORE_M
|
|
771
769
|
# @api private
|
772
770
|
# @since 0.13.0
|
773
771
|
def __define_option_writer__(key)
|
774
|
-
define_singleton_method("#{key}=") do |value|
|
772
|
+
define_singleton_method(:"#{key}=") do |value|
|
775
773
|
self.[]=(key, value)
|
776
774
|
end
|
777
775
|
end
|
@@ -782,7 +780,7 @@ class Qonfig::Settings # NOTE: Layout/ClassStructure is disabled only for CORE_M
|
|
782
780
|
# @api private
|
783
781
|
# @since 0.13.0
|
784
782
|
def __define_option_predicate__(key)
|
785
|
-
define_singleton_method("#{key}?") do
|
783
|
+
define_singleton_method(:"#{key}?") do
|
786
784
|
!!self.[](key)
|
787
785
|
end
|
788
786
|
end
|
@@ -114,8 +114,8 @@ class Qonfig::Validation::Building::InstanceBuilder::AttributesConsistency
|
|
114
114
|
)
|
115
115
|
end
|
116
116
|
|
117
|
-
if (
|
118
|
-
(predefined_validator && (runtime_validation_method || validation_logic))
|
117
|
+
if (runtime_validation_method && validation_logic) ||
|
118
|
+
(predefined_validator && (runtime_validation_method || validation_logic))
|
119
119
|
raise(
|
120
120
|
Qonfig::ValidatorArgumentError,
|
121
121
|
'Incosistent validation (you should use: dataset method OR proc OR predefined validator)'
|
data/lib/qonfig/version.rb
CHANGED
data/lib/qonfig.rb
CHANGED
data/qonfig.gemspec
CHANGED
@@ -6,7 +6,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
6
6
|
require 'qonfig/version'
|
7
7
|
|
8
8
|
Gem::Specification.new do |spec|
|
9
|
-
spec.required_ruby_version = '>=
|
9
|
+
spec.required_ruby_version = '>= 3.1'
|
10
10
|
|
11
11
|
spec.name = 'qonfig'
|
12
12
|
spec.version = Qonfig::VERSION
|
@@ -27,14 +27,14 @@ Gem::Specification.new do |spec|
|
|
27
27
|
|
28
28
|
spec.files = `git ls-files -z`.split("\x0")
|
29
29
|
|
30
|
-
spec.
|
31
|
-
|
32
|
-
spec.add_development_dependency '
|
33
|
-
spec.add_development_dependency '
|
30
|
+
spec.add_dependency 'base64', '>= 0.2'
|
31
|
+
|
32
|
+
spec.add_development_dependency 'simplecov', '~> 0.22'
|
33
|
+
spec.add_development_dependency 'rspec', '~> 3.2'
|
34
|
+
spec.add_development_dependency 'armitage-rubocop', '~> 1.59'
|
35
|
+
spec.add_development_dependency 'activesupport', '~> 6', '< 8'
|
34
36
|
spec.add_development_dependency 'bundler', '>= 1'
|
35
|
-
spec.add_development_dependency '
|
36
|
-
spec.add_development_dependency 'ci-helper', '~> 0.5'
|
37
|
-
spec.add_development_dependency 'pry', '~> 0.14'
|
37
|
+
spec.add_development_dependency 'pry', '~> 0.15'
|
38
38
|
spec.add_development_dependency 'rake', '>= 13'
|
39
39
|
spec.add_development_dependency 'simplecov-lcov', '~> 0.8'
|
40
40
|
end
|
@@ -76,7 +76,7 @@ describe 'Config definition and representation' do
|
|
76
76
|
)
|
77
77
|
|
78
78
|
# hash representation (with key transformation)
|
79
|
-
expect(config.to_h(key_transformer: proc
|
79
|
+
expect(config.to_h(key_transformer: proc(&:to_sym))).to match(
|
80
80
|
serializers: {
|
81
81
|
json: :native,
|
82
82
|
xml: :native
|
@@ -94,7 +94,7 @@ describe 'Config definition and representation' do
|
|
94
94
|
)
|
95
95
|
|
96
96
|
# hash representation (with value transformation)
|
97
|
-
expect(config.to_h(value_transformer: proc
|
97
|
+
expect(config.to_h(value_transformer: proc(&:to_s))).to match(
|
98
98
|
'serializers' => {
|
99
99
|
'json' => 'native',
|
100
100
|
'xml' => 'native'
|
@@ -114,8 +114,8 @@ describe 'Config definition and representation' do
|
|
114
114
|
# hash representation (with key and value transformations)
|
115
115
|
expect(
|
116
116
|
config.to_h(
|
117
|
-
key_transformer: proc
|
118
|
-
value_transformer: proc
|
117
|
+
key_transformer: proc(&:to_sym),
|
118
|
+
value_transformer: proc(&:to_s)
|
119
119
|
)
|
120
120
|
).to match(
|
121
121
|
serializers: {
|
@@ -381,7 +381,7 @@ describe 'Config definition and representation' do
|
|
381
381
|
end.to raise_error(Qonfig::AmbiguousSettingValueError)
|
382
382
|
|
383
383
|
# attempt to use non-hash object
|
384
|
-
[1, 1.0, Object.new, true, false, Class.new, Module.new,
|
384
|
+
[1, 1.0, Object.new, true, false, Class.new, Module.new, proc {}, -> {}].each do |non_hash|
|
385
385
|
expect do
|
386
386
|
# without proc
|
387
387
|
HashConfigurableConfig.new(non_hash)
|
@@ -435,7 +435,7 @@ describe 'Config definition and representation' do
|
|
435
435
|
end
|
436
436
|
|
437
437
|
specify 'only string and symbol keys are supported' do
|
438
|
-
[1, 1.0, Object.new, true, false, Class.new, Module.new,
|
438
|
+
[1, 1.0, Object.new, true, false, Class.new, Module.new, proc {}, -> {}].each do |key|
|
439
439
|
expect do
|
440
440
|
Class.new(Qonfig::DataSet) { setting(key) }
|
441
441
|
end.to raise_error(Qonfig::ArgumentError)
|
@@ -477,7 +477,7 @@ describe 'Config definition and representation' do
|
|
477
477
|
end
|
478
478
|
|
479
479
|
specify 'fails when tries to use a non-string/non-symbol value as a setting key' do
|
480
|
-
incorrect_key_values = [123, Object.new, 15.1,
|
480
|
+
incorrect_key_values = [123, Object.new, 15.1, proc {}, Class.new, true, false]
|
481
481
|
correct_key_values = ['test', :test]
|
482
482
|
|
483
483
|
incorrect_key_values.each do |incorrect_key|
|
@@ -36,13 +36,13 @@ describe 'Freeze state' do
|
|
36
36
|
expect { conf.additionals = true }.to raise_error(Qonfig::FrozenSettingsError)
|
37
37
|
|
38
38
|
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.5.0')
|
39
|
-
expect { conf.api_mode_enabled = false }.to raise_error(
|
40
|
-
expect { conf.api.format = :xml }.to raise_error(
|
41
|
-
expect { conf.additionals = true }.to raise_error(
|
39
|
+
expect { conf.api_mode_enabled = false }.to raise_error(FrozenError)
|
40
|
+
expect { conf.api.format = :xml }.to raise_error(FrozenError)
|
41
|
+
expect { conf.additionals = true }.to raise_error(FrozenError)
|
42
42
|
else
|
43
|
-
expect { conf.api_mode_enabled = false }.to raise_error(
|
44
|
-
expect { conf.api.format = :xml }.to raise_error(
|
45
|
-
expect { conf.additionals = true }.to raise_error(
|
43
|
+
expect { conf.api_mode_enabled = false }.to raise_error(RuntimeError)
|
44
|
+
expect { conf.api.format = :xml }.to raise_error(RuntimeError)
|
45
|
+
expect { conf.additionals = true }.to raise_error(RuntimeError)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -55,11 +55,11 @@ describe 'Freeze state' do
|
|
55
55
|
expect { frozen_config.clear! }.to raise_error(Qonfig::FrozenSettingsError)
|
56
56
|
|
57
57
|
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.5.0')
|
58
|
-
expect { frozen_config.reload! }.to raise_error(
|
59
|
-
expect { frozen_config.clear! }.to raise_error(
|
58
|
+
expect { frozen_config.reload! }.to raise_error(FrozenError)
|
59
|
+
expect { frozen_config.clear! }.to raise_error(FrozenError)
|
60
60
|
else
|
61
|
-
expect { frozen_config.reload! }.to raise_error(
|
62
|
-
expect { frozen_config.clear! }.to raise_error(
|
61
|
+
expect { frozen_config.reload! }.to raise_error(RuntimeError)
|
62
|
+
expect { frozen_config.clear! }.to raise_error(RuntimeError)
|
63
63
|
end
|
64
64
|
|
65
65
|
expect(frozen_config.to_h).to match(
|
@@ -35,13 +35,13 @@ describe 'Plugins(:pretty_print): Pretty print :)', plugin: :pretty_print do
|
|
35
35
|
)
|
36
36
|
|
37
37
|
expect(pretty_printer_output.string).to include(
|
38
|
-
" api.domain: \"google\",\n" \
|
39
|
-
"
|
40
|
-
"
|
41
|
-
"
|
42
|
-
"
|
43
|
-
"
|
44
|
-
"
|
38
|
+
" api.domain: \"google\",\n " \
|
39
|
+
"api.creds.token: \"a0sdj10k@\",\n " \
|
40
|
+
"api.creds.login: \"D2\",\n " \
|
41
|
+
"database.adapter: \"pg\",\n " \
|
42
|
+
"database.logging.queries: nil,\n " \
|
43
|
+
"logging: false,\n " \
|
44
|
+
"author: nil>\n"
|
45
45
|
)
|
46
46
|
end
|
47
47
|
else
|
@@ -50,14 +50,14 @@ describe 'Plugins(:pretty_print): Pretty print :)', plugin: :pretty_print do
|
|
50
50
|
value_space = SpecSupport.from_object_id_space_to_value_space(config)
|
51
51
|
|
52
52
|
expect(pretty_printer_output.string).to eq(
|
53
|
-
"#<#{expected_config_klass_name}:0x#{value_space}\n" \
|
54
|
-
"
|
55
|
-
"
|
56
|
-
"
|
57
|
-
"
|
58
|
-
"
|
59
|
-
"
|
60
|
-
"
|
53
|
+
"#<#{expected_config_klass_name}:0x#{value_space}\n " \
|
54
|
+
"api.domain: \"google\",\n " \
|
55
|
+
"api.creds.token: \"a0sdj10k@\",\n " \
|
56
|
+
"api.creds.login: \"D2\",\n " \
|
57
|
+
"database.adapter: \"pg\",\n " \
|
58
|
+
"database.logging.queries: nil,\n " \
|
59
|
+
"logging: false,\n " \
|
60
|
+
"author: nil>\n"
|
61
61
|
)
|
62
62
|
end
|
63
63
|
end
|
@@ -142,7 +142,7 @@ describe 'Plugins(toml): Save to .toml (TOML)', plugin: :toml do
|
|
142
142
|
end
|
143
143
|
|
144
144
|
specify 'fails with parser error' do
|
145
|
-
expect { config.save_to_toml(path: config_file_path) }.to raise_error(
|
145
|
+
expect { config.save_to_toml(path: config_file_path) }.to raise_error(TomlRB::ParseError)
|
146
146
|
end
|
147
147
|
end
|
148
148
|
end
|