aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/tap.rb
diff options
context:
space:
mode:
authorMarkus Reiter2016-08-25 05:19:14 +0200
committerMarkus Reiter2016-09-05 21:43:03 +0200
commit89a63fb1778dbfd4140a774c32dededf5b2a4585 (patch)
treeab388940a1833598d79696ba98a6e5bb74c0a5f0 /Library/Homebrew/tap.rb
parent7820489831b049a2fc6fd4ef0c5964e63e78f778 (diff)
downloadbrew-89a63fb1778dbfd4140a774c32dededf5b2a4585.tar.bz2
Add `cask_files` method to `Tap` class.
Diffstat (limited to 'Library/Homebrew/tap.rb')
-rw-r--r--Library/Homebrew/tap.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb
index 8dd7fd155..340f6eca3 100644
--- a/Library/Homebrew/tap.rb
+++ b/Library/Homebrew/tap.rb
@@ -290,13 +290,22 @@ class Tap
# path to the directory of all {Cask} files for this {Tap}.
def cask_dir
- @cask_dir ||= path/"Casks"
+ @cask_dir ||= [path/"Casks"].detect(&:directory?)
end
# an array of all {Formula} files of this {Tap}.
def formula_files
@formula_files ||= if formula_dir
- formula_dir.children.select { |p| p.extname == ".rb" }
+ formula_dir.children.select(&method(:formula_file?))
+ else
+ []
+ end
+ end
+
+ # an array of all {Cask} files of this {Tap}.
+ def cask_files
+ @cask_files ||= if cask_dir
+ cask_dir.children.select(&method(:cask_file?))
else
[]
end
@@ -311,7 +320,7 @@ class Tap
file.extname == ".rb" && file.parent == formula_dir
end
- # return true if given path would present a cask file in this {Tap}.
+ # return true if given path would present a {Cask} file in this {Tap}.
# accepts both absolute path and relative path (relative to this {Tap}'s path)
# @private
def cask_file?(file)