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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1805418799b3ae9c8b027496139bc2bbb47c4d50ee454bbc10f3fe675bf8677
4
- data.tar.gz: 8be3d42e01f8c5c8e7297eacb60b79f6f8742d9db3b013e60c62809515c2e1ef
3
+ metadata.gz: 99b9388005849ac1568ac1694edd62c06c1bdc6b94b0533393f4b753720d8447
4
+ data.tar.gz: a614d545a272b2367834ae0c45abe2a6b1a11530653090e2778ddf6baecb327e
5
5
  SHA512:
6
- metadata.gz: 6d7aca269439664f6ceccbad924095e3244ed8f2a5bcc7d1c11608a0e0159a3851b51a3b00bc8c6de900121e65032073b7b8a52c5e1f84eda9ef93e332694494
7
- data.tar.gz: da4e2f05d692e8453b9b6dd69defc24f0e9e0ff29ed9211d13a951d61056f12080a5acd441bea782f4bb611f18441a66650d9e5c1189dae53d174ea377116495
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
- # config.config_schema_klass = AppConfig
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
- # config.base_configuration_file_path = Rails.root.join("config/config.yml.erb")
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SourcedConfig
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
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.0
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