Skip to content

Commit

Permalink
Merge branch 'master' into arrays_from_env
Browse files Browse the repository at this point in the history
  • Loading branch information
cjlarose authored Mar 30, 2024
2 parents 070b279 + ddd3ed6 commit 3af8b46
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
3 changes: 2 additions & 1 deletion lib/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,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
Expand Down
2 changes: 1 addition & 1 deletion lib/config/integrations/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/config/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Config
VERSION = '5.3.0'.freeze
VERSION = '5.4.0'.freeze
end
5 changes: 5 additions & 0 deletions lib/generators/config/templates/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand All @@ -84,6 +91,8 @@ def self.reset
end
end
end

config.include FixturePathHelper
end

##
Expand Down

0 comments on commit 3af8b46

Please sign in to comment.