Skip to content

Rewrite facter_version_for_puppet_version for a better style - #183

Open
ekohl wants to merge 2 commits into
voxpupuli:masterfrom
ekohl:rewrite-style
Open

Rewrite facter_version_for_puppet_version for a better style#183
ekohl wants to merge 2 commits into
voxpupuli:masterfrom
ekohl:rewrite-style

Conversation

@ekohl

@ekohl ekohl commented Jun 9, 2024

Copy link
Copy Markdown
Member

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