aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/tap.rb
diff options
context:
space:
mode:
authorXu Cheng2016-02-15 22:31:47 +0800
committerXu Cheng2016-02-16 14:23:39 +0800
commit4e51c0b8ea371d15d2ae996700e1c988e79cab17 (patch)
treeee0cf40d3a6b095ac33c126e0095b601fe678ba9 /Library/Homebrew/tap.rb
parent578e68b2c1cda6af408ca04ed69877de15198b04 (diff)
downloadbrew-4e51c0b8ea371d15d2ae996700e1c988e79cab17.tar.bz2
add Tap#formula_file?
Return true if given path would present a Formula file in this Tap. Accepts both absolute path and relative path (relative to this Tap's path) It offer an abstraction such that caller would not need to worry about low level file system in the tap. It will be used in `brew pull` and `brew update`. Closes Homebrew/homebrew#49191. Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library/Homebrew/tap.rb')
-rw-r--r--Library/Homebrew/tap.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb
index 712348d60..08e85688d 100644
--- a/Library/Homebrew/tap.rb
+++ b/Library/Homebrew/tap.rb
@@ -247,6 +247,15 @@ class Tap
end
end
+ # return true if given path would present a {Formula} file in this {Tap}.
+ # accepts both absolute path and relative path (relative to this {Tap}'s path)
+ # @private
+ def formula_file?(file)
+ file = Pathname.new(file) unless file.is_a? Pathname
+ file = file.expand_path(path)
+ file.extname == ".rb" && file.parent == formula_dir
+ end
+
# an array of all {Formula} names of this {Tap}.
def formula_names
@formula_names ||= formula_files.map { |f| formula_file_to_name(f) }