summaryrefslogtreecommitdiffstats
path: root/config/initializers/zeitwerk.rb
blob: ab86b28e2ba7fe79ea83a45e6f157194b98e9a41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true

lib = Rails.root.join('lib/redmine')
Rails.autoloaders.main.push_dir lib, namespace: Redmine
Rails.application.config.watchable_dirs[lib] = [:rb]

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