Module: Cask::Caskroom Private
- Defined in:
- cask/caskroom.rb
Overview
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Helper functions for interacting with the Caskroom
directory.
Class Method Summary collapse
-
.any_casks_installed? ⇒ Boolean
private
-
.casks(config: nil) ⇒ Array<Cask>
private
-
.ensure_caskroom_exists ⇒ void
private
-
.path ⇒ Pathname
private
Class Method Details
.any_casks_installed? ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
26 27 28 |
# File 'cask/caskroom.rb', line 26 def self.any_casks_installed? paths.any? end |
.casks(config: nil) ⇒ Array<Cask>
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'cask/caskroom.rb', line 48 def self.casks(config: nil) paths.sort.map do |path| token = path.basename.to_s begin CaskLoader.load(token, config: config) rescue TapCaskAmbiguityError tap_path = CaskLoader.tap_paths(token).first CaskLoader::FromTapPathLoader.new(tap_path).load(config: config) rescue CaskUnavailableError # Don't blow up because of a single unavailable cask. nil end end.compact end |
.ensure_caskroom_exists ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'cask/caskroom.rb', line 31 def self.ensure_caskroom_exists return if path.exist? sudo = !path.parent.writable? if sudo && !ENV.key?("SUDO_ASKPASS") && $stdout.tty? ohai "Creating Caskroom directory: #{path}", "We'll set permissions properly so we won't need sudo in the future." end SystemCommand.run("/bin/mkdir", args: ["-p", path], sudo: sudo) SystemCommand.run("/bin/chmod", args: ["g+rwx", path], sudo: sudo) SystemCommand.run("/usr/sbin/chown", args: [User.current, path], sudo: sudo) SystemCommand.run("/usr/bin/chgrp", args: ["admin", path], sudo: sudo) end |
.path ⇒ Pathname
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
12 13 14 |
# File 'cask/caskroom.rb', line 12 def self.path @path ||= HOMEBREW_PREFIX/"Caskroom" end |