sourced_config 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/sourced_config/install_generator.rb +1 -0
- data/lib/generators/sourced_config/templates/app_config_schema.rb +18 -0
- data/lib/generators/sourced_config/templates/sourced_config.rb +2 -2
- data/lib/sourced_config/config_contract.rb +0 -12
- data/lib/sourced_config/locale/i18n_backend.rb +1 -1
- 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: 99b9388005849ac1568ac1694edd62c06c1bdc6b94b0533393f4b753720d8447
|
4
|
+
data.tar.gz: a614d545a272b2367834ae0c45abe2a6b1a11530653090e2778ddf6baecb327e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b231f3234f177b62fff9fd6357cbc51a5ec0f8d403115f2d60f9ba30a4fe522cc388e17ebb59c5889e9aeec74211017d2d9a95a53db294f58f19711b52ed9a61
|
7
|
+
data.tar.gz: 3cd8e908f7a4012ea301aa54b618c3be41c3e681b3da831134abc679dfb5385fd8ab6e3441410db6fa4d27cfb5aae90fff6d122bd47deeed3bd1342000163091
|
@@ -12,6 +12,7 @@ module SourcedConfig
|
|
12
12
|
def copy_tasks
|
13
13
|
template "templates/sourced_config.rb", "config/initializers/sourced_config.rb"
|
14
14
|
template "templates/config.yml.erb", "config/config.yml.erb"
|
15
|
+
template "templates/app_config_schema.rb", "app/config/app_config_schema.rb"
|
15
16
|
|
16
17
|
application do
|
17
18
|
<<RUBY
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
3
|
+
class AppConfigSchema < SourcedConfig::ConfigContract
|
4
|
+
class LocalesConfig < SourcedConfig::ConfigContract
|
5
|
+
params do
|
6
|
+
required(:supported).filled(array[:string])
|
7
|
+
optional(:load_from_type).filled(:string)
|
8
|
+
optional(:load_from_source).maybe(:string)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
schema do
|
13
|
+
required(:locales).hash(LocalesConfig.schema)
|
14
|
+
|
15
|
+
# TODO: Add your own config keys here...
|
16
|
+
# ...
|
17
|
+
end
|
18
|
+
end
|
@@ -6,10 +6,10 @@ Rails.application.config.to_prepare do
|
|
6
6
|
# This is the class that will be used to validate the configuration. The default is the minimum configuration
|
7
7
|
# required, `SourcedConfig::ConfigContract` but you should create your own class that inherits from it and define
|
8
8
|
# your own configuration schema as needed.
|
9
|
-
|
9
|
+
config.config_schema_klass = AppConfigSchema
|
10
10
|
|
11
11
|
# The base configuration file path. This is always required and loaded first. It can be an ERB file.
|
12
|
-
|
12
|
+
config.base_configuration_file_path = Rails.root.join("config/config.yml.erb")
|
13
13
|
|
14
14
|
# The type of configuration source to use. If not specified the configuration is loaded only from the default source
|
15
15
|
# in `base_configuration_file_path`. Can be one of:
|
@@ -7,18 +7,6 @@ module SourcedConfig
|
|
7
7
|
class ConfigContract < ::Dry::Validation::Contract
|
8
8
|
::Dry::Validation.load_extensions(:monads)
|
9
9
|
|
10
|
-
class LocalesConfig < ConfigContract
|
11
|
-
params do
|
12
|
-
required(:supported).filled(array[:string])
|
13
|
-
optional(:load_from_type).filled(:string)
|
14
|
-
optional(:load_from_source).maybe(:string)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
params do
|
19
|
-
required(:locales).hash(LocalesConfig.schema)
|
20
|
-
end
|
21
|
-
|
22
10
|
class << self
|
23
11
|
def key_names
|
24
12
|
schema.key_map.map(&:name)
|
@@ -7,7 +7,7 @@ module SourcedConfig
|
|
7
7
|
module Locale
|
8
8
|
class I18nBackend < ::I18n::Backend::Simple
|
9
9
|
def load_translations
|
10
|
-
return unless ::SourcedConfig.loaded?
|
10
|
+
return unless ::SourcedConfig.loaded? && ::SourcedConfig[:locales].present?
|
11
11
|
type = ::SourcedConfig[:locales][:load_from_type]
|
12
12
|
source = ::SourcedConfig[:locales][:load_from_source]
|
13
13
|
null_client = Rails.env.test? ? NullClient.new : nil
|
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.3.
|
4
|
+
version: 0.3.1
|
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/app_config_schema.rb
|
85
86
|
- lib/generators/sourced_config/templates/config.yml.erb
|
86
87
|
- lib/generators/sourced_config/templates/sourced_config.rb
|
87
88
|
- lib/sourced_config.rb
|