summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2021-11-17 20:55:08 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2021-11-17 20:55:08 +0000
commita914cf4c402b2597e0cc563bd84145ce9eda5a41 (patch)
treeedb14ba9ebce182cb4f7cac808bfb49c6c504a46 /config
parente82b0a77e348419bb4c4ed736ac126e22358eac0 (diff)
downloadredmine-a914cf4c402b2597e0cc563bd84145ce9eda5a41.tar.gz
redmine-a914cf4c402b2597e0cc563bd84145ce9eda5a41.zip
Switch to zeitwerk autoloader (#29914, #32938).
Patch by Takashi Kato. git-svn-id: http://svn.redmine.org/redmine/trunk@21287 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'config')
-rw-r--r--config/application.rb2
-rw-r--r--config/initializers/zeitwerk.rb31
2 files changed, 32 insertions, 1 deletions
diff --git a/config/application.rb b/config/application.rb
index fc6e6a33f..e74fcbf67 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -24,7 +24,7 @@ module RedmineApp
# -- 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.
diff --git a/config/initializers/zeitwerk.rb b/config/initializers/zeitwerk.rb
new file mode 100644
index 000000000..f5630b3ee
--- /dev/null
+++ b/config/initializers/zeitwerk.rb
@@ -0,0 +1,31 @@
+# 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