aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib/hbc/cask_loader.rb
diff options
context:
space:
mode:
authorMarkus Reiter2017-10-07 15:58:49 +0200
committerMarkus Reiter2017-10-07 16:11:25 +0200
commit97333df4cb4bd006401193639400a8bc6df56e3a (patch)
treed04a2c243da0486c4e3248e74f392c6716c8bf88 /Library/Homebrew/cask/lib/hbc/cask_loader.rb
parent113e5da55e630018cba9da19f4d3b268c2e7ee37 (diff)
downloadbrew-97333df4cb4bd006401193639400a8bc6df56e3a.tar.bz2
Add helper method for Cask fixture paths and refactor CaskLoader.
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc/cask_loader.rb')
-rw-r--r--Library/Homebrew/cask/lib/hbc/cask_loader.rb15
1 files changed, 7 insertions, 8 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cask_loader.rb b/Library/Homebrew/cask/lib/hbc/cask_loader.rb
index 8fce9636a..5660992da 100644
--- a/Library/Homebrew/cask/lib/hbc/cask_loader.rb
+++ b/Library/Homebrew/cask/lib/hbc/cask_loader.rb
@@ -147,14 +147,6 @@ module Hbc
end
end
- def self.load_from_file(path)
- FromPathLoader.new(path).load
- end
-
- def self.load_from_string(content)
- FromContentLoader.new(content).load
- end
-
def self.path(ref)
self.for(ref).path
end
@@ -164,6 +156,13 @@ module Hbc
end
def self.for(ref)
+ if ref.respond_to?(:to_str)
+ content = ref.to_str
+ if content.match?(/\A\s*cask\s+(?:"[^"]*"|'[^']*')\s+do(?:\s+.*\s+|;?\s+)end\s*\Z/)
+ return FromContentLoader.new(content)
+ end
+ end
+
[
FromInstanceLoader,
FromURILoader,