Project

General

Profile

Feature #32938 » alt-0005-Use-zeitwerk.patch

Takashi Kato, 2021-10-27 11:58

View differences:

app/models/custom_field.rb
end
end
end
require_dependency 'redmine/field_format'
app/models/enumeration.rb
end
end
end
# Force load the subclasses in development mode
require_dependency 'time_entry_activity'
require_dependency 'document_category'
require_dependency 'issue_priority'
app/models/group.rb
Watcher.where('user_id = ?', id).delete_all
end
end
require_dependency "group_builtin"
app/models/group_builtin.rb
private :create_instance
end
end
require_dependency "group_anonymous"
require_dependency "group_non_member"
app/models/principal.rb
end
end
end
require_dependency "user"
require_dependency "group"
config/application.rb
# -- all .rb files in that directory are automatically loaded.
# Custom directories with classes and modules you want to be autoloadable.
config.autoload_paths += %W(#{config.root}/lib)
config.autoloader = :zeitwerk
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
config/initializers/zeitwerk.rb
# frozen_string_literal: true
lib = Rails.root.join('lib/redmine')
Rails.autoloaders.main.push_dir lib, namespace: Redmine
IGNORE_LIST = [
'wiki_formatting/textile/redcloth3.rb',
'core_ext.rb',
'core_ext'
]
class RedmineInflector < Zeitwerk::Inflector
def camelize(basename, abspath)
abspath.match?('redmine\/version.rb\z') ? 'VERSION' : super
end
end
Rails.autoloaders.each do |loader|
loader.inflector = RedmineInflector.new
loader.inflector.inflect(
'html' => 'HTML',
'csv' => 'CSV',
'pdf' => 'PDF',
'url' => 'URL',
'pop3' => 'POP3',
'imap' => 'IMAP'
)
IGNORE_LIST.each do |mod|
loader.ignore lib.join(mod)
end
end
lib/redmine/plugin_loader.rb
def self.create_assets_reloader
plugin_assets_dirs = {}
@plugin_directories.each do |dir|
directories.each do |dir|
plugin_assets_dirs[dir.assets_dir] = ['*']
end
ActiveSupport::FileUpdateChecker.new([], plugin_assets_dirs) do
......
# Add the plugin directories to rails autoload paths
engine_cfg = Rails::Engine::Configuration.new(directory.to_s)
engine_cfg.paths.add 'lib', eager_load: true
Rails.application.config.eager_load_paths += engine_cfg.eager_load_paths
Rails.application.config.autoload_once_paths += engine_cfg.autoload_once_paths
Rails.application.config.autoload_paths += engine_cfg.autoload_paths
engine_cfg.eager_load_paths.each do |dir|
Rails.autoloaders.main.push_dir dir
end
end
end
lib/redmine/twofa.rb
def self.scan_builtin_schemes
Dir[Rails.root.join('lib', 'redmine', 'twofa', '*.rb')].each do |file|
require_dependency file
require file
end
end
private_class_method :scan_builtin_schemes
(16-16/16)