2.0.0.pre
Pre-releaseRailsConf 2019 special.
The first, preview, release in 2.x series.
There is no more API changes plans, only new features, so it's safe to start using 2.0.0.pre
.
NOTE: Internal functionality is likely to change though.
Breaking changes
-
Ruby >= 2.5.0 is required.
-
Changed the way of providing explicit values:
# BEFORE Config.new(overrides: data) # AFTER Config.new(data)
Features
- Add Rails credentials support.
The data from credentials is loaded after the data from YAML config and secrets,
but before environmental variables (i.e. env variables are stronger).
- Add support for local configuration files and credentials.
Now users can store their personal configurations in local files:
<config_name>.local.yml
config/credentials/local.yml.enc
(for Rails 6).
Local configs are meant for using in development and only loaded if Anyway::Settings.use_local_files
is true
(which is true by default if RACK_ENV
or RAILS_ENV
env variable is equal to "development"
).
- Added test helpers.
Added with_env
helper to test code in the context of the specified environment variables.
Included automatically in RSpec for examples with the type: :config
meta or with the spec/configs
path.
- Better Rails integration.
Anyway::Railtie
provides an access to Anyway::Settings
via Rails.applicaiton.configuration.anyway_config
.
It also adds app/configs
path to autoload paths (low-level, ActiveSupport::Dependencies
) to
make it possible to use configs in the app configuration files.
Changes
- Updated config name inference logic.
Config name is automatically inferred only if:
- the class name has a form of
<Module>::Config
(SomeModule::Config => "some_module"
) - the class name has a form of
<Something>Config
(SomeConfig => "some"
)
Fixes
- Fixed config classes inheritance.
Previously, inheritance didn't work due to the lack of proper handling of class-level configuration (naming, option parses settings, defaults).
Now it's possible to extend config classes without breaking the original classes functionality.
Other:
- if
config_name
is explicitly defined on class, it's inherited by subclasses:
class MyAppBaseConfig < Anyway::Config
config_name :my_app
end
class MyServiceConfig < MyAppBaseConfig
end
MyServiceConfig.config_name #=> "my_app"
- defaults are merged leaving the parent class defaults unchanged
- option parse extension are not overriden, but added to the parent class extensions.