Fix compatibility with Bundler 1.6
Stop using `Bundler.settings.with`, because it will be removed from Bundler 1.6. Also, as described in #7653, we could use `Bundler.settings[:with]`, but that would be internal API again, so it probably breaks again in the future. That's why I added a `BundlerHelper` module to parse the required optional group from our config files, without the use of any internal Bundler API. Fixes #7653
This commit is contained in:
parent
db95c94c97
commit
63fcc9c1bc
2 changed files with 29 additions and 1 deletions
|
|
@ -4,9 +4,11 @@ require_relative 'boot'
|
||||||
|
|
||||||
require 'rails/all'
|
require 'rails/all'
|
||||||
|
|
||||||
|
require_relative "bundler_helper"
|
||||||
|
|
||||||
# Require the gems listed in Gemfile, including any gems
|
# Require the gems listed in Gemfile, including any gems
|
||||||
# you've limited to :test, :development, or :production.
|
# you've limited to :test, :development, or :production.
|
||||||
Bundler.require(*Rails.groups(*Bundler.settings.with))
|
Bundler.require(*Rails.groups(BundlerHelper.database))
|
||||||
|
|
||||||
# Do not dump the limit of boolean fields on MySQL,
|
# Do not dump the limit of boolean fields on MySQL,
|
||||||
# since that generates a db/schema.rb that's incompatible
|
# since that generates a db/schema.rb that's incompatible
|
||||||
|
|
|
||||||
26
config/bundler_helper.rb
Normal file
26
config/bundler_helper.rb
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "yaml"
|
||||||
|
|
||||||
|
module BundlerHelper
|
||||||
|
def self.rails_env
|
||||||
|
@rails_env ||= ENV["RAILS_ENV"] ||
|
||||||
|
parse_value_from_file("diaspora.yml", "configuration", "server", "rails_environment") ||
|
||||||
|
parse_value_from_file("defaults.yml", "defaults", "server", "rails_environment")
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.database
|
||||||
|
@adapter ||= parse_value_from_file("database.yml", rails_env, "adapter")
|
||||||
|
|
||||||
|
raise "No database adapter found, please fix your config/database.yml!" unless @adapter
|
||||||
|
|
||||||
|
@adapter.sub("mysql2", "mysql")
|
||||||
|
end
|
||||||
|
|
||||||
|
private_class_method def self.parse_value_from_file(file, *keys)
|
||||||
|
path = File.join(__dir__, file)
|
||||||
|
return YAML.load_file(path).dig(*keys) if File.file?(path)
|
||||||
|
|
||||||
|
puts "Configuration file #{path} not found, ensure it's present" # rubocop:disable Rails/Output
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in a new issue