From 9c23cbbd44ce3226f9fc3a524a37efa07bb5c2a8 Mon Sep 17 00:00:00 2001 From: Chris LaRose Date: Sat, 16 Mar 2024 00:11:18 -0700 Subject: [PATCH 1/3] Silence deprecation warnings for fixture_path in Rails >= 7.1 (#357) --- spec/spec_helper.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 244b76b8..ca0739e7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -59,6 +59,13 @@ end end +module FixturePathHelper + def fixture_path + # Call fixture_paths.first in Rails >= 7.1 to avoid deprecation warnings + respond_to?(:fixture_paths) ? fixture_paths.first : super + end +end + ## # Common Rspec configure # @@ -84,6 +91,8 @@ def self.reset end end end + + config.include FixturePathHelper end ## From 59fffa6a8a120a62e2fe503474528fc69341b294 Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Sat, 16 Mar 2024 07:50:35 +0000 Subject: [PATCH 2/3] Configuring the environment name in Rails (#356) * Bumping rails versions to fix build issues locally * Added a new config option called 'environment', which allows you to overide the default config environment which is the Rails.env. This allows us to have multiple different environments, without having to worry about making custom rails environments --------- Co-authored-by: Neil Williams Co-authored-by: Chris LaRose --- README.md | 2 ++ lib/config.rb | 3 ++- lib/config/integrations/rails/railtie.rb | 2 +- lib/generators/config/templates/config.rb | 5 +++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fcecf3e4..119580fe 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,8 @@ which will generate customizable config file `config/initializers/config.rb` and You can now edit them to adjust to your needs. +> Note: By default, the config environment will match the Rails environment (`Rails.env`). This can be changed by setting `config.environment`. + ### Installing on Padrino Add the gem to your `Gemfile` and run `bundle install` to install it. Then edit `app.rb` and register `Config` diff --git a/lib/config.rb b/lib/config.rb index 0efde070..db06bcbc 100644 --- a/lib/config.rb +++ b/lib/config.rb @@ -27,7 +27,8 @@ module Config overwrite_arrays: true, merge_hash_arrays: false, validation_contract: nil, - evaluate_erb_in_yaml: true + evaluate_erb_in_yaml: true, + environment: nil ) def self.setup diff --git a/lib/config/integrations/rails/railtie.rb b/lib/config/integrations/rails/railtie.rb index 460fa5f3..6748c116 100644 --- a/lib/config/integrations/rails/railtie.rb +++ b/lib/config/integrations/rails/railtie.rb @@ -9,7 +9,7 @@ def preload # Parse the settings before any of the initializers Config.load_and_set_settings( - Config.setting_files(::Rails.root.join('config'), ::Rails.env) + Config.setting_files(::Rails.root.join('config'), Config.environment.nil? ? ::Rails.env : Config.environment.to_sym) ) end diff --git a/lib/generators/config/templates/config.rb b/lib/generators/config/templates/config.rb index 6ea74ecc..f6a222d0 100644 --- a/lib/generators/config/templates/config.rb +++ b/lib/generators/config/templates/config.rb @@ -15,6 +15,11 @@ # # config.overwrite_arrays = true + # Defines current environment, affecting which settings file will be loaded. + # Default: `Rails.env` + # + # config.environment = ENV.fetch('ENVIRONMENT', :development) + # Load environment variables from the `ENV` object and override any settings defined in files. # # config.use_env = false From ddd3ed64b43e87a54265a2da881c6fbc20e15d3c Mon Sep 17 00:00:00 2001 From: Chris LaRose Date: Sat, 16 Mar 2024 00:57:19 -0700 Subject: [PATCH 3/3] Bump to version 5.4.0 --- CHANGELOG.md | 6 ++++++ lib/config/version.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8cd44cb..6319f40f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 5.4.0 + +### New features + +* Add configuration option `environment` to override the use of `Rails.env` ([#356](https://github.com/rubyconfig/config/pull/356)) + ## 5.3.0 * Remove `dry-validation` from dependencies ([#333](https://github.com/rubyconfig/config/pull/333)) diff --git a/lib/config/version.rb b/lib/config/version.rb index f29f179a..a4dcdf24 100644 --- a/lib/config/version.rb +++ b/lib/config/version.rb @@ -1,3 +1,3 @@ module Config - VERSION = '5.3.0'.freeze + VERSION = '5.4.0'.freeze end