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

Fixes/invalid yield #321

Merged
merged 2 commits into from
Nov 4, 2021
Merged

Fixes/invalid yield #321

merged 2 commits into from
Nov 4, 2021

Conversation

etagwerker
Copy link
Member

Hi there,

This PR fixes #319 because the current syntax does not work with Ruby 3.0

Please check it out.

Thanks!

@@ -27,14 +27,15 @@ def lib_require(base = "", &_block)
# Adds methods x_dir and _x_require for the directory x,
# relative to the metric_fu lib, to the given klass
# @param klass [Class] the klass to add methods for the specified directories
# @param library_dirs [Array] list of directories
Copy link
Member

Choose a reason for hiding this comment

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

@etagwerker I think you can remove this comment line, library_dirs is not a param of this method.

That idiom is no longer supported. I decided to go with a constant.
@etagwerker
Copy link
Member Author

@lubc I just removed that old comment. I thought I was going to need it. In the end I decided to implement the patch with a different approach. 👍

@@ -34,7 +34,7 @@ def lib_require(base = "", &_block)
# ::metrics_require which takes a block of files to require relative to the metrics_dir
def create_dirs(klass)
class << klass
Array(yield).each do |dir|
Copy link
Member

Choose a reason for hiding this comment

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

did it just need a create_dirs(klass, &block) instead maybe?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, I guess that could have worked too. I thought it was a good opportunity to simplify unnecessary indirection...

Choose a reason for hiding this comment

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

I'm not sure anyone cares, but this fix changes semantics. One could, with the old code, override the library_dirs in use without a warning of overriding a constant (likewise for artifact_subdirs, I think). To this fixes credit, it is simpler. I don't know if any of these directories are subject to the whim of the tools metric_fu calls. If they are, then keeping the old semantics seems better.

@etagwerker etagwerker merged commit 1ffbcdf into master Nov 4, 2021
@etagwerker etagwerker deleted the fixes/invalid-yield branch November 4, 2021 01:19
@pedrofurtado
Copy link

@etagwerker @lubc Is this change released in rubygems? 🤝

@lubc
Copy link
Member

lubc commented Jan 9, 2022

@pedrofurtado hey Pedro! I don't think so. I'll talk to my team tomorrow to see if we can release a new version 👍

@pedrofurtado
Copy link

@lubc Thanks a lot!

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.

Ruby 3.0 yield in class syntax warning
5 participants