qonfig 0.22.0 → 0.26.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -2
  3. data/.rubocop.yml +19 -1
  4. data/.travis.yml +28 -20
  5. data/CHANGELOG.md +57 -1
  6. data/Gemfile.lock +102 -0
  7. data/LICENSE.txt +1 -1
  8. data/README.md +125 -9
  9. data/Rakefile +0 -1
  10. data/bin/rspec +1 -0
  11. data/gemfiles/with_external_deps.gemfile +2 -0
  12. data/gemfiles/with_external_deps.gemfile.lock +112 -0
  13. data/gemfiles/without_external_deps.gemfile.lock +102 -0
  14. data/lib/qonfig.rb +4 -1
  15. data/lib/qonfig/commands/definition/load_from_env.rb +2 -0
  16. data/lib/qonfig/commands/definition/load_from_env/value_converter.rb +2 -0
  17. data/lib/qonfig/data_set.rb +5 -2
  18. data/lib/qonfig/dsl.rb +2 -2
  19. data/lib/qonfig/imports/direct_key.rb +8 -2
  20. data/lib/qonfig/imports/mappings.rb +8 -2
  21. data/lib/qonfig/loaders/basic.rb +2 -0
  22. data/lib/qonfig/loaders/json.rb +2 -1
  23. data/lib/qonfig/plugins.rb +1 -0
  24. data/lib/qonfig/plugins/pretty_print.rb +8 -1
  25. data/lib/qonfig/plugins/pretty_print/requirements.rb +3 -0
  26. data/lib/qonfig/plugins/pretty_print/ruby_2_7_basic_object_pp_patch.rb +44 -0
  27. data/lib/qonfig/plugins/toml/commands/definition/expose_toml.rb +4 -4
  28. data/lib/qonfig/plugins/toml/commands/definition/load_from_toml.rb +1 -1
  29. data/lib/qonfig/plugins/toml/data_set.rb +2 -2
  30. data/lib/qonfig/plugins/toml/dsl.rb +2 -2
  31. data/lib/qonfig/plugins/vault.rb +24 -0
  32. data/lib/qonfig/plugins/vault/commands/definition/expose_vault.rb +142 -0
  33. data/lib/qonfig/plugins/vault/commands/definition/load_from_vault.rb +53 -0
  34. data/lib/qonfig/plugins/vault/dsl.rb +35 -0
  35. data/lib/qonfig/plugins/vault/errors.rb +9 -0
  36. data/lib/qonfig/plugins/vault/loaders/vault.rb +73 -0
  37. data/lib/qonfig/settings.rb +83 -22
  38. data/lib/qonfig/settings/key_matcher.rb +3 -1
  39. data/lib/qonfig/uploaders/base.rb +2 -0
  40. data/lib/qonfig/uploaders/file.rb +2 -2
  41. data/lib/qonfig/uploaders/yaml.rb +3 -1
  42. data/lib/qonfig/version.rb +1 -1
  43. data/qonfig.gemspec +6 -9
  44. data/sig/.keep +0 -0
  45. data/spec/features/clear_options_spec.rb +92 -0
  46. data/spec/features/compacted_config_spec.rb +308 -0
  47. data/spec/features/composition_spec.rb +207 -0
  48. data/spec/features/config_definition_and_representation_spec.rb +535 -0
  49. data/spec/features/definition_order_spec.rb +69 -0
  50. data/spec/features/dig_functionality_spec.rb +47 -0
  51. data/spec/features/dot_notation_spec.rb +159 -0
  52. data/spec/features/export_settings_spec.rb +138 -0
  53. data/spec/features/expose_json_spec.rb +281 -0
  54. data/spec/features/expose_self/format_option_dynamic_spec.rb +69 -0
  55. data/spec/features/expose_self/format_option_json_spec.rb +74 -0
  56. data/spec/features/expose_self/format_option_unsupported_spec.rb +27 -0
  57. data/spec/features/expose_self/format_option_yaml_spec.rb +77 -0
  58. data/spec/features/expose_self_spec.rb +97 -0
  59. data/spec/features/expose_yaml_spec.rb +263 -0
  60. data/spec/features/freeze_state_spec.rb +122 -0
  61. data/spec/features/get_config_keys_spec.rb +62 -0
  62. data/spec/features/get_config_values_spec.rb +41 -0
  63. data/spec/features/has_a_key_spec.rb +48 -0
  64. data/spec/features/import_settings_spec.rb +323 -0
  65. data/spec/features/indifferent_access_spec.rb +57 -0
  66. data/spec/features/inheritance_spec.rb +110 -0
  67. data/spec/features/instantiation_without_class_definition_spec.rb +59 -0
  68. data/spec/features/iteration_over_setting_keys_spec.rb +48 -0
  69. data/spec/features/load_from_env_spec.rb +240 -0
  70. data/spec/features/load_from_json_spec.rb +97 -0
  71. data/spec/features/load_from_self/format_option_json_spec.rb +31 -0
  72. data/spec/features/load_from_self/format_option_unsupported_spec.rb +27 -0
  73. data/spec/features/load_from_self/format_option_yaml_spec.rb +49 -0
  74. data/spec/features/load_from_self/with_erb_instructions_spec.rb +33 -0
  75. data/spec/features/load_from_self/with_hash_like_data_representation_spec.rb +66 -0
  76. data/spec/features/load_from_self/with_non_hash_like_data_representation_spec.rb +19 -0
  77. data/spec/features/load_from_self/without_end_data_spec.rb +11 -0
  78. data/spec/features/load_from_yaml_spec.rb +110 -0
  79. data/spec/features/load_setting_values_from_file/by_instance_method_examples.rb +171 -0
  80. data/spec/features/load_setting_values_from_file/by_macros_examples.rb +165 -0
  81. data/spec/features/load_setting_values_from_file/load_from_json_spec.rb +21 -0
  82. data/spec/features/load_setting_values_from_file/load_from_self/json_format/end_data_with_env_spec.rb +100 -0
  83. data/spec/features/load_setting_values_from_file/load_from_self/json_format/with_end_data_spec.rb +129 -0
  84. data/spec/features/load_setting_values_from_file/load_from_self/json_format/with_incorrect_end_data_spec.rb +34 -0
  85. data/spec/features/load_setting_values_from_file/load_from_self/json_format/without_end_data_spec.rb +65 -0
  86. data/spec/features/load_setting_values_from_file/load_from_self/yaml_format/end_data_with_env_spec.rb +94 -0
  87. data/spec/features/load_setting_values_from_file/load_from_self/yaml_format/with_end_data_spec.rb +126 -0
  88. data/spec/features/load_setting_values_from_file/load_from_self/yaml_format/with_incorrect_end_data_spec.rb +32 -0
  89. data/spec/features/load_setting_values_from_file/load_from_self/yaml_format/without_end_data_spec.rb +65 -0
  90. data/spec/features/load_setting_values_from_file/load_from_yaml_spec.rb +21 -0
  91. data/spec/features/load_setting_values_from_file/shared_behavior_spec.rb +33 -0
  92. data/spec/features/mixin_spec.rb +387 -0
  93. data/spec/features/non_redefineable_core_methods_spec.rb +29 -0
  94. data/spec/features/plugins/pretty_print_spec.rb +86 -0
  95. data/spec/features/plugins/toml/expose_self/format_option_toml_spec.rb +71 -0
  96. data/spec/features/plugins/toml/expose_toml_spec.rb +221 -0
  97. data/spec/features/plugins/toml/load_from_self/format_option_toml_spec.rb +27 -0
  98. data/spec/features/plugins/toml/load_from_toml_spec.rb +109 -0
  99. data/spec/features/plugins/toml/load_setting_values_from_file/load_from_toml_spec.rb +27 -0
  100. data/spec/features/plugins/toml/load_setting_values_from_file/load_toml_from_self/end_data_with_env_spec.rb +95 -0
  101. data/spec/features/plugins/toml/load_setting_values_from_file/load_toml_from_self/with_end_data_spec.rb +125 -0
  102. data/spec/features/plugins/toml/load_setting_values_from_file/load_toml_from_self/with_incorrect_end_data_spec.rb +34 -0
  103. data/spec/features/plugins/toml/load_setting_values_from_file/load_toml_from_self/without_end_data_spec.rb +65 -0
  104. data/spec/features/plugins/toml/load_setting_values_from_file/shared_behavior_spec.rb +34 -0
  105. data/spec/features/plugins/toml/save_to_toml_spec.rb +149 -0
  106. data/spec/features/plugins/vault/expose_vault_spec.rb +117 -0
  107. data/spec/features/plugins/vault/load_from_vault_spec.rb +80 -0
  108. data/spec/features/plugins_spec.rb +89 -0
  109. data/spec/features/reload_spec.rb +75 -0
  110. data/spec/features/run_code_with_temporary_settings_spec.rb +104 -0
  111. data/spec/features/save_to_file/save_to_json_spec.rb +157 -0
  112. data/spec/features/save_to_file/save_to_yaml_spec.rb +189 -0
  113. data/spec/features/settings_as_predicates_spec.rb +47 -0
  114. data/spec/features/settings_redefinition_spec.rb +30 -0
  115. data/spec/features/slice_functionality_spec.rb +69 -0
  116. data/spec/features/subset_functionality_spec.rb +49 -0
  117. data/spec/features/validation_spec.rb +916 -0
  118. data/spec/fixtures/array_settings.yml +3 -0
  119. data/spec/fixtures/expose_json/incompatible_root_structure.json +6 -0
  120. data/spec/fixtures/expose_json/incompatible_structure.json +4 -0
  121. data/spec/fixtures/expose_json/project.development.json +7 -0
  122. data/spec/fixtures/expose_json/project.json +30 -0
  123. data/spec/fixtures/expose_json/project.production.json +7 -0
  124. data/spec/fixtures/expose_json/project.staging.json +7 -0
  125. data/spec/fixtures/expose_json/project.test.json +7 -0
  126. data/spec/fixtures/expose_yaml/incompatible_structure.yml +2 -0
  127. data/spec/fixtures/expose_yaml/project.development.yml +4 -0
  128. data/spec/fixtures/expose_yaml/project.production.yml +4 -0
  129. data/spec/fixtures/expose_yaml/project.staging.yml +4 -0
  130. data/spec/fixtures/expose_yaml/project.test.yml +4 -0
  131. data/spec/fixtures/expose_yaml/project.yml +25 -0
  132. data/spec/fixtures/json_array_sample.json +14 -0
  133. data/spec/fixtures/json_object_sample.json +9 -0
  134. data/spec/fixtures/json_with_empty_object.json +6 -0
  135. data/spec/fixtures/json_with_erb.json +6 -0
  136. data/spec/fixtures/plugins/toml/expose_toml/project.development.toml +4 -0
  137. data/spec/fixtures/plugins/toml/expose_toml/project.production.toml +4 -0
  138. data/spec/fixtures/plugins/toml/expose_toml/project.staging.toml +4 -0
  139. data/spec/fixtures/plugins/toml/expose_toml/project.test.toml +4 -0
  140. data/spec/fixtures/plugins/toml/expose_toml/project.toml +27 -0
  141. data/spec/fixtures/plugins/toml/mini_file.toml +6 -0
  142. data/spec/fixtures/plugins/toml/toml_sample_with_all_types.toml +72 -0
  143. data/spec/fixtures/plugins/toml/values_file/with_env.toml +13 -0
  144. data/spec/fixtures/plugins/toml/values_file/without_env.toml +6 -0
  145. data/spec/fixtures/rubocop_settings.yml +12 -0
  146. data/spec/fixtures/shared_settings_with_aliases.yml +10 -0
  147. data/spec/fixtures/travis_settings.yml +6 -0
  148. data/spec/fixtures/values_file/with_env.json +19 -0
  149. data/spec/fixtures/values_file/with_env.yml +17 -0
  150. data/spec/fixtures/values_file/without_env.json +8 -0
  151. data/spec/fixtures/values_file/without_env.yml +5 -0
  152. data/spec/fixtures/with_empty_hash.yml +4 -0
  153. data/spec/fixtures/with_erb_instructions.yml +3 -0
  154. data/spec/spec_helper.rb +27 -0
  155. data/spec/support/meta_scopes.rb +20 -0
  156. data/spec/support/spec_support.rb +42 -0
  157. metadata +140 -30
data/Rakefile CHANGED
@@ -4,7 +4,6 @@ require 'bundler/gem_tasks'
4
4
  require 'rspec/core/rake_task'
5
5
  require 'rubocop'
6
6
  require 'rubocop/rake_task'
7
- require 'rubocop-rails'
8
7
  require 'rubocop-performance'
9
8
  require 'rubocop-rspec'
10
9
  require 'rubocop-rake'
data/bin/rspec CHANGED
@@ -36,6 +36,7 @@ module QonfigSpecRunner
36
36
 
37
37
  def run_with_specs_for_plugins!
38
38
  ENV['TEST_PLUGINS'] = 'true'
39
+ ENV['FULL_TEST_COVERAGE_CHECK'] = 'true'
39
40
  ENV['BUNDLE_GEMFILE'] = GEMFILES[:with_external_deps]
40
41
  run_tests!
41
42
  end
@@ -4,5 +4,7 @@ source 'https://rubygems.org'
4
4
 
5
5
  # @since 0.17.0 (qonfig: :toml plugin)
6
6
  gem 'toml-rb', '>= 2'
7
+ # @since 0.25.0 (qonfig: :vault plugin)
8
+ gem 'vault', '>= 0.1'
7
9
 
8
10
  gemspec path: '..'
@@ -0,0 +1,112 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ qonfig (0.25.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (6.1.0)
10
+ concurrent-ruby (~> 1.0, >= 1.0.2)
11
+ i18n (>= 1.6, < 2)
12
+ minitest (>= 5.1)
13
+ tzinfo (~> 2.0)
14
+ zeitwerk (~> 2.3)
15
+ armitage-rubocop (1.7.0.1)
16
+ rubocop (= 1.7.0)
17
+ rubocop-performance (= 1.9.1)
18
+ rubocop-rails (= 2.9.1)
19
+ rubocop-rake (= 0.5.1)
20
+ rubocop-rspec (= 2.1.0)
21
+ ast (2.4.1)
22
+ aws-eventstream (1.1.0)
23
+ aws-sigv4 (1.2.2)
24
+ aws-eventstream (~> 1, >= 1.0.2)
25
+ citrus (3.0.2)
26
+ coderay (1.1.3)
27
+ concurrent-ruby (1.1.7)
28
+ diff-lcs (1.4.4)
29
+ docile (1.3.4)
30
+ i18n (1.8.5)
31
+ concurrent-ruby (~> 1.0)
32
+ method_source (1.0.0)
33
+ minitest (5.14.2)
34
+ parallel (1.20.1)
35
+ parser (3.0.0.0)
36
+ ast (~> 2.4.1)
37
+ pry (0.13.1)
38
+ coderay (~> 1.1)
39
+ method_source (~> 1.0)
40
+ rack (2.2.3)
41
+ rainbow (3.0.0)
42
+ rake (13.0.3)
43
+ regexp_parser (2.0.2)
44
+ rexml (3.2.4)
45
+ rspec (3.10.0)
46
+ rspec-core (~> 3.10.0)
47
+ rspec-expectations (~> 3.10.0)
48
+ rspec-mocks (~> 3.10.0)
49
+ rspec-core (3.10.0)
50
+ rspec-support (~> 3.10.0)
51
+ rspec-expectations (3.10.0)
52
+ diff-lcs (>= 1.2.0, < 2.0)
53
+ rspec-support (~> 3.10.0)
54
+ rspec-mocks (3.10.0)
55
+ diff-lcs (>= 1.2.0, < 2.0)
56
+ rspec-support (~> 3.10.0)
57
+ rspec-support (3.10.0)
58
+ rubocop (1.7.0)
59
+ parallel (~> 1.10)
60
+ parser (>= 2.7.1.5)
61
+ rainbow (>= 2.2.2, < 4.0)
62
+ regexp_parser (>= 1.8, < 3.0)
63
+ rexml
64
+ rubocop-ast (>= 1.2.0, < 2.0)
65
+ ruby-progressbar (~> 1.7)
66
+ unicode-display_width (>= 1.4.0, < 2.0)
67
+ rubocop-ast (1.3.0)
68
+ parser (>= 2.7.1.5)
69
+ rubocop-performance (1.9.1)
70
+ rubocop (>= 0.90.0, < 2.0)
71
+ rubocop-ast (>= 0.4.0)
72
+ rubocop-rails (2.9.1)
73
+ activesupport (>= 4.2.0)
74
+ rack (>= 1.1)
75
+ rubocop (>= 0.90.0, < 2.0)
76
+ rubocop-rake (0.5.1)
77
+ rubocop
78
+ rubocop-rspec (2.1.0)
79
+ rubocop (~> 1.0)
80
+ rubocop-ast (>= 1.1.0)
81
+ ruby-progressbar (1.10.1)
82
+ simplecov (0.20.0)
83
+ docile (~> 1.1)
84
+ simplecov-html (~> 0.11)
85
+ simplecov_json_formatter (~> 0.1)
86
+ simplecov-html (0.12.3)
87
+ simplecov_json_formatter (0.1.2)
88
+ toml-rb (2.0.1)
89
+ citrus (~> 3.0, > 3.0)
90
+ tzinfo (2.0.4)
91
+ concurrent-ruby (~> 1.0)
92
+ unicode-display_width (1.7.0)
93
+ vault (0.15.0)
94
+ aws-sigv4
95
+ zeitwerk (2.4.2)
96
+
97
+ PLATFORMS
98
+ x86_64-darwin-19
99
+
100
+ DEPENDENCIES
101
+ armitage-rubocop (~> 1.7)
102
+ bundler
103
+ pry
104
+ qonfig!
105
+ rake (>= 13)
106
+ rspec (~> 3.10)
107
+ simplecov (~> 0.20)
108
+ toml-rb (>= 2)
109
+ vault (>= 0.1)
110
+
111
+ BUNDLED WITH
112
+ 2.2.3
@@ -0,0 +1,102 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ qonfig (0.25.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (6.1.0)
10
+ concurrent-ruby (~> 1.0, >= 1.0.2)
11
+ i18n (>= 1.6, < 2)
12
+ minitest (>= 5.1)
13
+ tzinfo (~> 2.0)
14
+ zeitwerk (~> 2.3)
15
+ armitage-rubocop (1.7.0.1)
16
+ rubocop (= 1.7.0)
17
+ rubocop-performance (= 1.9.1)
18
+ rubocop-rails (= 2.9.1)
19
+ rubocop-rake (= 0.5.1)
20
+ rubocop-rspec (= 2.1.0)
21
+ ast (2.4.1)
22
+ coderay (1.1.3)
23
+ concurrent-ruby (1.1.7)
24
+ diff-lcs (1.4.4)
25
+ docile (1.3.4)
26
+ i18n (1.8.5)
27
+ concurrent-ruby (~> 1.0)
28
+ method_source (1.0.0)
29
+ minitest (5.14.2)
30
+ parallel (1.20.1)
31
+ parser (3.0.0.0)
32
+ ast (~> 2.4.1)
33
+ pry (0.13.1)
34
+ coderay (~> 1.1)
35
+ method_source (~> 1.0)
36
+ rack (2.2.3)
37
+ rainbow (3.0.0)
38
+ rake (13.0.3)
39
+ regexp_parser (2.0.2)
40
+ rexml (3.2.4)
41
+ rspec (3.10.0)
42
+ rspec-core (~> 3.10.0)
43
+ rspec-expectations (~> 3.10.0)
44
+ rspec-mocks (~> 3.10.0)
45
+ rspec-core (3.10.0)
46
+ rspec-support (~> 3.10.0)
47
+ rspec-expectations (3.10.0)
48
+ diff-lcs (>= 1.2.0, < 2.0)
49
+ rspec-support (~> 3.10.0)
50
+ rspec-mocks (3.10.0)
51
+ diff-lcs (>= 1.2.0, < 2.0)
52
+ rspec-support (~> 3.10.0)
53
+ rspec-support (3.10.0)
54
+ rubocop (1.7.0)
55
+ parallel (~> 1.10)
56
+ parser (>= 2.7.1.5)
57
+ rainbow (>= 2.2.2, < 4.0)
58
+ regexp_parser (>= 1.8, < 3.0)
59
+ rexml
60
+ rubocop-ast (>= 1.2.0, < 2.0)
61
+ ruby-progressbar (~> 1.7)
62
+ unicode-display_width (>= 1.4.0, < 2.0)
63
+ rubocop-ast (1.3.0)
64
+ parser (>= 2.7.1.5)
65
+ rubocop-performance (1.9.1)
66
+ rubocop (>= 0.90.0, < 2.0)
67
+ rubocop-ast (>= 0.4.0)
68
+ rubocop-rails (2.9.1)
69
+ activesupport (>= 4.2.0)
70
+ rack (>= 1.1)
71
+ rubocop (>= 0.90.0, < 2.0)
72
+ rubocop-rake (0.5.1)
73
+ rubocop
74
+ rubocop-rspec (2.1.0)
75
+ rubocop (~> 1.0)
76
+ rubocop-ast (>= 1.1.0)
77
+ ruby-progressbar (1.10.1)
78
+ simplecov (0.20.0)
79
+ docile (~> 1.1)
80
+ simplecov-html (~> 0.11)
81
+ simplecov_json_formatter (~> 0.1)
82
+ simplecov-html (0.12.3)
83
+ simplecov_json_formatter (0.1.2)
84
+ tzinfo (2.0.4)
85
+ concurrent-ruby (~> 1.0)
86
+ unicode-display_width (1.7.0)
87
+ zeitwerk (2.4.2)
88
+
89
+ PLATFORMS
90
+ x86_64-darwin-19
91
+
92
+ DEPENDENCIES
93
+ armitage-rubocop (~> 1.7)
94
+ bundler
95
+ pry
96
+ qonfig!
97
+ rake (>= 13)
98
+ rspec (~> 3.10)
99
+ simplecov (~> 0.20)
100
+
101
+ BUNDLED WITH
102
+ 2.2.3
data/lib/qonfig.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'set'
3
4
  require 'yaml'
4
5
  require 'json'
5
6
  require 'erb'
@@ -57,10 +58,12 @@ module Qonfig
57
58
  # @since 0.20.0
58
59
  define_validator(:module) { |value| value.is_a?(Module) }
59
60
  # @since 0.20.0
60
- define_validator(:not_nil) { |value| !value.nil? }
61
+ define_validator(:not_nil) { |value| value == nil }
61
62
 
62
63
  # @since 0.12.0
63
64
  register_plugin('toml', Qonfig::Plugins::TOML)
64
65
  # @since 0.19.0
65
66
  register_plugin('pretty_print', Qonfig::Plugins::PrettyPrint)
67
+ # @since 0.25.0
68
+ register_plugin('vault', Qonfig::Plugins::Vault)
66
69
  end
@@ -55,6 +55,8 @@ class Qonfig::Commands::Definition::LoadFromENV < Qonfig::Commands::Base
55
55
  @convert_values = convert_values
56
56
  @prefix_pattern = prefix.is_a?(Regexp) ? prefix : /\A#{Regexp.escape(prefix.to_s)}.*\z/m
57
57
  @trim_prefix = trim_prefix
58
+
59
+ # TODO: mb trim_prefix ?
58
60
  @trim_pattern = prefix.is_a?(Regexp) ? prefix : /\A(#{Regexp.escape(prefix.to_s)})/m
59
61
  end
60
62
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  # @api private
4
4
  # @since 0.2.0
5
+ # rubocop:disable Style/RedundantFreeze, Performance/MethodObjectAsBlock
5
6
  module Qonfig::Commands::Definition::LoadFromENV::ValueConverter
6
7
  # @return [Regexp]
7
8
  #
@@ -80,3 +81,4 @@ module Qonfig::Commands::Definition::LoadFromENV::ValueConverter
80
81
  end
81
82
  end
82
83
  end
84
+ # rubocop:enable Style/RedundantFreeze, Performance/MethodObjectAsBlock
@@ -184,6 +184,7 @@ class Qonfig::DataSet # rubocop:disable Metrics/ClassLength
184
184
  end
185
185
  end
186
186
 
187
+ # @option dot_style [Boolean]
187
188
  # @option key_transformer [Proc]
188
189
  # @option value_transformer [Proc]
189
190
  # @return [Hash]
@@ -191,11 +192,13 @@ class Qonfig::DataSet # rubocop:disable Metrics/ClassLength
191
192
  # @api public
192
193
  # @since 0.1.0
193
194
  def to_h(
195
+ dot_style: Qonfig::Settings::REPRESENT_HASH_IN_DOT_STYLE,
194
196
  key_transformer: Qonfig::Settings::BASIC_SETTING_KEY_TRANSFORMER,
195
197
  value_transformer: Qonfig::Settings::BASIC_SETTING_VALUE_TRANSFORMER
196
198
  )
197
199
  thread_safe_access do
198
200
  settings.__to_hash__(
201
+ dot_notation: dot_style,
199
202
  transform_key: key_transformer,
200
203
  transform_value: value_transformer
201
204
  )
@@ -203,7 +206,7 @@ class Qonfig::DataSet # rubocop:disable Metrics/ClassLength
203
206
  end
204
207
  alias_method :to_hash, :to_h
205
208
 
206
- # @option path [String]
209
+ # @option path [String, Pathname]
207
210
  # @option options [Hash<Symbol|String,Any>] Native (ruby-stdlib) ::JSON#generate attributes
208
211
  # @param value_processor [Block]
209
212
  # @return [void]
@@ -217,7 +220,7 @@ class Qonfig::DataSet # rubocop:disable Metrics/ClassLength
217
220
  end
218
221
  alias_method :dump_to_json, :save_to_json
219
222
 
220
- # @option path [String]
223
+ # @option path [String, Pathname]
221
224
  # @option symbolize_keys [Boolean]
222
225
  # @option options [Hash<Symbol|String,Any>] Native (ruby-stdlib) ::YAML#dump attributes
223
226
  # @param value_processor [Block]
data/lib/qonfig/dsl.rb CHANGED
@@ -15,7 +15,7 @@ module Qonfig::DSL # rubocop:disable Metrics/ModuleLength
15
15
  # @api private
16
16
  # @since 0.1.0
17
17
  # @version 0.20.0
18
- # rubocop:disable Metrics/LineLength, Metrics/AbcSize
18
+ # rubocop:disable Layout/LineLength, Metrics/AbcSize
19
19
  def extended(child_klass)
20
20
  child_klass.instance_variable_set(:@definition_commands, Qonfig::CommandSet.new)
21
21
  child_klass.instance_variable_set(:@instance_commands, Qonfig::CommandSet.new)
@@ -33,7 +33,7 @@ module Qonfig::DSL # rubocop:disable Metrics/ModuleLength
33
33
  end
34
34
  end)
35
35
  end
36
- # rubocop:enable Metrics/LineLength, Metrics/AbcSize
36
+ # rubocop:enable Layout/LineLength, Metrics/AbcSize
37
37
  end
38
38
 
39
39
  # @return [Qonfig::CommandSet]
@@ -34,7 +34,10 @@ class Qonfig::Imports::DirectKey < Qonfig::Imports::Abstract
34
34
  # @api private
35
35
  # @since 0.18.0
36
36
  # @version 0.21.0
37
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/BlockLength
37
+ # rubocop:disable Metrics/AbcSize
38
+ # rubocop:disable Metrics/MethodLength
39
+ # rubocop:disable Metrics/BlockLength
40
+ # rubocop:disable Metrics/PerceivedComplexity
38
41
  def import!(settings_interface = Module.new)
39
42
  key_matchers.each do |key_matcher|
40
43
  raise(
@@ -80,7 +83,10 @@ class Qonfig::Imports::DirectKey < Qonfig::Imports::Abstract
80
83
  end
81
84
  end
82
85
  end
83
- # rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/BlockLength
86
+ # rubocop:enable Metrics/AbcSize
87
+ # rubocop:enable Metrics/MethodLength
88
+ # rubocop:enable Metrics/BlockLength
89
+ # rubocop:enable Metrics/PerceivedComplexity
84
90
 
85
91
  private
86
92
 
@@ -40,7 +40,10 @@ class Qonfig::Imports::Mappings < Qonfig::Imports::Abstract
40
40
  # @api private
41
41
  # @since 0.18.0
42
42
  # @version 0.21.0
43
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/BlockLength
43
+ # rubocop:disable Metrics/AbcSize
44
+ # rubocop:disable Metrics/MethodLength
45
+ # rubocop:disable Metrics/BlockLength
46
+ # rubocop:disable Metrics/PerceivedComplexity
44
47
  def import!(settings_interface = Module.new) # rubocop:disable Metrics/AbcSize
45
48
  key_matchers.each_pair do |(mapped_method_name, key_matcher)|
46
49
  raise(
@@ -85,7 +88,10 @@ class Qonfig::Imports::Mappings < Qonfig::Imports::Abstract
85
88
  end
86
89
  end
87
90
  end
88
- # rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/BlockLength
91
+ # rubocop:enable Metrics/AbcSize
92
+ # rubocop:enable Metrics/MethodLength
93
+ # rubocop:enable Metrics/BlockLength
94
+ # rubocop:enable Metrics/PerceivedComplexity
89
95
 
90
96
  private
91
97
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  # @api private
4
4
  # @since 0.2.0
5
+ # rubocop:disable Style/StaticClass
5
6
  class Qonfig::Loaders::Basic
6
7
  class << self
7
8
  # @param data [String]
@@ -36,3 +37,4 @@ class Qonfig::Loaders::Basic
36
37
  end
37
38
  end
38
39
  end
40
+ # rubocop:enable Style/StaticClass
@@ -11,8 +11,9 @@ class Qonfig::Loaders::JSON < Qonfig::Loaders::Basic
11
11
  #
12
12
  # @api private
13
13
  # @since 0.5.0
14
+ # @version 0.26.0
14
15
  def load(data)
15
- ::JSON.parse(data, max_nesting: false, allow_nan: true)
16
+ ::JSON.parse(ERB.new(data).result, max_nesting: false, allow_nan: true)
16
17
  rescue ::JSON::ParserError => error
17
18
  raise(Qonfig::JSONLoaderParseError.new(error.message).tap do |exception|
18
19
  exception.set_backtrace(error.backtrace)
@@ -8,6 +8,7 @@ module Qonfig::Plugins
8
8
  require_relative 'plugins/abstract'
9
9
  require_relative 'plugins/toml'
10
10
  require_relative 'plugins/pretty_print'
11
+ require_relative 'plugins/vault'
11
12
 
12
13
  # @since 0.4.0
13
14
  @plugin_registry = Registry.new
@@ -8,8 +8,15 @@ class Qonfig::Plugins::PrettyPrint < Qonfig::Plugins::Abstract
8
8
  #
9
9
  # @api private
10
10
  # @since 0.19.0
11
- # @version 0.21.0
11
+ # @version 0.24.0
12
12
  def install!
13
+ # :nocov:
14
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0')
15
+ require_relative 'pretty_print/ruby_2_7_basic_object_pp_patch'
16
+ end
17
+ # :nocov:
18
+
19
+ require_relative 'pretty_print/requirements'
13
20
  require_relative 'pretty_print/mixin'
14
21
  require_relative 'pretty_print/data_set'
15
22
  require_relative 'pretty_print/settings'