qonfig 0.24.0 → 0.27.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +62 -0
  3. data/.gitignore +0 -2
  4. data/.rubocop.yml +19 -1
  5. data/CHANGELOG.md +53 -0
  6. data/Gemfile +2 -0
  7. data/Gemfile.lock +129 -0
  8. data/LICENSE.txt +1 -1
  9. data/README.md +115 -5
  10. data/Rakefile +0 -1
  11. data/gemfiles/with_external_deps.gemfile +2 -0
  12. data/gemfiles/with_external_deps.gemfile.lock +123 -0
  13. data/gemfiles/without_external_deps.gemfile.lock +113 -0
  14. data/lib/qonfig/commands/definition/load_from_env/value_converter.rb +2 -0
  15. data/lib/qonfig/commands/definition/load_from_env.rb +2 -0
  16. data/lib/qonfig/data_set.rb +3 -0
  17. data/lib/qonfig/imports/direct_key.rb +8 -2
  18. data/lib/qonfig/imports/mappings.rb +8 -2
  19. data/lib/qonfig/loaders/basic.rb +2 -0
  20. data/lib/qonfig/loaders/json.rb +2 -1
  21. data/lib/qonfig/loaders/yaml.rb +3 -1
  22. data/lib/qonfig/plugins/pretty_print/requirements.rb +3 -0
  23. data/lib/qonfig/plugins/pretty_print.rb +1 -0
  24. data/lib/qonfig/plugins/toml/commands/definition/expose_toml.rb +3 -3
  25. data/lib/qonfig/plugins/vault/commands/definition/expose_vault.rb +142 -0
  26. data/lib/qonfig/plugins/vault/commands/definition/load_from_vault.rb +53 -0
  27. data/lib/qonfig/plugins/vault/dsl.rb +35 -0
  28. data/lib/qonfig/plugins/vault/errors.rb +9 -0
  29. data/lib/qonfig/plugins/vault/loaders/vault.rb +74 -0
  30. data/lib/qonfig/plugins/vault.rb +24 -0
  31. data/lib/qonfig/plugins.rb +1 -0
  32. data/lib/qonfig/settings/key_matcher.rb +3 -1
  33. data/lib/qonfig/settings.rb +83 -22
  34. data/lib/qonfig/uploaders/base.rb +2 -0
  35. data/lib/qonfig/uploaders/yaml.rb +2 -0
  36. data/lib/qonfig/version.rb +1 -1
  37. data/lib/qonfig.rb +4 -1
  38. data/qonfig.gemspec +9 -8
  39. data/sig/.keep +0 -0
  40. data/spec/artifacts/.keep +0 -0
  41. data/spec/features/clear_options_spec.rb +92 -0
  42. data/spec/features/compacted_config_spec.rb +308 -0
  43. data/spec/features/composition_spec.rb +207 -0
  44. data/spec/features/config_definition_and_representation_spec.rb +535 -0
  45. data/spec/features/definition_order_spec.rb +69 -0
  46. data/spec/features/dig_functionality_spec.rb +47 -0
  47. data/spec/features/dot_notation_spec.rb +159 -0
  48. data/spec/features/export_settings_spec.rb +138 -0
  49. data/spec/features/expose_json_spec.rb +281 -0
  50. data/spec/features/expose_self/format_option_dynamic_spec.rb +69 -0
  51. data/spec/features/expose_self/format_option_json_spec.rb +74 -0
  52. data/spec/features/expose_self/format_option_unsupported_spec.rb +27 -0
  53. data/spec/features/expose_self/format_option_yaml_spec.rb +77 -0
  54. data/spec/features/expose_self_spec.rb +97 -0
  55. data/spec/features/expose_yaml_spec.rb +263 -0
  56. data/spec/features/freeze_state_spec.rb +122 -0
  57. data/spec/features/get_config_keys_spec.rb +62 -0
  58. data/spec/features/get_config_values_spec.rb +41 -0
  59. data/spec/features/has_a_key_spec.rb +48 -0
  60. data/spec/features/import_settings_spec.rb +323 -0
  61. data/spec/features/indifferent_access_spec.rb +57 -0
  62. data/spec/features/inheritance_spec.rb +110 -0
  63. data/spec/features/instantiation_without_class_definition_spec.rb +59 -0
  64. data/spec/features/iteration_over_setting_keys_spec.rb +48 -0
  65. data/spec/features/load_from_env_spec.rb +240 -0
  66. data/spec/features/load_from_json_spec.rb +97 -0
  67. data/spec/features/load_from_self/format_option_json_spec.rb +31 -0
  68. data/spec/features/load_from_self/format_option_unsupported_spec.rb +27 -0
  69. data/spec/features/load_from_self/format_option_yaml_spec.rb +49 -0
  70. data/spec/features/load_from_self/with_erb_instructions_spec.rb +33 -0
  71. data/spec/features/load_from_self/with_hash_like_data_representation_spec.rb +66 -0
  72. data/spec/features/load_from_self/with_non_hash_like_data_representation_spec.rb +19 -0
  73. data/spec/features/load_from_self/without_end_data_spec.rb +11 -0
  74. data/spec/features/load_from_yaml_spec.rb +110 -0
  75. data/spec/features/load_setting_values_from_file/by_instance_method_examples.rb +171 -0
  76. data/spec/features/load_setting_values_from_file/by_macros_examples.rb +165 -0
  77. data/spec/features/load_setting_values_from_file/load_from_json_spec.rb +21 -0
  78. data/spec/features/load_setting_values_from_file/load_from_self/json_format/end_data_with_env_spec.rb +100 -0
  79. data/spec/features/load_setting_values_from_file/load_from_self/json_format/with_end_data_spec.rb +129 -0
  80. data/spec/features/load_setting_values_from_file/load_from_self/json_format/with_incorrect_end_data_spec.rb +34 -0
  81. data/spec/features/load_setting_values_from_file/load_from_self/json_format/without_end_data_spec.rb +65 -0
  82. data/spec/features/load_setting_values_from_file/load_from_self/yaml_format/end_data_with_env_spec.rb +94 -0
  83. data/spec/features/load_setting_values_from_file/load_from_self/yaml_format/with_end_data_spec.rb +126 -0
  84. data/spec/features/load_setting_values_from_file/load_from_self/yaml_format/with_incorrect_end_data_spec.rb +32 -0
  85. data/spec/features/load_setting_values_from_file/load_from_self/yaml_format/without_end_data_spec.rb +65 -0
  86. data/spec/features/load_setting_values_from_file/load_from_yaml_spec.rb +21 -0
  87. data/spec/features/load_setting_values_from_file/shared_behavior_spec.rb +33 -0
  88. data/spec/features/mixin_spec.rb +387 -0
  89. data/spec/features/non_redefineable_core_methods_spec.rb +29 -0
  90. data/spec/features/plugins/pretty_print_spec.rb +86 -0
  91. data/spec/features/plugins/toml/expose_self/format_option_toml_spec.rb +71 -0
  92. data/spec/features/plugins/toml/expose_toml_spec.rb +221 -0
  93. data/spec/features/plugins/toml/load_from_self/format_option_toml_spec.rb +27 -0
  94. data/spec/features/plugins/toml/load_from_toml_spec.rb +109 -0
  95. data/spec/features/plugins/toml/load_setting_values_from_file/load_from_toml_spec.rb +27 -0
  96. data/spec/features/plugins/toml/load_setting_values_from_file/load_toml_from_self/end_data_with_env_spec.rb +95 -0
  97. data/spec/features/plugins/toml/load_setting_values_from_file/load_toml_from_self/with_end_data_spec.rb +125 -0
  98. data/spec/features/plugins/toml/load_setting_values_from_file/load_toml_from_self/with_incorrect_end_data_spec.rb +34 -0
  99. data/spec/features/plugins/toml/load_setting_values_from_file/load_toml_from_self/without_end_data_spec.rb +65 -0
  100. data/spec/features/plugins/toml/load_setting_values_from_file/shared_behavior_spec.rb +34 -0
  101. data/spec/features/plugins/toml/save_to_toml_spec.rb +149 -0
  102. data/spec/features/plugins/vault/expose_vault_spec.rb +117 -0
  103. data/spec/features/plugins/vault/load_from_vault_spec.rb +80 -0
  104. data/spec/features/plugins_spec.rb +89 -0
  105. data/spec/features/reload_spec.rb +75 -0
  106. data/spec/features/run_code_with_temporary_settings_spec.rb +104 -0
  107. data/spec/features/save_to_file/save_to_json_spec.rb +157 -0
  108. data/spec/features/save_to_file/save_to_yaml_spec.rb +189 -0
  109. data/spec/features/settings_as_predicates_spec.rb +47 -0
  110. data/spec/features/settings_redefinition_spec.rb +30 -0
  111. data/spec/features/slice_functionality_spec.rb +69 -0
  112. data/spec/features/subset_functionality_spec.rb +49 -0
  113. data/spec/features/validation_spec.rb +919 -0
  114. data/spec/fixtures/array_settings.yml +3 -0
  115. data/spec/fixtures/expose_json/incompatible_root_structure.json +6 -0
  116. data/spec/fixtures/expose_json/incompatible_structure.json +4 -0
  117. data/spec/fixtures/expose_json/project.development.json +7 -0
  118. data/spec/fixtures/expose_json/project.json +30 -0
  119. data/spec/fixtures/expose_json/project.production.json +7 -0
  120. data/spec/fixtures/expose_json/project.staging.json +7 -0
  121. data/spec/fixtures/expose_json/project.test.json +7 -0
  122. data/spec/fixtures/expose_yaml/incompatible_structure.yml +2 -0
  123. data/spec/fixtures/expose_yaml/project.development.yml +4 -0
  124. data/spec/fixtures/expose_yaml/project.production.yml +4 -0
  125. data/spec/fixtures/expose_yaml/project.staging.yml +4 -0
  126. data/spec/fixtures/expose_yaml/project.test.yml +4 -0
  127. data/spec/fixtures/expose_yaml/project.yml +25 -0
  128. data/spec/fixtures/json_array_sample.json +14 -0
  129. data/spec/fixtures/json_object_sample.json +9 -0
  130. data/spec/fixtures/json_with_empty_object.json +6 -0
  131. data/spec/fixtures/json_with_erb.json +6 -0
  132. data/spec/fixtures/plugins/toml/expose_toml/project.development.toml +4 -0
  133. data/spec/fixtures/plugins/toml/expose_toml/project.production.toml +4 -0
  134. data/spec/fixtures/plugins/toml/expose_toml/project.staging.toml +4 -0
  135. data/spec/fixtures/plugins/toml/expose_toml/project.test.toml +4 -0
  136. data/spec/fixtures/plugins/toml/expose_toml/project.toml +27 -0
  137. data/spec/fixtures/plugins/toml/mini_file.toml +6 -0
  138. data/spec/fixtures/plugins/toml/toml_sample_with_all_types.toml +72 -0
  139. data/spec/fixtures/plugins/toml/values_file/with_env.toml +13 -0
  140. data/spec/fixtures/plugins/toml/values_file/without_env.toml +6 -0
  141. data/spec/fixtures/rubocop_settings.yml +12 -0
  142. data/spec/fixtures/shared_settings_with_aliases.yml +10 -0
  143. data/spec/fixtures/travis_settings.yml +6 -0
  144. data/spec/fixtures/values_file/with_env.json +19 -0
  145. data/spec/fixtures/values_file/with_env.yml +17 -0
  146. data/spec/fixtures/values_file/without_env.json +8 -0
  147. data/spec/fixtures/values_file/without_env.yml +5 -0
  148. data/spec/fixtures/with_empty_hash.yml +4 -0
  149. data/spec/fixtures/with_erb_instructions.yml +3 -0
  150. data/spec/spec_helper.rb +46 -0
  151. data/spec/support/meta_scopes.rb +20 -0
  152. data/spec/support/spec_support.rb +42 -0
  153. metadata +181 -15
  154. data/.travis.yml +0 -47
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43bd1182137cdfc1dbba1156fb39daa755a0e0aa4fa8cd9a58e9ee62afd8a682
4
- data.tar.gz: 983d47af7e7d3edceff06ccdc5e17dfe18befa6768496c8dfbdbd909c7746beb
3
+ metadata.gz: 0f1dc9656c82767633db2cd0560ec5e556596db39cb24ebedb7e57e77953fe4f
4
+ data.tar.gz: e2cb31c582204c47346c3161974e7c0ae1c74f08ec25bcce33ab795dd2a920f0
5
5
  SHA512:
6
- metadata.gz: 544c1f4704f5cd33e08354bb47f202f8fe5356e698577eb15d176827e24fff77ecbc5d9fab19e79a1550c6d6771a70f8bec3228c2478737c24e15b49bf812986
7
- data.tar.gz: 59fb280050df43e2af4b37e548073083fdcce19f7250778e8c5db596a0c2fbd373b4f479dea721531c39b3a51ed0fe643e08b3251b93d2ea31952609db1241c4
6
+ metadata.gz: 9af958e6b471e7df6b66bea682622a02a1063d76b820aff9f4663b0a81b2a8ca8048aff94e4035d6d9376542da3b28e38cb4578d3f8d3e3f1f4a38c3eae220a2
7
+ data.tar.gz: fb8c4348721326fb48875506e20c48c924a6abd0d6317557849454a804a697801a71583c8b7cccc3b1b2441b3cac482872adbac9d59255357c65fd765aa05ff8
@@ -0,0 +1,62 @@
1
+ name: Test
2
+
3
+ on: [push, pull_request]
4
+
5
+ env:
6
+ FULL_COVERAGE_CHECK: true
7
+
8
+ jobs:
9
+ full-check:
10
+ runs-on: ubuntu-latest
11
+
12
+ # We want to run on external PRs, but not on our own internal PRs as they'll be run on push event
13
+ if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != '0exp/qonfig'
14
+
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: 3
20
+ bundler-cache: true
21
+ - name: Run Linter
22
+ run: bundle exec ci-helper RubocopLint
23
+ - name: Check missed spec suffixes
24
+ run: bundle exec ci-helper CheckSpecSuffixes --extra-paths spec/*.rb --ignored-paths spec/*_helper.rb spec/**/*_examples.rb
25
+ - name: Run specs
26
+ run: bundle exec ci-helper RunSpecs
27
+ - name: Audit
28
+ run: bundle exec ci-helper BundlerAudit
29
+ - name: Coveralls
30
+ uses: coverallsapp/github-action@master
31
+ with:
32
+ github-token: ${{ secrets.GITHUB_TOKEN }}
33
+ specs:
34
+ runs-on: ubuntu-latest
35
+ continue-on-error: ${{ matrix.experimental }}
36
+
37
+ env:
38
+ FULL_COVERAGE_CHECK: false
39
+
40
+ # We want to run on external PRs, but not on our own internal PRs as they'll be run on push event
41
+ if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != '0exp/qonfig'
42
+
43
+ strategy:
44
+ fail-fast: false
45
+ matrix:
46
+ ruby: ["2.6", "2.7", "3.0", "3.1"]
47
+ experimental: [false]
48
+ include:
49
+ - ruby: head
50
+ experimental: true
51
+ - ruby: jruby
52
+ experimental: true
53
+
54
+
55
+ steps:
56
+ - uses: actions/checkout@v2
57
+ - uses: ruby/setup-ruby@v1
58
+ with:
59
+ ruby-version: ${{ matrix.ruby }}
60
+ bundler-cache: true
61
+ - name: Run specs
62
+ run: bundle exec ci-helper RunSpecs
data/.gitignore CHANGED
@@ -7,10 +7,8 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  .rspec_status
10
- Gemfile.lock
11
10
  /.idea
12
11
  .ruby-version
13
12
  /.vscode/
14
13
  /spec/artifacts/
15
- /gemfiles/*.gemfile.lock
16
14
  *.gem
data/.rubocop.yml CHANGED
@@ -5,13 +5,15 @@ inherit_gem:
5
5
  - lib/rubocop.rspec.yml
6
6
 
7
7
  AllCops:
8
- TargetRubyVersion: 2.6.5
8
+ TargetRubyVersion: 2.6.0
9
+ NewCops: enable
9
10
  Include:
10
11
  - lib/**/*.rb
11
12
  - spec/**/*.rb
12
13
  - Gemfile
13
14
  - Rakefile
14
15
  - qonfig.gemspec
16
+ - gemfiles/*.gemfile
15
17
  - bin/console
16
18
  - bin/rspec
17
19
 
@@ -26,3 +28,19 @@ Style/RedundantBegin:
26
28
  # NOTE: too situative
27
29
  Metrics/ParameterLists:
28
30
  Enabled: false
31
+
32
+ # NOTE: too situative in current code base
33
+ Style/NilComparison:
34
+ Enabled: false
35
+
36
+ # NOTE: too situative in current code base
37
+ Style/NonNilCheck:
38
+ Enabled: false
39
+
40
+ # NOTE: too situative in current code base
41
+ Lint/MissingSuper:
42
+ Enabled: false
43
+
44
+ # NOTE: too situative in current code base
45
+ Lint/EmptyBlock:
46
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,6 +1,59 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.27.0] - 2022-01-12
5
+ ### Changed
6
+ - Drop Ruby 2.5 support.
7
+ - Fix YAML loading in Psych v4 (#132).
8
+
9
+ ## [0.26.0] - 2021-07-01
10
+ ### Added
11
+ - Support `ERB` in `load_from_json` method;
12
+
13
+ ## [0.25.0] - 2020-09-15
14
+ ### Added
15
+ - Support for **Vault** config provider:
16
+ - realized as a plugin (`Qonfig.plugin(:vault)`);
17
+ - provides `#load_from_vault`, `#expose_vault` methods and works in `#*_yaml`-like manner);
18
+ - depends on `gem vault (>= 0.1)`
19
+ - `Qonfig::Settings#[]` behave like `Qonfig::Settings#__dig__`;
20
+ - An ability to represent the config hash in dot-notated style (all config keys are represented in dot-notated format):
21
+ - works via `#to_h(dot_style: true)`;
22
+ - `key_transformer:` and `value_transfomer:` options are supported too;
23
+
24
+ ```ruby
25
+ class Config << Qonfig::DataSet
26
+ setting :database do
27
+ setting :host, 'localhost'
28
+ setting :port, 6432
29
+ end
30
+
31
+ setting :api do
32
+ setting :rest_enabled, true
33
+ setting :rpc_enabled, false
34
+ end
35
+ end
36
+
37
+ Config.new.to_h(dot_style: true)
38
+ # =>
39
+ {
40
+ 'database.host' => 'localhost',
41
+ 'database.port' => 6432,
42
+ 'api.rest_enabled' => true,
43
+ 'api.rpc_enabled' => false,
44
+ }
45
+ ```
46
+
47
+ ## [0.24.1] - 2020-03-10
48
+ ### Changed
49
+ - Enhanced dot-notated key resolving algorithm: now it goes through the all dot-notated key parts
50
+ until it finds the required setting key (or fails with `Qonfig::UnknowSettingKeyError`);
51
+
52
+ ### Fixed
53
+ - (**Pretty-Print Plugin**):
54
+ - dot-noted setting keys can not be pretty-printed (they raise `Qonfig::UnknownSettingKeyError`);
55
+ - added `set` and `pp` as preloaded dependencies;
56
+
4
57
  ## [0.24.0] - 2019-12-29
5
58
  ### Added
6
59
  - Support for **Ruby@2.7**;
data/Gemfile CHANGED
@@ -6,3 +6,5 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
7
7
  # Specify your gem's dependencies in qonfig.gemspec
8
8
  gemspec
9
+
10
+ gem 'activesupport', '~> 6.0' # AS 7 requires ruby > 2.7
data/Gemfile.lock ADDED
@@ -0,0 +1,129 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ qonfig (0.27.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (6.1.4.4)
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.23.0.1)
16
+ rubocop (= 1.23.0)
17
+ rubocop-performance (= 1.12.0)
18
+ rubocop-rails (= 2.12.4)
19
+ rubocop-rake (= 0.6.0)
20
+ rubocop-rspec (= 2.6.0)
21
+ ast (2.4.2)
22
+ bundler-audit (0.9.0.1)
23
+ bundler (>= 1.2.0, < 3)
24
+ thor (~> 1.0)
25
+ ci-helper (0.4.2)
26
+ colorize (~> 0.8)
27
+ dry-inflector (~> 0.2)
28
+ umbrellio-sequel-plugins (~> 0.4)
29
+ coderay (1.1.3)
30
+ colorize (0.8.1)
31
+ concurrent-ruby (1.1.9)
32
+ diff-lcs (1.5.0)
33
+ docile (1.4.0)
34
+ dry-inflector (0.2.1)
35
+ ffi (1.15.5-java)
36
+ i18n (1.8.11)
37
+ concurrent-ruby (~> 1.0)
38
+ method_source (1.0.0)
39
+ minitest (5.15.0)
40
+ parallel (1.21.0)
41
+ parser (3.1.0.0)
42
+ ast (~> 2.4.1)
43
+ pry (0.14.1)
44
+ coderay (~> 1.1)
45
+ method_source (~> 1.0)
46
+ pry (0.14.1-java)
47
+ coderay (~> 1.1)
48
+ method_source (~> 1.0)
49
+ spoon (~> 0.0)
50
+ rack (2.2.3)
51
+ rainbow (3.1.1)
52
+ rake (13.0.6)
53
+ regexp_parser (2.2.0)
54
+ rexml (3.2.5)
55
+ rspec (3.10.0)
56
+ rspec-core (~> 3.10.0)
57
+ rspec-expectations (~> 3.10.0)
58
+ rspec-mocks (~> 3.10.0)
59
+ rspec-core (3.10.1)
60
+ rspec-support (~> 3.10.0)
61
+ rspec-expectations (3.10.1)
62
+ diff-lcs (>= 1.2.0, < 2.0)
63
+ rspec-support (~> 3.10.0)
64
+ rspec-mocks (3.10.2)
65
+ diff-lcs (>= 1.2.0, < 2.0)
66
+ rspec-support (~> 3.10.0)
67
+ rspec-support (3.10.3)
68
+ rubocop (1.23.0)
69
+ parallel (~> 1.10)
70
+ parser (>= 3.0.0.0)
71
+ rainbow (>= 2.2.2, < 4.0)
72
+ regexp_parser (>= 1.8, < 3.0)
73
+ rexml
74
+ rubocop-ast (>= 1.12.0, < 2.0)
75
+ ruby-progressbar (~> 1.7)
76
+ unicode-display_width (>= 1.4.0, < 3.0)
77
+ rubocop-ast (1.15.1)
78
+ parser (>= 3.0.1.1)
79
+ rubocop-performance (1.12.0)
80
+ rubocop (>= 1.7.0, < 2.0)
81
+ rubocop-ast (>= 0.4.0)
82
+ rubocop-rails (2.12.4)
83
+ activesupport (>= 4.2.0)
84
+ rack (>= 1.1)
85
+ rubocop (>= 1.7.0, < 2.0)
86
+ rubocop-rake (0.6.0)
87
+ rubocop (~> 1.0)
88
+ rubocop-rspec (2.6.0)
89
+ rubocop (~> 1.19)
90
+ ruby-progressbar (1.11.0)
91
+ sequel (5.52.0)
92
+ simplecov (0.21.2)
93
+ docile (~> 1.1)
94
+ simplecov-html (~> 0.11)
95
+ simplecov_json_formatter (~> 0.1)
96
+ simplecov-html (0.12.3)
97
+ simplecov-lcov (0.8.0)
98
+ simplecov_json_formatter (0.1.3)
99
+ spoon (0.0.6)
100
+ ffi
101
+ symbiont-ruby (0.7.0)
102
+ thor (1.2.1)
103
+ tzinfo (2.0.4)
104
+ concurrent-ruby (~> 1.0)
105
+ umbrellio-sequel-plugins (0.5.1.27)
106
+ sequel
107
+ symbiont-ruby
108
+ unicode-display_width (2.1.0)
109
+ zeitwerk (2.5.3)
110
+
111
+ PLATFORMS
112
+ ruby
113
+ universal-java-1.8
114
+
115
+ DEPENDENCIES
116
+ activesupport (~> 6.0)
117
+ armitage-rubocop (~> 1.7)
118
+ bundler
119
+ bundler-audit
120
+ ci-helper
121
+ pry
122
+ qonfig!
123
+ rake (>= 13)
124
+ rspec (~> 3.10)
125
+ simplecov (~> 0.20)
126
+ simplecov-lcov
127
+
128
+ BUNDLED WITH
129
+ 2.3.3
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018-2019 Rustam Ibragimov
3
+ Copyright (c) 2018-2020 Rustam Ibragimov
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -40,6 +40,9 @@ require 'qonfig'
40
40
  - [Inheritance](#inheritance)
41
41
  - [Composition](#composition)
42
42
  - [Hash representation](#hash-representation)
43
+ - [Default behaviour (without options)](#default-behavior-without-options)
44
+ - [With transformations](#with-transformations)
45
+ - [Dot-style format](#dot-style-format)
43
46
  - [Smart Mixin](#smart-mixin) (`Qonfig::Configurable`)
44
47
  - [Instantiation without class definition](#instantiation-without-class-definition) (`Qonfig::DataSet.build(&definitions)`)
45
48
  - [Compacted config](#compacted-config)
@@ -102,6 +105,7 @@ require 'qonfig'
102
105
  - [Plugins](#plugins)
103
106
  - [toml](#plugins-toml) (support for `TOML` format)
104
107
  - [pretty_print](#plugins-pretty_print) (beautified/prettified console output)
108
+ - [vault](#plugins-vault) (support for `Vault` store)
105
109
  - [Roadmap](#roadmap)
106
110
  - [Build](#build)
107
111
  ---
@@ -188,6 +192,10 @@ config.settings['vendor_api']['domain'] # => 'app.service.com'
188
192
  config.settings['vendor_api']['login'] # => 'test_user'
189
193
  config.settings['enable_graphql'] # => false
190
194
 
195
+ # dig to value
196
+ config.settings[:vendor_api, :domain] # => 'app.service.com'
197
+ config.settings[:vendor_api, 'login'] # => 'test_user'
198
+
191
199
  # get option value directly via index (with indifferent access)
192
200
  config['project_id'] # => nil
193
201
  config['enable_graphql'] # => false
@@ -271,7 +279,7 @@ config.slice_value('vendor_api.port') # => Qonfig::UnknownSettingError # (key do
271
279
  # - get a subset (a set of sets) of config settings represented as a hash;
272
280
  # - each key (or key set) represents a requirement of a certain setting key;
273
281
 
274
- config.subet(:vendor_api, :enable_graphql)
282
+ config.subset(:vendor_api, :enable_graphql)
275
283
  # => { 'vendor_api' => { 'login' => ..., 'domain' => ... }, 'enable_graphql' => false }
276
284
 
277
285
  config.subset(:project_id, [:vendor_api, :domain], [:credentials, :user, :login])
@@ -436,6 +444,12 @@ project_config.settings.db.password # => 'testpaswd'
436
444
 
437
445
  ### Hash representation
438
446
 
447
+ - works via `#to_h` and `#to_hash`;
448
+ - supported options:
449
+ - `key_transformer:` - an optional proc that accepts setting key and makes your custom transformations;
450
+ - `value_transformer:` - an optional proc that accepts setting value and makes your custom transformations;
451
+ - `dot_style:` - (`false` by default) represent setting keys in dot-notation (transformations are supported too);
452
+
439
453
  ```ruby
440
454
  class Config < Qonfig::DataSet
441
455
  setting :serializers do
@@ -454,9 +468,13 @@ class Config < Qonfig::DataSet
454
468
 
455
469
  setting :logger, Logger.new(STDOUT)
456
470
  end
471
+ ```
457
472
 
458
- Config.new.to_h
473
+ #### Default behavior (without-options)
459
474
 
475
+ ```ruby
476
+ Config.new.to_h
477
+ # =>
460
478
  {
461
479
  "serializers": {
462
480
  "json" => { "engine" => :ok },
@@ -467,6 +485,55 @@ Config.new.to_h
467
485
  }
468
486
  ```
469
487
 
488
+ #### With transformations
489
+
490
+ - with `key_transformer` and/or `value_transformer`;
491
+
492
+ ```ruby
493
+ key_transformer = -> (key) { "#{key}!!" }
494
+ value_transformer = -> (value) { "#{value}??" }
495
+
496
+ Config.new.to_h(key_transformer: key_transformer, value_transformer: value_transformer)
497
+ # =>
498
+ {
499
+ "serializers!!": {
500
+ "json!!" => { "engine!!" => "ok??" },
501
+ "hash!!" => { "engine!!" => "native??" },
502
+ },
503
+ "adapter!!" => { "default!!" => "memory_sync??" },
504
+ "logger!!" => "#<Logger:0x00007fcde799f158>??"
505
+ }
506
+ ```
507
+
508
+ #### Dot-style format
509
+
510
+ - transformations are supported too (`key_transformer` and `value_transformer`);
511
+
512
+ ```ruby
513
+ Config.new.to_h(dot_style: true)
514
+ # =>
515
+ {
516
+ "serializers.json.engine" => :ok,
517
+ "serializers.hash.engine" => :native,
518
+ "adapter.default" => :memory_sync,
519
+ "logger" => #<Logger:0x4b0d79fc>,
520
+ }
521
+ ```
522
+
523
+ ```ruby
524
+ transformer = -> (value) { "$$#{value}$$" }
525
+
526
+ Config.new.to_h(dot_style: true, key_transformer: transformer, value_transformer: transformer)
527
+
528
+ # => "#<Logger:0x00007fcde799f158>??"
529
+ {
530
+ "$$serializers.json.engine$$" => "$$ok$$",
531
+ "$$serializers.hash.engine$$" => "$$native$$",
532
+ "$$adapter.default$$" => "$$memory_sync$$",
533
+ "$$logger$$" => "$$#<Logger:0x00007fcde799f158>$$",
534
+ }
535
+ ```
536
+
470
537
  ---
471
538
 
472
539
  ### Smart Mixin
@@ -1001,6 +1068,8 @@ config.root_keys
1001
1068
  - method signature: `#reload!(configurations = {}, &configuration)`;
1002
1069
 
1003
1070
  ```ruby
1071
+ # -- config example ---
1072
+
1004
1073
  class Config < Qonfig::DataSet
1005
1074
  setting :db do
1006
1075
  setting :adapter, 'postgresql'
@@ -1013,6 +1082,10 @@ config = Config.new
1013
1082
 
1014
1083
  config.settings.db.adapter # => 'postgresql'
1015
1084
  config.settings.logger # => #<Logger:0x00007ff9>
1085
+ ```
1086
+
1087
+ ```ruby
1088
+ # --- redefine some settings (or add a new one) --
1016
1089
 
1017
1090
  config.configure { |conf| conf.logger = nil } # redefine some settings (will be reloaded)
1018
1091
 
@@ -1024,6 +1097,10 @@ class Config
1024
1097
 
1025
1098
  setting :enable_api, false # append new setting
1026
1099
  end
1100
+ ```
1101
+
1102
+ ```ruby
1103
+ # --- reload ---
1027
1104
 
1028
1105
  # reload settings
1029
1106
  config.reload!
@@ -2163,6 +2240,7 @@ config.settings.web.password # => staging_password (from sidekiq.staging.yml)
2163
2240
 
2164
2241
  ### Load from JSON file
2165
2242
 
2243
+ - supports `ERB`;
2166
2244
  - `:strict` mode (fail behaviour when the required yaml file doesnt exist):
2167
2245
  - `true` (by default) - causes `Qonfig::FileNotFoundError`;
2168
2246
  - `false` - do nothing, ignore current command;
@@ -3081,6 +3159,7 @@ dynamic: 10
3081
3159
 
3082
3160
  - [toml](#plugins-toml) (provides `load_from_toml`, `save_to_toml`, `expose_toml`);
3083
3161
  - [pretty_print](#plugins-pretty_print) (beautified/prettified console output);
3162
+ - [vault](#plugins-vault) (provides `load_from_vault`, `expose_vault`)
3084
3163
 
3085
3164
  ---
3086
3165
 
@@ -3204,15 +3283,46 @@ config = Config.new
3204
3283
 
3205
3284
  ---
3206
3285
 
3286
+ ### Plugins: vault
3287
+
3288
+ - `Qonfig.plugin(:vault)`
3289
+ - adds support for `vault kv store`, [more info](https://www.vaultproject.io/docs/secrets/kv/kv-v2)
3290
+ - depends on `vault` gem ([link](https://github.com/hashicorp/vault-ruby)) (tested on `>= 0.1`);
3291
+ - provides `.load_from_vault` (works in `.load_from_yaml` manner ([doc](#load-from-yaml-file)));
3292
+ - provides `.expose_vault` (works in `.expose_yaml` manner ([doc](#expose-yaml)));
3293
+
3294
+ ```ruby
3295
+ # 1) require external dependency
3296
+ require 'vault'
3297
+
3298
+ # 2) Setup vault client
3299
+
3300
+ Vault.address = 'http://localhost:8200'
3301
+ Vault.token = 'super-duper-token-here'
3302
+
3303
+ # 3) enable plugin
3304
+ Qonfig.plugin(:vault)
3305
+
3306
+ # 3) use vault :)
3307
+ ```
3308
+
3309
+ ---
3310
+
3207
3311
  ## Roadmap
3208
3312
 
3209
3313
  - **Major**:
3210
- - distributed configuration server;
3211
- - cli toolchain;
3212
3314
  - support for Rails-like secrets;
3213
3315
  - support for persistent data storages (we want to store configs in multiple databases and files);
3214
- - Rails reload plugin;
3316
+ - rails plugin;
3317
+ - support for pattern matching;
3318
+ - support for type checking (via `rbs`, `typeprof`, `steep`);
3319
+ - console utilities;
3215
3320
  - **Minor**:
3321
+ - An ability to flag `Qonfig::Configurable`'s config object as `compacted` (`Qonfig::Compacted`);
3322
+ - Instance-based behavior for `Vault` plugin, also use instance of `Vault` client instead of `Singleton`;
3323
+ - External validation class with an importing api for better custom validations;
3324
+ - Setting value changement trace (in `anyway_config` manner);
3325
+ - Instantiation and reloading callbacks;
3216
3326
 
3217
3327
  ## Build
3218
3328
 
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'
@@ -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,123 @@
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.5)
30
+ ffi (1.14.2-java)
31
+ i18n (1.8.5)
32
+ concurrent-ruby (~> 1.0)
33
+ method_source (1.0.0)
34
+ minitest (5.14.2)
35
+ parallel (1.20.1)
36
+ parser (3.0.0.0)
37
+ ast (~> 2.4.1)
38
+ pry (0.13.1)
39
+ coderay (~> 1.1)
40
+ method_source (~> 1.0)
41
+ pry (0.13.1-java)
42
+ coderay (~> 1.1)
43
+ method_source (~> 1.0)
44
+ spoon (~> 0.0)
45
+ rack (2.2.3)
46
+ rainbow (3.0.0)
47
+ rake (13.0.3)
48
+ regexp_parser (2.0.2)
49
+ rexml (3.2.4)
50
+ rspec (3.10.0)
51
+ rspec-core (~> 3.10.0)
52
+ rspec-expectations (~> 3.10.0)
53
+ rspec-mocks (~> 3.10.0)
54
+ rspec-core (3.10.0)
55
+ rspec-support (~> 3.10.0)
56
+ rspec-expectations (3.10.0)
57
+ diff-lcs (>= 1.2.0, < 2.0)
58
+ rspec-support (~> 3.10.0)
59
+ rspec-mocks (3.10.0)
60
+ diff-lcs (>= 1.2.0, < 2.0)
61
+ rspec-support (~> 3.10.0)
62
+ rspec-support (3.10.0)
63
+ rubocop (1.7.0)
64
+ parallel (~> 1.10)
65
+ parser (>= 2.7.1.5)
66
+ rainbow (>= 2.2.2, < 4.0)
67
+ regexp_parser (>= 1.8, < 3.0)
68
+ rexml
69
+ rubocop-ast (>= 1.2.0, < 2.0)
70
+ ruby-progressbar (~> 1.7)
71
+ unicode-display_width (>= 1.4.0, < 2.0)
72
+ rubocop-ast (1.3.0)
73
+ parser (>= 2.7.1.5)
74
+ rubocop-performance (1.9.1)
75
+ rubocop (>= 0.90.0, < 2.0)
76
+ rubocop-ast (>= 0.4.0)
77
+ rubocop-rails (2.9.1)
78
+ activesupport (>= 4.2.0)
79
+ rack (>= 1.1)
80
+ rubocop (>= 0.90.0, < 2.0)
81
+ rubocop-rake (0.5.1)
82
+ rubocop
83
+ rubocop-rspec (2.1.0)
84
+ rubocop (~> 1.0)
85
+ rubocop-ast (>= 1.1.0)
86
+ ruby-progressbar (1.10.1)
87
+ simplecov (0.21.2)
88
+ docile (~> 1.1)
89
+ simplecov-html (~> 0.11)
90
+ simplecov_json_formatter (~> 0.1)
91
+ simplecov-html (0.12.3)
92
+ simplecov-lcov (0.8.0)
93
+ simplecov_json_formatter (0.1.2)
94
+ spoon (0.0.6)
95
+ ffi
96
+ toml-rb (2.0.1)
97
+ citrus (~> 3.0, > 3.0)
98
+ tzinfo (2.0.4)
99
+ concurrent-ruby (~> 1.0)
100
+ unicode-display_width (1.7.0)
101
+ vault (0.15.0)
102
+ aws-sigv4
103
+ zeitwerk (2.4.2)
104
+
105
+ PLATFORMS
106
+ universal-java-1.8
107
+ x86_64-darwin-19
108
+ x86_64-linux
109
+
110
+ DEPENDENCIES
111
+ armitage-rubocop (~> 1.7)
112
+ bundler
113
+ pry
114
+ qonfig!
115
+ rake (>= 13)
116
+ rspec (~> 3.10)
117
+ simplecov (~> 0.20)
118
+ simplecov-lcov
119
+ toml-rb (>= 2)
120
+ vault (>= 0.1)
121
+
122
+ BUNDLED WITH
123
+ 2.2.3