Skip to content

Commit

Permalink
Cleanup sort_by
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin-Fernbaugh committed Dec 14, 2023
1 parent 2f28fa1 commit a6c87e0
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ module Helpers

def installed_postgresql_major_version
pgsql_package = node['packages'].filter { |p| p.match?(/^postgresql-?(\d+)?$/) }
pgsql_package = pgsql_package.sort_by do |key, _values|
version_match = key.match(/^postgresql(\d+)/)
version_match ? version_match[1].to_i : 0
end.to_h
pgsql_package = pgsql_package.sort_by { |key, _values| key[1].to_i }.to_h

raise 'Unable to determine installed PostgreSQL version' if nil_or_empty?(pgsql_package)

Expand All @@ -47,10 +44,7 @@ def installed_postgresql_major_version

def installed_postgresql_package_source
pgsql_package = node['packages'].filter { |p| p.match?(/^postgresql-?(\d+)?$/) }
pgsql_package = pgsql_package.sort_by do |key, _values|
version_match = key.match(/^postgresql(\d+)/)
version_match ? version_match[1].to_i : 0
end.reverse.to_h
pgsql_package = pgsql_package.sort_by { |key, _values| key[1].to_i }.to_h

raise 'Unable to determine installed PostgreSQL version' if nil_or_empty?(pgsql_package)

Expand Down

0 comments on commit a6c87e0

Please sign in to comment.