From 270d8882973805fded0f67e4b7a627ff5c1eae9c Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 14 Apr 2018 10:28:28 +0200 Subject: [PATCH] Make `Cask` `enumerable. --- Library/Homebrew/cask/lib/hbc/cask.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc/cask.rb b/Library/Homebrew/cask/lib/hbc/cask.rb index 681130c1b1..341f80047f 100644 --- a/Library/Homebrew/cask/lib/hbc/cask.rb +++ b/Library/Homebrew/cask/lib/hbc/cask.rb @@ -3,11 +3,20 @@ require "hbc/metadata" module Hbc class Cask + extend Enumerable extend Forwardable include Metadata attr_reader :token, :sourcefile_path, :config + def self.each + return to_enum unless block_given? + + Tap.flat_map(&:cask_files).each do |f| + yield CaskLoader::FromTapPathLoader.new(f).load + end + end + def tap return super if block_given? # Object#tap @tap @@ -43,10 +52,10 @@ module Hbc end def full_name - if @tap.nil? || @tap == Hbc.default_tap + if tap.nil? || tap == Hbc.default_tap token else - "#{@tap}/#{token}" + "#{tap.name}/#{token}" end end