-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Generate repo #200
Generate repo #200
Conversation
By adding new templates for un-nested operations
This reverts commit a5bd2f3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks great!
If you could take care of switching from pluralised to singularised names, then we can get this in!
normalized_name = if name.end_with?("_repo") | ||
name | ||
else | ||
"#{inflector.pluralize(name)}_repo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the idea of us providing the combination of convenience and guard rails through our arg handling!
"#{inflector.pluralize(name)}_repo" | |
"#{inflector.singularize(name)}_repo" |
Just one adjustment though: repos are actually named singularly, so BookRepo
, not BooksRepo
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, duh! Fixed
else | ||
"#{inflector.pluralize(name)}_repo" | ||
end | ||
slice = inflector.underscore(Shellwords.shellescape(slice)) if slice |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, I don't think we need to shellescape this slice arg at all. We're checking for the presence of the slice dir via our generators anyway, so that's validation enough for the slice name.
In #201 I removed the shellescaping, and I reckon we could just do the same here too.
Builds on work done in #199. This is where those refactors pay off: this almost trivial PR to add a repo generator.
I decided to add some logic for
pluralization(update:) singularization:hanami g repo book
=> BookRepohanami g repo books
=> BookRepohanami g repo books_repo
=> BooksRepohanami g repo book_repo
=> BookRepoThe idea here is that we want to guide people to naming things with our convention, but if they end their name with _repo then we assume they're doing it intentionally and want that exact name, without any singularization.
Closes #189