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

Commits on Jun 9, 2024

  1. Use max_by to determine the maximum value

    This gives the same result, but it's much easier to read what's going
    on.
    ekohl committed Jun 9, 2024
    Configuration menu
    Copy the full SHA
    a3c9b6b View commit details
    Browse the repository at this point in the history
  2. Rewrite facter_version_for_puppet_version for a better style

    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 committed Jun 9, 2024
    Configuration menu
    Copy the full SHA
    c69be0a View commit details
    Browse the repository at this point in the history