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

Add helper method underscore #307

Merged
merged 1 commit into from May 10, 2021
Merged

Conversation

vinistock
Copy link
Member

Closes #286

Motivation

We can't depend on active_support being available, so I moved our spec implementation of underscore into a helper method so that we can use it in projects that do not include active_support.

I considered adding it as a core extension to string, but I'm not a fan of that approach as it could potentially lead to mistakes. For example, a project including Tapioca could use underscore in String during development and it would work fine, but then would break outside of a development environment, where Tapioca is not included. This is why I made it a class method.

Implementation

Move the implementation of underscore into a helper class method inside Generator. Please, let me know if we have a better place for utilities such as this one.

Tests

This is a refactor. Existing tests already cover it.

@vinistock vinistock requested a review from a team May 10, 2021 14:13
Copy link
Member

@paracycle paracycle left a comment

Choose a reason for hiding this comment

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

We will also need a similar treatment for constantize or we need to replace it with const_get instead.

lib/tapioca/generator.rb Outdated Show resolved Hide resolved
@vinistock vinistock force-pushed the add_helper_method_underscore branch from 9eadc2e to 124b164 Compare May 10, 2021 15:26
spec/dsl_spec.rb Show resolved Hide resolved
@vinistock vinistock force-pushed the add_helper_method_underscore branch from 124b164 to e26845b Compare May 10, 2021 17:15
@vinistock vinistock merged commit 23bea77 into master May 10, 2021
@vinistock vinistock deleted the add_helper_method_underscore branch May 10, 2021 17:22
@shopify-shipit shopify-shipit bot temporarily deployed to production May 19, 2021 17:37 Inactive
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.

Tapioca assumes ActiveSupport string core extensions are present
3 participants