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

Comply with Zeitwerk autoloader #3465

Merged
merged 20 commits into from
Mar 11, 2022
Merged

Comply with Zeitwerk autoloader #3465

merged 20 commits into from
Mar 11, 2022

Conversation

parndt
Copy link
Member

@parndt parndt commented Jan 13, 2020

Context

For full Zeitwerk support, we require all gems that currently depend on
something in Refinery by requiring the gem's name to update the require
to a path inside the gem.

For example, if a gem had:

require 'refinerycms-pages'

This has to change to:

require 'refinery/pages'

Not a huge code change, but needs to be done everywhere.

Changes

Applies the above suggestion to code that lives inside this repository.

Considerations

One issue is that this kind of violates the namespace expectation of a
gem called refinerycms-core, which should have lib/refinerycms/core.rb.

Perhaps this is worth a lot of consideration as an alternative.

Resolves #3464

This is a breaking change, it requires all gems that currently depend on
something in Refinery by requiring the gem's name to update the require
to a path inside the gem.

For example, if a gem had:

    require 'refinerycms-pages'

This has to change to:

    require 'refinery/pages'

Not a huge change, but needs to be done everywhere.
@parndt parndt requested a review from bricesanchez January 13, 2020 21:32
@parndt parndt changed the title Remove refinerycms-*.rb files to comply with zeitwerk Remove refinerycms-*.rb files to comply with Zeitwerk Jan 13, 2020
@@ -1,7 +1,7 @@
require 'thor'

module Refinery
class CLI < Thor
Copy link
Member Author

Choose a reason for hiding this comment

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

perhaps it should live inside Core too?

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 we could leave it here until we rewrite it

bricesanchez
bricesanchez previously approved these changes Jan 14, 2020
in order to comply with Zeitwerk loader conventions
@bricesanchez bricesanchez self-requested a review January 14, 2020 03:09
@bricesanchez bricesanchez dismissed their stale review January 14, 2020 03:10

External gems like refinerycms-wymeditor does not load anymore

bricesanchez
bricesanchez previously approved these changes Jan 14, 2020
Gemfile Outdated
@@ -15,10 +15,10 @@ gem 'listen'
gem 'activejob'

# Add support for refinerycms-acts-as-indexed
gem 'refinerycms-acts-as-indexed', ['~> 3.0', '>= 3.0.0']
gem 'refinerycms-acts-as-indexed', ['~> 3.0', '>= 3.0.0'], require: 'refinery/acts_as_indexed'
Copy link
Member Author

Choose a reason for hiding this comment

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

still wishing there is a way we can get this without the require. In this case I guess the gem should be called refinerycms-acts_as_indexed

Copy link
Member

Choose a reason for hiding this comment

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

It could help but there will always be a problem on the cms part

Copy link
Member Author

Choose a reason for hiding this comment

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

not if it's lib/refinerycms/acts_as_indexed.rb

Maybe for now we can use lib/refinerycms/acts/as/indexed.rb? Haven't tried it yet

@parndt
Copy link
Member Author

parndt commented Jan 28, 2020

@bricesanchez not exactly a monkey patch, we're just defining our own inflector right?

@parndt parndt changed the title Remove refinerycms-*.rb files to comply with Zeitwerk Comply with Zeitwerk autoloader Jan 28, 2020
@parndt parndt dismissed bricesanchez’s stale review January 28, 2020 05:33

let's revisit as approach has changed

Gemfile Outdated Show resolved Hide resolved
@RandieM
Copy link
Contributor

RandieM commented Nov 18, 2021

This seems to be almost done. It would be nice to see it merged.

@parndt
Copy link
Member Author

parndt commented Nov 18, 2021

Does it work for you @RandieM ?

@RandieM
Copy link
Contributor

RandieM commented Dec 9, 2021

Does it work for you @RandieM ?

Sorry for the late reply. The error is gone and the website seems to work without issues. Let me know if you'd like me to test something more specific.

Gemfile Outdated Show resolved Hide resolved
@parndt
Copy link
Member Author

parndt commented Feb 8, 2022

@RandieM thanks 😄

@parndt parndt enabled auto-merge (squash) March 11, 2022 00:16
@parndt parndt merged commit 6ec054d into master Mar 11, 2022
@parndt parndt deleted the zeitwerk branch March 11, 2022 00:24
parndt added a commit to refinery/refinerycms-i18n that referenced this pull request Mar 11, 2022
This adds Zeitwerk support like refinery/refinerycms#3465

Co-authored-by: Brice Sanchez <bricesanchez@users.noreply.github.com>
require 'refinerycms-core'
require 'refinerycms-dragonfly'
require 'refinerycms/core'
require 'refinerycms/dragonfly'
Copy link

Choose a reason for hiding this comment

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

Shouldn't this be 'refinery/dragonfly' then? I still get " cannot load such file -- refinerycms/dragonfly (LoadError)" as I try to upgrade to rails 6

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

Successfully merging this pull request may close these issues.

4 participants