aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib/hbc/scopes.rb
diff options
context:
space:
mode:
authorMike McQuaid2016-09-24 20:48:03 +0100
committerMike McQuaid2016-09-24 20:48:03 +0100
commite767fd3df9d179fca0445cc0bc0fdc061ad857d6 (patch)
tree93e9db33313b36eebe7d7fb3aedf0f92cc2c3918 /Library/Homebrew/cask/lib/hbc/scopes.rb
parent7fc241765e3654718235791c32e5638bf7f8e15a (diff)
parent232078df57418004bb9bf7abef877e734fcf7005 (diff)
downloadbrew-e767fd3df9d179fca0445cc0bc0fdc061ad857d6.tar.bz2
Merge branch 'master' into mkdir_with_intermediates
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc/scopes.rb')
-rw-r--r--Library/Homebrew/cask/lib/hbc/scopes.rb74
1 files changed, 38 insertions, 36 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/scopes.rb b/Library/Homebrew/cask/lib/hbc/scopes.rb
index 431c3ff47..8520028c9 100644
--- a/Library/Homebrew/cask/lib/hbc/scopes.rb
+++ b/Library/Homebrew/cask/lib/hbc/scopes.rb
@@ -1,45 +1,47 @@
-module Hbc::Scopes
- def self.included(base)
- base.extend(ClassMethods)
- end
-
- module ClassMethods
- def all
- @all_casks ||= {}
- all_tokens.map { |t| @all_casks[t] ||= load(t) }
+module Hbc
+ module Scopes
+ def self.included(base)
+ base.extend(ClassMethods)
end
- def all_tapped_cask_dirs
- Tap.map(&:cask_dir).compact
- end
+ module ClassMethods
+ def all
+ @all_casks ||= {}
+ all_tokens.map { |t| @all_casks[t] ||= load(t) }
+ end
- def all_tokens
- Tap.map { |t|
- t.cask_files.map { |p|
- "#{t.name}/#{File.basename(p, ".rb")}"
- }
- }.flatten
- end
+ def all_tapped_cask_dirs
+ Tap.map(&:cask_dir).compact
+ end
- def installed
- # Hbc.load has some DWIM which is slow. Optimize here
- # by spoon-feeding Hbc.load fully-qualified paths.
- # TODO: speed up Hbc::Source::Tapped (main perf drag is calling Hbc.all_tokens repeatedly)
- # TODO: ability to specify expected source when calling Hbc.load (minor perf benefit)
- Pathname.glob(caskroom.join("*"))
- .map { |caskroom_path|
- token = caskroom_path.basename.to_s
+ def all_tokens
+ Tap.map { |t|
+ t.cask_files.map { |p|
+ "#{t.name}/#{File.basename(p, ".rb")}"
+ }
+ }.flatten
+ end
- path_to_cask = all_tapped_cask_dirs.find { |tap_dir|
- tap_dir.join("#{token}.rb").exist?
- }
+ def installed
+ # Hbc.load has some DWIM which is slow. Optimize here
+ # by spoon-feeding Hbc.load fully-qualified paths.
+ # TODO: speed up Hbc::Source::Tapped (main perf drag is calling Hbc.all_tokens repeatedly)
+ # TODO: ability to specify expected source when calling Hbc.load (minor perf benefit)
+ Pathname.glob(caskroom.join("*"))
+ .map { |caskroom_path|
+ token = caskroom_path.basename.to_s
+
+ path_to_cask = all_tapped_cask_dirs.find { |tap_dir|
+ tap_dir.join("#{token}.rb").exist?
+ }
- if path_to_cask
- Hbc.load(path_to_cask.join("#{token}.rb"))
- else
- Hbc.load(token)
- end
- }
+ if path_to_cask
+ Hbc.load(path_to_cask.join("#{token}.rb"))
+ else
+ Hbc.load(token)
+ end
+ }
+ end
end
end
end