Class: Homebrew::DevCmd::Create Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::DevCmd::Create
- Defined in:
- dev-cmd/create.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/create.rbi
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Defined Under Namespace
Classes: Args
Instance Method Summary collapse
- #args ⇒ Homebrew::DevCmd::Create::Args private
-
#find_app_in(download) ⇒ Array<(Pathname, [Cask::Appcast::Result, nil])>?
private
Unpack the download to find the app it installs, relative to the unpacked download, and that app's appcast.
-
#find_appcast_for(app) ⇒ Cask::Appcast::Result?
private
Scan the app, from the download or an installed copy, for an appcast to prefill the
livecheckblock. -
#generate_zap_for(app) ⇒ String?
private
Scan for files left by an already-installed copy of the app to prefill the
zapstanza. -
#run ⇒ void
private
Create a formula from a tarball URL.
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?
Methods included from Utils::Output::Mixin
#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_once, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_cannot_install, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_removed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning
Constructor Details
This class inherits a constructor from Homebrew::AbstractCommand
Instance Method Details
#args ⇒ Homebrew::DevCmd::Create::Args
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.
10 |
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/create.rbi', line 10 def args; end |
#find_app_in(download) ⇒ Array<(Pathname, [Cask::Appcast::Result, nil])>?
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.
Unpack the download to find the app it installs, relative to the unpacked download, and that app's appcast. This only prefills the template, so don't guess between the apps in a suite and warn rather than fail if the download can't be unpacked.
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'dev-cmd/create.rb', line 197 def find_app_in(download) Dir.mktmpdir("brew-create", HOMEBREW_TEMP) do |dir| unpack_dir = Pathname(dir) UnpackStrategy.detect(download, merge_xattrs: true).extract_nestedly(to: unpack_dir) shallowest_apps = unpack_dir.glob("**/*.app").group_by { |app| app.each_filename.count } .min_by(&:first)&.last next unless shallowest_apps&.one? shallowest_app = shallowest_apps.fetch(0) [shallowest_app.relative_path_from(unpack_dir), find_appcast_for(shallowest_app)] end rescue => e opoo "Unable to unpack the download to find its app." odebug e. nil end |
#find_appcast_for(app) ⇒ Cask::Appcast::Result?
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.
Scan the app, from the download or an installed copy, for an appcast
to prefill the livecheck block.
184 185 186 187 188 189 190 |
# File 'dev-cmd/create.rb', line 184 def find_appcast_for(app) return unless app.directory? appcast = Cask::Appcast.find(app) ohai "Found #{appcast.strategy.inspect} appcast: #{appcast.url}" if appcast appcast end |
#generate_zap_for(app) ⇒ String?
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.
Scan for files left by an already-installed copy of the app to prefill
the zap stanza.
218 219 220 221 222 223 |
# File 'dev-cmd/create.rb', line 218 def generate_zap_for(app) return unless app.directory? Utils.popen_read_text(HOMEBREW_BREW_FILE, "generate-zap", "--name", app.basename(".app").to_s, err: :err) .slice(/^zap (?:trash|delete):.*/m)&.chomp end |
#run ⇒ 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.
Create a formula from a tarball URL.
80 81 82 83 84 85 86 87 88 |
# File 'dev-cmd/create.rb', line 80 def run path = if args.cask? create_cask else create_formula end Utils::Editor.open path end |