Module: Cask::Caskroom Private
- Defined in:
- Library/Homebrew/cask/caskroom.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Helper functions for interacting with the Caskroom
directory.
Class Method Summary collapse
-
.casks(config: nil) ⇒ Object
private
-
.ensure_caskroom_exists ⇒ Object
private
-
.path ⇒ Object
private
Class Method Details
.casks(config: nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'Library/Homebrew/cask/caskroom.rb', line 33 def casks(config: nil) return [] unless path.exist? Pathname.glob(path.join("*")).sort.select(&:directory?).map do |path| token = path.basename.to_s if tap_path = CaskLoader.tap_paths(token).first CaskLoader::FromTapPathLoader.new(tap_path).load(config: config) elsif caskroom_path = Pathname.glob(path.join(".metadata/*/*/*/*.rb")).first CaskLoader::FromPathLoader.new(caskroom_path).load(config: config) else CaskLoader.load(token, config: config) end end end |
.ensure_caskroom_exists ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'Library/Homebrew/cask/caskroom.rb', line 17 def ensure_caskroom_exists return if path.exist? sudo = !path.parent.writable? if sudo && !ENV.key?("SUDO_ASKPASS") && $stdout.tty? ohai "Creating Caskroom at #{path}" ohai "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 ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'Library/Homebrew/cask/caskroom.rb', line 13 def path @path ||= HOMEBREW_PREFIX.join("Caskroom") end |