Amber: Controller generator is not great with multi-word names

Created on 19 Oct 2017  路  7Comments  路  Source: amberframework/amber

Description

The generator for controllers has trouble with multi-word names. Creating a multi-word controller name results in incorrect file names or incorrect class names, depending on the name you pass.

Steps to Reproduce

Test case 1: amber g controller PostComments
Test case 2: amber g controller post_comments

Expected behavior:

  • I see a file called post_comments_controller_spec.cr was created.
  • I see a file called post_comments_controller.cr was created.
  • Both the spec and the controller use the class name PostCommentsController

Actual behavior: [What actually happens]

Test case 1:

  • class name is PostcommentsController
  • file names are postcomments_controller, rather than an underscore between the words.

Test case 2:

  • class name is Post_commentsController
  • file names are correct!

Reproduces how often:

Always

Versions

0.3.0

enhancement good-first-issue

Most helpful comment

@eliasjpr not a problem! I would love to help out.

All 7 comments

After looking further, this seems to be pretty generic as to how all file names and class names are created. I'm seeing the same issue when generating models as well.

Perhaps the generators should have a shared piece of logic for taken a user-given name and discerning its CamelCase and snake_case names.

@aarongodin How do you feel about opening a PR addressing this issue? 馃槃 We welcome the help.

@eliasjpr not a problem! I would love to help out.

@aarongodin - If you don't object, I would like to take a shot at this.

PR: https://github.com/amberframework/amber/pull/330

@marksiemers Looks nice!

@aarongodin - Is this fixed for you on the master branch? Can we close the issue?

@marksiemers It's fixed from my perspective. Closing!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

faustinoaq picture faustinoaq  路  5Comments

eliasjpr picture eliasjpr  路  6Comments

conradwt picture conradwt  路  3Comments

faustinoaq picture faustinoaq  路  7Comments

blankoworld picture blankoworld  路  7Comments