sourced_config 0.2.1 → 0.3.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/lib/generators/sourced_config/install_generator.rb +2 -1
- data/lib/generators/sourced_config/templates/config.yml.erb +5 -0
- data/lib/generators/sourced_config/templates/sourced_config.rb +21 -18
- data/lib/sourced_config/config_manager.rb +2 -2
- data/lib/sourced_config/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1805418799b3ae9c8b027496139bc2bbb47c4d50ee454bbc10f3fe675bf8677
|
4
|
+
data.tar.gz: 8be3d42e01f8c5c8e7297eacb60b79f6f8742d9db3b013e60c62809515c2e1ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d7aca269439664f6ceccbad924095e3244ed8f2a5bcc7d1c11608a0e0159a3851b51a3b00bc8c6de900121e65032073b7b8a52c5e1f84eda9ef93e332694494
|
7
|
+
data.tar.gz: da4e2f05d692e8453b9b6dd69defc24f0e9e0ff29ed9211d13a951d61056f12080a5acd441bea782f4bb611f18441a66650d9e5c1189dae53d174ea377116495
|
@@ -11,9 +11,10 @@ module SourcedConfig
|
|
11
11
|
desc "Creates an initializer for the gem."
|
12
12
|
def copy_tasks
|
13
13
|
template "templates/sourced_config.rb", "config/initializers/sourced_config.rb"
|
14
|
+
template "templates/config.yml.erb", "config/config.yml.erb"
|
14
15
|
|
15
16
|
application do
|
16
|
-
<<RUBY
|
17
|
+
<<RUBY
|
17
18
|
# Initialise watch of application configuration
|
18
19
|
config.after_initialize { |app| ::SourcedConfig.setup(app) }
|
19
20
|
config.before_eager_load { |app| ::SourcedConfig.setup(app) }
|
@@ -1,26 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
# Configure after autoloading of constants so schema class can be specified
|
4
|
+
Rails.application.config.to_prepare do
|
5
|
+
SourcedConfig.configure do |config|
|
6
|
+
# This is the class that will be used to validate the configuration. The default is the minimum configuration
|
7
|
+
# required, `SourcedConfig::ConfigContract` but you should create your own class that inherits from it and define
|
8
|
+
# your own configuration schema as needed.
|
9
|
+
# config.config_schema_klass = AppConfig
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
+
# The base configuration file path. This is always required and loaded first. It can be an ERB file.
|
12
|
+
# config.base_configuration_file_path = Rails.root.join("config/config.yml.erb")
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
# The type of configuration source to use. If not specified the configuration is loaded only from the default source
|
15
|
+
# in `base_configuration_file_path`. Can be one of:
|
16
|
+
# `SourcedConfig::ConfigManager::SOURCE_TYPE_LOCAL_FILE`
|
17
|
+
# `SourcedConfig::ConfigManager::SOURCE_TYPE_S3_CONFIG_BUCKET`
|
18
|
+
# config.config_type = SourcedConfig::ConfigManager::SOURCE_TYPE_LOCAL_FILE
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
+
# The path to the configuration file either locally or in S3. It *cannot* be an ERB file.
|
21
|
+
# config.configuration_file_path = "custom_config/config.yml"
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
+
# If the remote configuration source is an S3 bucket, the bucket name of said bucket.
|
24
|
+
# config.configuration_bucket = "my-bucket-name"
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
+
# If the remote configuration source is an S3 bucket, the region of said bucket.
|
27
|
+
# config.configuration_bucket_region = "us-east-1"
|
28
|
+
end
|
26
29
|
end
|
@@ -11,7 +11,7 @@ module SourcedConfig
|
|
11
11
|
configuration[key]
|
12
12
|
end
|
13
13
|
|
14
|
-
def load!(external_type, external_source_path)
|
14
|
+
def load!(external_type, external_source_path, schema_klass: nil)
|
15
15
|
Rails.logger.info "Load configuration data from #{external_type} - #{external_source_path}" if external_type
|
16
16
|
if loaded?
|
17
17
|
Rails.logger.warn "An attempt to load configuration happened when it is already loaded"
|
@@ -20,7 +20,7 @@ module SourcedConfig
|
|
20
20
|
primary_config = load_yaml_and_parse_erb(SourcedConfig.configuration.base_configuration_file_path).deep_symbolize_keys
|
21
21
|
external = external_type.present? && load_external_config(external_type, external_source_path).deep_symbolize_keys
|
22
22
|
|
23
|
-
schema = SourcedConfig.configuration.config_schema_klass.new
|
23
|
+
schema = (schema_klass || SourcedConfig.configuration.config_schema_klass).new
|
24
24
|
config_contract = schema.call(external ? primary_config.deep_merge(external) : primary_config)
|
25
25
|
if config_contract.failure?
|
26
26
|
messages = config_contract.errors(full: true).to_h
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sourced_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Ierodiaconou
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- Rakefile
|
83
83
|
- lib/generators/sourced_config/USAGE
|
84
84
|
- lib/generators/sourced_config/install_generator.rb
|
85
|
+
- lib/generators/sourced_config/templates/config.yml.erb
|
85
86
|
- lib/generators/sourced_config/templates/sourced_config.rb
|
86
87
|
- lib/sourced_config.rb
|
87
88
|
- lib/sourced_config/config_contract.rb
|