Skip to content

Commit

Permalink
Drop lib/manageiq-gems-pending, add zeitwerk.rb
Browse files Browse the repository at this point in the history
Use for_gem_extension provided in zeitwerk 2.6.8
  • Loading branch information
jrafanie committed May 2, 2023
1 parent 180915b commit e198dbc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
4 changes: 1 addition & 3 deletions lib/manageiq/gems/pending.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# In case this is required directly
require 'manageiq-gems-pending'

require "manageiq/gems/pending/version"
require 'manageiq/gems/pending/zeitwerk'

module ManageIQ
module Gems
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
require 'manageiq/gems/pending'

require "zeitwerk"
loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
loader = Zeitwerk::Loader.for_gem_extension(ManageIQ::Gems::Pending)
loader.ignore(__FILE__)

# For straight requires from here
loader.push_dir("#{__dir__}/gems/pending/util")
lib = File.expand_path("#{__dir__}../../../../")
loader.push_dir("#{lib}/gems/pending/util")

# This tells the loader to not expect Mount or ObjectStorage namspaces...
loader.collapse("#{__dir__}/gems/pending/util/mount")
loader.collapse("#{__dir__}/gems/pending/util/object_storage")
loader.collapse("#{__dir__}/gems/pending/util/win32")
loader.collapse("#{__dir__}/gems/pending/util/xml")
loader.collapse("#{lib}/gems/pending/util/mount")
loader.collapse("#{lib}/gems/pending/util/object_storage")
loader.collapse("#{lib}/gems/pending/util/win32")
loader.collapse("#{lib}/gems/pending/util/xml")

# These files skip zeitwerk and must be required manually
##### TODO: check for requires outside of this gem to these files and util/ in requires
loader.ignore("#{__dir__}/gems/pending/util/miq-extensions.rb") # loader file, no class
loader.ignore("#{__dir__}/gems/pending/util/require_with_logging.rb") # file has no class ;-)
loader.ignore("#{__dir__}/gems/pending/util/xml/miq_nokogiri.rb") # monkey patch, so no class
loader.ignore("#{__dir__}/gems/pending/util/xml/xml_utils.rb") # multiple classes in one file
loader.ignore("#{lib}/gems/pending/util/miq-extensions.rb") # loader file, no class
loader.ignore("#{lib}/gems/pending/util/require_with_logging.rb") # file has no class ;-)
loader.ignore("#{lib}/gems/pending/util/xml/miq_nokogiri.rb") # monkey patch, so no class
loader.ignore("#{lib}/gems/pending/util/xml/xml_utils.rb") # multiple classes in one file

# These inflectors teach zeitwerk our naming convention here
loader.inflector.inflect(
"manageiq" => "ManageIQ",
"version" => "VERSION", # TODO: why is this needed, for_gem is supposed to do this
"version" => "VERSION", # TODO: why is this needed, for_gem_extension is supposed to do this
)

# These inflectors are teaching zeitwerk when we fail at conventions.
Expand Down
2 changes: 1 addition & 1 deletion manageiq-gems-pending.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency "nokogiri", "~> 1.13", ">= 1.13.10"
s.add_runtime_dependency "sys-proctable", "~> 1.2.5"
s.add_runtime_dependency "sys-uname", "~> 1.2.1"
s.add_runtime_dependency "zeitwerk", "~> 2.6"
s.add_runtime_dependency "zeitwerk", "~> 2.6", ">= 2.6.8"

s.add_development_dependency "ftpd", "~> 2.1.0"
s.add_development_dependency "manageiq-style"
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
SimpleCov.start

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'manageiq-gems-pending'
require 'manageiq/gems/pending'

# Initialize the global logger that might be expected
require 'logger'
Expand Down

0 comments on commit e198dbc

Please sign in to comment.