From a1111396823989cf31c4211acd3d472b4ee01ce8 Mon Sep 17 00:00:00 2001 From: thibhero Date: Tue, 11 Feb 2025 11:06:16 -0500 Subject: [PATCH] moving to lambda expressions to respect `brew style` --- Library/Homebrew/cmd/reinstall.rb | 12 ++++++------ Library/Homebrew/cmd/upgrade.rb | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb index 14bdaf57e2..d336233313 100644 --- a/Library/Homebrew/cmd/reinstall.rb +++ b/Library/Homebrew/cmd/reinstall.rb @@ -152,7 +152,7 @@ module Homebrew # 1. The original formulae to install. # 2. Their outdated dependents (subject to pruning criteria). # 3. Optionally, any installed formula that depends on one of these and is outdated. - def compute_sized_formulae(formulae_to_install, check_dep: true) + compute_sized_formulae = lambda { |formulae_to_install, check_dep: true| sized_formulae = formulae_to_install.flat_map do |formula| # Always include the formula itself. formula_list = [formula] @@ -184,10 +184,10 @@ module Homebrew # Uniquify based on a string representation (or any unique identifier) sized_formulae.uniq { |f| f.to_s } - end + } # Compute the total sizes (download, installed, and net) for the given formulae. - def compute_total_sizes(sized_formulae, debug: false) + compute_total_sizes = lambda { |sized_formulae, debug: false| total_download_size = 0 total_installed_size = 0 total_net_size = 0 @@ -213,15 +213,15 @@ module Homebrew { download: total_download_size, installed: total_installed_size, net: total_net_size } - end + } # Main block: if asking the user is enabled, show dependency and size information. # This part should be if args.ask? ohai "Looking for bottles..." - sized_formulae = compute_sized_formulae(formulae, check_dep: false) - sizes = compute_total_sizes(sized_formulae, debug: args.debug?) + sized_formulae = compute_sized_formulae.call(formulae, check_dep: false) + sizes = compute_total_sizes.call(sized_formulae, debug: args.debug?) puts "Formulae: #{sized_formulae.join(", ")}\n\n" puts "Download Size: #{disk_usage_readable(sizes[:download])}" diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index a6e5454d0e..54893ad18a 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -242,7 +242,7 @@ module Homebrew # 1. The original formulae to install. # 2. Their outdated dependents (subject to pruning criteria). # 3. Optionally, any installed formula that depends on one of these and is outdated. - def compute_sized_formulae(formulae_to_install, check_dep: true) + compute_sized_formulae = lambda { |formulae_to_install, check_dep: true| sized_formulae = formulae_to_install.flat_map do |formula| # Always include the formula itself. formula_list = [formula] @@ -274,10 +274,10 @@ module Homebrew # Uniquify based on a string representation (or any unique identifier) sized_formulae.uniq { |f| f.to_s } - end + } # Compute the total sizes (download, installed, and net) for the given formulae. - def compute_total_sizes(sized_formulae, debug: false) + compute_total_sizes = lambda { |sized_formulae, debug: false| total_download_size = 0 total_installed_size = 0 total_net_size = 0 @@ -303,7 +303,7 @@ module Homebrew { download: total_download_size, installed: total_installed_size, net: total_net_size } - end + } # Main block: if asking the user is enabled, show dependency and size information. # This part should be