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

Rewrite facter_version_for_puppet_version for a better style #183

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ekohl
Copy link
Member

@ekohl ekohl commented Jun 9, 2024

This rewrites the code to be easier to follow.

First of all, JSON is parsed and all error handling is local. Using a self closing block avoids having to close a file descriptor and exception handling near the actual code helps understanding.

Then it uses filter_map that Ruby 2.7 introduced to avoid calling .map.compact. It also moves the selection of applicable versions into the mapping.

Includes #181.

ekohl added 2 commits June 9, 2024 20:06
This gives the same result, but it's much easier to read what's going
on.
This rewrites the code to be easier to follow.

First of all, JSON is parsed and all error handling is local. Using a
self closing block avoids having to close a file descriptor and
exception handling near the actual code helps understanding.

Then it uses filter_map that Ruby 2.7 introduced to avoid calling
.map.compact. It also moves the selection of applicable versions into
the mapping.
@ekohl ekohl mentioned this pull request Jun 9, 2024
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.

1 participant