diff --git a/Library/Homebrew/cask/cask.rb b/Library/Homebrew/cask/cask.rb index c04105c18a269..54a43bf4253c4 100644 --- a/Library/Homebrew/cask/cask.rb +++ b/Library/Homebrew/cask/cask.rb @@ -18,11 +18,11 @@ class 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/formula.rb b/Library/Homebrew/formula.rb index e89ed81e6d8c6..3551fc1b8b44b 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1459,9 +1459,9 @@ def self.full_names 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/tap.rb b/Library/Homebrew/tap.rb index 663fc28b9c655..d6cc29ceb60f8 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -552,14 +552,14 @@ def ==(other) 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