diff --git a/Library/Homebrew/cask/cask.rb b/Library/Homebrew/cask/cask.rb index c04105c18a269cbf20dcdff7597537235314fd64..54a43bf4253c4c4b1828ea15de0c5cad8490c767 100644 --- a/Library/Homebrew/cask/cask.rb +++ b/Library/Homebrew/cask/cask.rb @@ -18,11 +18,11 @@ module Cask attr_reader :token, :sourcefile_path, :config - def self.each + def self.each(&block) return to_enum unless block_given? Tap.flat_map(&:cask_files).each do |f| - yield CaskLoader::FromTapPathLoader.new(f).load + block.call CaskLoader::FromTapPathLoader.new(f).load rescue CaskUnreadableError => e opoo e.message end diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb index a4ed78a7803a3261dbd8a51f24f617c7c89b7dec..e2367a0c11b63651268a6de83182ceb059e26e24 100644 --- a/Library/Homebrew/extend/ENV/shared.rb +++ b/Library/Homebrew/extend/ENV/shared.rb @@ -166,10 +166,12 @@ module SharedEnvExtension # end</pre> def compiler @compiler ||= if (cc = @cc) - warn_about_non_apple_gcc($&) if cc =~ GNU_GCC_REGEXP + warn_about_non_apple_gcc(cc) if cc.match?(GNU_GCC_REGEXP) + fetch_compiler(cc, "--cc") elsif (cc = homebrew_cc) - warn_about_non_apple_gcc($&) if cc =~ GNU_GCC_REGEXP + warn_about_non_apple_gcc(cc) if cc.match?(GNU_GCC_REGEXP) + compiler = fetch_compiler(cc, "HOMEBREW_CC") if @formula diff --git a/Library/Homebrew/extend/ENV/std.rb b/Library/Homebrew/extend/ENV/std.rb index 70e76567373951b6a5faf458cfc960062f3da1d8..8afbc139742ff6878da71c79b9b9dabe64928e80 100644 --- a/Library/Homebrew/extend/ENV/std.rb +++ b/Library/Homebrew/extend/ENV/std.rb @@ -46,9 +46,9 @@ module Stdenv send(compiler) - return unless cc =~ GNU_GCC_REGEXP + return unless cc.match?(GNU_GCC_REGEXP) - gcc_formula = gcc_version_formula($&) + gcc_formula = gcc_version_formula(cc) append_path "PATH", gcc_formula.opt_bin.to_s end alias generic_setup_build_environment setup_build_environment diff --git a/Library/Homebrew/extend/ENV/super.rb b/Library/Homebrew/extend/ENV/super.rb index ba3015a62fabd302b998a7c77bd0f1080db6752c..4bbe7e054be10ba9ef9a3f3f197ca84327518da0 100644 --- a/Library/Homebrew/extend/ENV/super.rb +++ b/Library/Homebrew/extend/ENV/super.rb @@ -111,7 +111,7 @@ module Superenv path.append("/usr/bin", "/bin", "/usr/sbin", "/sbin") begin - path.append(gcc_version_formula($&).opt_bin) if homebrew_cc =~ GNU_GCC_REGEXP + path.append(gcc_version_formula(homebrew_cc).opt_bin) if homebrew_cc.match?(GNU_GCC_REGEXP) rescue FormulaUnavailableError # Don't fail and don't add these formulae to the path if they don't exist. nil diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index e89ed81e6d8c6a3625fb58f7c80ae0915dedf999..3551fc1b8b44b4327ffcb27d2bfa29a8146ed6d6 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1459,9 +1459,9 @@ class Formula end # @private - def self.each + def self.each(&block) files.each do |file| - yield Formulary.factory(file) + block.call Formulary.factory(file) rescue FormulaUnavailableError, FormulaUnreadableError => e # Don't let one broken formula break commands. But do complain. onoe "Failed to import: #{file}" diff --git a/Library/Homebrew/sorbet/rbi/utils/inreplace.rbi b/Library/Homebrew/sorbet/rbi/utils/inreplace.rbi index 6c9bfb5b3e28e2fa20938b86041ab646f8898ef9..b6d0be9a5a86b1e3ef905111a4f774fcd589dd77 100644 --- a/Library/Homebrew/sorbet/rbi/utils/inreplace.rbi +++ b/Library/Homebrew/sorbet/rbi/utils/inreplace.rbi @@ -3,9 +3,8 @@ module Utils::Inreplace include Kernel - sig { params(paths: T::Array[T.untyped], before: T.nilable(String), after: T.nilable(String), audit_result: T::Boolean).void } + sig { params(paths: T::Array[T.untyped], before: T.nilable(String), after: T.nilable(T.any(String, Symbol)), audit_result: T::Boolean).void } def inreplace(paths, before = nil, after = nil, audit_result = true); end - end class StringInreplaceExtension diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 663fc28b9c655beb71f48f4a343e8b9afb509b41..d6cc29ceb60f85a51f657ffa344656681dda07fc 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -552,14 +552,14 @@ class Tap self.class == other.class && name == other.name end - def self.each + def self.each(&block) return unless TAP_DIRECTORY.directory? return to_enum unless block_given? TAP_DIRECTORY.subdirs.each do |user| user.subdirs.each do |repo| - yield fetch(user.basename.to_s, repo.basename.to_s) + block.call fetch(user.basename.to_s, repo.basename.to_s) end end end diff --git a/Library/Homebrew/utils/inreplace.rb b/Library/Homebrew/utils/inreplace.rb index 8367b9c3ffd76e85764d8243acb360d3880b1618..ae3489b6c8b75b676bd2af6035b3f21cf1ccf5ad 100644 --- a/Library/Homebrew/utils/inreplace.rb +++ b/Library/Homebrew/utils/inreplace.rb @@ -28,6 +28,8 @@ module Utils # # @api public def inreplace(paths, before = nil, after = nil, audit_result = true) # rubocop:disable Style/OptionalBooleanParameter + after = after.to_s if after.is_a? Symbol + errors = {} errors["`paths` (first) parameter"] = ["`paths` was empty"] if paths.blank? @@ -39,7 +41,6 @@ module Utils if before.nil? && after.nil? yield s else - after = after.to_s if after.is_a? Symbol s.gsub!(before, after, audit_result) end