Skip to content

Convert slice generator to use ruby class file #297

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

Open
wants to merge 39 commits into
base: main
Choose a base branch
from

Conversation

cllns
Copy link
Member

@cllns cllns commented Apr 25, 2025

A number of refactors here too:

  • We needed a Module file so I had to create RubyModuleFile. I first copied it from RubyClassFile, but realized I could share almost all of the code. I did this via a super class called RubyFile, so now RubyClassFile and RubyModuleFile are just thin subclasses with their specific behavior. Open to other approaches here. I considered just assuming everything is a class file, then having a module: boolean arg with different behavior, since we rarely ever need to generate modules.
  • I removed fully_qualified_parent and partially_qualified_parent (from Refactor RubyClassFile, remove RubyFileWriter #296) and standardized them as (fully qualified) parent_class_name. This involves a bit more code from consumers (manually creating the string of the parent class name) but it seems worth providing a simpler API and implementation.
  • I was able to get rid of all ERB from Slice generator. The only remaining thing that makes some sense to have as ERB is the layout file, as that ends up as an ERB file in the end. But it was easy enough to inline with a heredoc (and simpler to not use ERB to generate ERB).

cllns added 30 commits April 18, 2025 16:03
Without the leading strings, sometimes the slice starts with a number
which is not a valid leading character in a Ruby constant
  Just copied and modified from RubyClassFile. Need to refactor later
Also added logic to only generate it if dry-operation is bundled
Also refactored Hanami::CLI::Files private method dir_path (from _path)
since it wasn't clear to me why we'd used one or the other, and it just adds
a trailing file separator so this is a better name.
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.

1 participant