Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoload with Zeitwerk #19

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Autoload with Zeitwerk #19

wants to merge 1 commit into from

Conversation

amomchilov
Copy link

Constantly restarting your debugger to make your changes take effect is a total pain.

This PR tries to apply Zeitwerk to autoload constants and live reload files as they change (not yet working). I only do it to open.rb, and not other commands like start.rb.

if defined?(SESSION)
# puts("const_defined? #{ DEBUGGER__.const_defined?(:SESSION)}, defined? #{defined?(SESSION)}")
# if defined?(SESSION)
if DEBUGGER__.const_defined?(:SESSION)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand why, but defined?(SESSION) and DEBUGGER__.const_defined?(:SESSION) behave differently.

Without changing this, the if was being entered, SESSION was attempted to be loaded, and then not found because it's defined dynamically.

@@ -29,4 +29,5 @@ Gem::Specification.new do |spec|

spec.add_dependency "irb", ">= 1.5.0" # for binding.irb(show_code: false)
spec.add_dependency "reline", ">= 0.3.1"
spec.add_development_dependency "zeitwerk", "~> 2.6.9"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imma be real, I have no idea what the difference is between this, and gemspec.add_development_dependency 🫥

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it just depends on how the variable from Gem::Specification.new do |spec| is named. In most cases it seems to be named spec?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants