From a3c9b6bbf38f6dd241c3f8519c9cdb33c7945db8 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Sun, 9 Jun 2024 20:06:09 +0200 Subject: [PATCH] Use max_by to determine the maximum value This gives the same result, but it's much easier to read what's going on. --- lib/rspec-puppet-facts.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rspec-puppet-facts.rb b/lib/rspec-puppet-facts.rb index 6577fb6..5f5a4d2 100644 --- a/lib/rspec-puppet-facts.rb +++ b/lib/rspec-puppet-facts.rb @@ -412,7 +412,7 @@ def self.facter_version_for_puppet_version(puppet_version) return Facter.version end - applicable_versions.sort { |a, b| b.first <=> a.first }.first.last + applicable_versions.max_by { |p, _| p }.last rescue JSON::ParserError warning "#{json_path} contains invalid JSON, defaulting to Facter #{Facter.version}" Facter.version