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

Change HashDiff Constant to Hashdiff #65

Merged
merged 2 commits into from
May 28, 2019
Merged

Change HashDiff Constant to Hashdiff #65

merged 2 commits into from
May 28, 2019

Conversation

jfelchner
Copy link
Contributor

@jfelchner jfelchner commented May 27, 2019

Why This Change Is Necessary

The name of this gem is hashdiff. There is another gem named
hash_diff. When they are both required via dependencies, errors are
thrown. Additionally since the behavior is different, gems that are
relying on hashdiff's behavior, may get hash_diff's behavior and
vice versa.

The reason for the conflict is because, based on ruby conventions, _'s
are the separators for camel case.

So:

'hashdiff'.camelize # => "Hashdiff"

'hash_diff'.camelize # => "HashDiff"

Unfortunately instead of making the base module of this gem Hashdiff,
it's called HashDiff and it conflicts.

How These Changes Address the Issue

We change all of the constants to the new constant, including in
documentation and tests.

Then we add a shim to allow the old constant to be used and therefore
maintain backward compatibility.

Finally we add a warning message for users of the gem that the old
constant will be removed in the next major version bump.

Side Effects Caused By This Change

A new warning is added when loading the gem.


References:

@jfelchner
Copy link
Contributor Author

Test failures seem to be Rubocop issues that existed before this PR.

@jfelchner jfelchner changed the title Change HashDiff Contant to Hashdiff Change HashDiff Constant to Hashdiff May 27, 2019
@liufengyun
Copy link
Owner

Thanks a lot @jfelchner . WDYT @krzysiek1507 ?

lib/hashdiff.rb Show resolved Hide resolved
changelog.md Outdated Show resolved Hide resolved
@krzysiek1507 krzysiek1507 self-requested a review May 28, 2019 10:44
Why This Change Is Necessary
========================================================================

The name of this gem is `hashdiff`. There is another gem named
`hash_diff`. When they are both required via dependencies, errors are
thrown. Additionally since the behavior is different, gems that are
relying on `hashdiff`'s behavior, may get `hash_diff`'s behavior and
vice versa.

The reason for the conflict is because, based on ruby conventions, _'s
are the separators for camel case.

So:

```ruby
'hashdiff'.camelize # => "Hashdiff"

'hash_diff'.camelize # => "HashDiff"
```

Unfortunately instead of making the base module of this gem `Hashdiff`,
it's called `HashDiff` and it conflicts.

How These Changes Address the Issue
========================================================================

We change all of the constants to the new constant, including in
documentation and tests.

Then we add a shim to allow the old constant to be used and therefore
maintain backward compatibility.

Finally we add a warning message for users of the gem that the old
constant will be removed in the next major version bump.

Side Effects Caused By This Change
========================================================================

A new warning is added when loading the gem.
Why This Change Is Necessary
========================================================================

`require_relative` is error-prone in certain situations, specifically in
Ruby < 2.4 and should never be used for requires inside of gems.

How These Changes Address the Issue
========================================================================

Revert the change from `require` to `require_relative`.

Side Effects Caused By This Change
========================================================================

Fewer bugs.
Copy link

@luke-hill luke-hill left a comment

Choose a reason for hiding this comment

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

Seems legit. Just guess you gotta get it merged in

@jfelchner
Copy link
Contributor Author

@liufengyun just remember this needs to be version 0.4.0.

@liufengyun
Copy link
Owner

Thank a lot @jfelchner 🎉

And thanks for reviewing @krzysiek1507 @luke-hill !

@bquorning
Copy link

@liufengyun Could you please update the GitHub repository description as well?

image

@liufengyun
Copy link
Owner

@bquorning It's changed now, thanks for the catch.

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.

None yet

5 participants