rails-options_config 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7689f5625604db17772a75d1fdcdc5e7b316a3adbd79e8d691e575f1ba663f8
|
4
|
+
data.tar.gz: 47367ce04d3f612b6c627e18d5f481f104ece4d2579ce3bbda150ffef3826b84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 315b51d35d4db43a0957f53fd8a4f991a9f282ebfda4ec0c993855649af7e3e27c91a04603bcf7b1db09d7e306d3cf6687de5efe7f4e74686f27a079b9bf221e
|
7
|
+
data.tar.gz: a2dd452cdce5b421b8dc3f8df1152cbbf777b039d249c28f1f2ac74df89c302c921a0cab8cf346cdd0ab66ed9c9a7d724ddacbe96bc13521ee3a2469e9c3bcf6
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ As a project's size increases, its credentials file tends to become unmanageable
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem 'rails-
|
12
|
+
gem 'rails-options_config', '~> 1.0'
|
13
13
|
```
|
14
14
|
|
15
15
|
And then execute:
|
@@ -44,7 +44,7 @@ The YAML files can be encrypted: if the filename ends in `.enc`, the content wil
|
|
44
44
|
|
45
45
|
If a filename contains an environment tag, the content will be considered only in the respective environment: `config/options/pokemon.development.yml` will only be loaded in the `development` environment.
|
46
46
|
|
47
|
-
Files with the same root name will overwrite each other: environment specific files will overwrite generic ones, and encrypted files will overwrite clear text ones. This way you can provide sensible defaults in the generic files, with encryption if necessary, and override them in specific environments (for example using a `.development` gitignored file to use a local mocked server instead of the real thing).
|
47
|
+
Files with the same root name will overwrite each other: environment specific files will overwrite generic ones, and encrypted files will overwrite clear text ones. This way you can provide sensible defaults in the generic files, with encryption if necessary, and override them in specific environments (for example using a `.development` gitignored file to use a local mocked server instead of the real thing). The values are overwritten using `Hash#deep_merge` from Active Support, so you can overwrite only selected values and keep the default for the rest.
|
48
48
|
|
49
49
|
Options can also be picked up from environment variables. Any `!env/VAR` YAML tag will be substituted for the value of the `VAR` variable, anywhere in the file (even in keys). For example, setting `VAR=variable`:
|
50
50
|
|
@@ -64,7 +64,7 @@ will become:
|
|
64
64
|
|
65
65
|
You can set these options in `application.rb` or in any of the `environments/*.rb` files.
|
66
66
|
|
67
|
-
- `config.options.roots` : the directories, relative to `Rails.root`, in which to look for options files. You can either add to the existing array with `<<` or assign a new array. Default: `['config']`.
|
67
|
+
- `config.options.roots` : the directories, relative to `Rails.root`, in which to look for options files. You can either add to the existing array with `<<` or assign a new array. Default: `['config']`.
|
68
68
|
- `config.options.paths` : the patterns (in the format of `Dir.glob`) corresponding to the options files. They will be looked for in all the `roots` directories. Default: `['options.{yml,yaml}{.enc,}', 'options/**/*.{yml,yaml}{.enc,}']`.
|
69
69
|
- `config.options.raise_on_override` : set this to `true` if you want an exception to be raised if any key would be set by multiple files. If this is `false` and a "conflict" happens, one key will overwrite the other, but the order is undefined. This only applies to files with a different `path/to/file`, not to conflicts between the base and any environment-specific version. Default: `false`.
|
70
70
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative 'yaml/env_visitor'
|
2
2
|
require_relative 'key_override_error'
|
3
|
+
require_relative 'unusable_options_error'
|
3
4
|
|
4
5
|
module Rails
|
5
6
|
class Application
|
@@ -15,10 +16,16 @@ module Rails
|
|
15
16
|
full_path = Pathname(root).join(path)
|
16
17
|
encrypted = md[:enc].present?
|
17
18
|
content = if encrypted
|
18
|
-
|
19
|
+
YAML.parse encrypted(full_path).read
|
19
20
|
else
|
20
|
-
|
21
|
+
YAML.parse_file full_path
|
21
22
|
end
|
23
|
+
.therefore { |yaml| yaml_visitor.accept yaml }
|
24
|
+
|
25
|
+
unless content.is_a? Hash
|
26
|
+
raise OptionsConfig::UnusableOptionsError,
|
27
|
+
"The contents of options file `#{full_path}` are unsuitable. It must be a hash."
|
28
|
+
end
|
22
29
|
|
23
30
|
{
|
24
31
|
path: full_path,
|
@@ -49,7 +56,7 @@ module Rails
|
|
49
56
|
if config.options.raise_on_override
|
50
57
|
hashes.reduce credentials.config do |acc, hash|
|
51
58
|
acc.deep_merge hash do |key, value1, value2|
|
52
|
-
raise
|
59
|
+
raise OptionsConfig::KeyOverrideError,
|
53
60
|
'Key override while loading options: ' \
|
54
61
|
"trying to set `#{key}' to #{value2.inspect}:#{value2.class}, " \
|
55
62
|
"but it is already set to #{value1.inspect}:#{value1.class}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-options_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Moku S.r.l.
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-11-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -25,6 +25,20 @@ dependencies:
|
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '7.0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: therefore
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
28
42
|
description: As a project's size increases, its credentials file tends to become unmanageable.
|
29
43
|
With Rails Options Config you can split the credentials into smaller separate YAML
|
30
44
|
files.
|
@@ -40,6 +54,7 @@ files:
|
|
40
54
|
- lib/rails/options_config/application.rb
|
41
55
|
- lib/rails/options_config/engine.rb
|
42
56
|
- lib/rails/options_config/key_override_error.rb
|
57
|
+
- lib/rails/options_config/unusable_options_error.rb
|
43
58
|
- lib/rails/options_config/version.rb
|
44
59
|
- lib/rails/options_config/yaml/env_visitor.rb
|
45
60
|
homepage: https://github.com/moku-io/rails-options
|
@@ -64,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
79
|
- !ruby/object:Gem::Version
|
65
80
|
version: '0'
|
66
81
|
requirements: []
|
67
|
-
rubygems_version: 3.
|
82
|
+
rubygems_version: 3.5.22
|
68
83
|
signing_key:
|
69
84
|
specification_version: 4
|
70
85
|
summary: A uniform interface to multiple option YAML files.
|