Module: Homebrew::Bundle::FormulaDumper Private
- Extended by:
- Utils::Output::Mixin
- Defined in:
- bundle/formula_dumper.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.
refactor into multiple modules
Defined Under Namespace
Classes: Topo
Class Method Summary collapse
- .dump(describe: false, no_restart: false) ⇒ Object private
- .formula_aliases ⇒ Object private
- .formula_oldnames ⇒ Object private
- .formulae ⇒ Object private
- .formulae_by_full_name(name = nil) ⇒ Object private
- .formulae_by_name(name) ⇒ Object private
- .reset! ⇒ Object private
Methods included from Utils::Output::Mixin
odebug, odeprecated, odie, odisabled, ofail, oh1, oh1_title, ohai, ohai_title, onoe, opoo, opoo_outside_github_actions, pretty_duration, pretty_installed, pretty_outdated, pretty_uninstalled
Class Method Details
.dump(describe: false, no_restart: false) ⇒ Object
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.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'bundle/formula_dumper.rb', line 59 def self.dump(describe: false, no_restart: false) require "bundle/brew_services" requested_formula = formulae.select do |f| f[:installed_on_request?] || !f[:installed_as_dependency?] end requested_formula.map do |f| brewline = if describe && f[:desc].present? f[:desc].split("\n").map { |s| "# #{s}\n" }.join else "" end brewline += "brew \"#{f[:full_name]}\"" args = f[:args].map { |arg| "\"#{arg}\"" }.sort.join(", ") brewline += ", args: [#{args}]" unless f[:args].empty? brewline += ", restart_service: :changed" if !no_restart && BrewServices.started?(f[:full_name]) brewline += ", link: #{f[:link?]}" unless f[:link?].nil? brewline end.join("\n") end |
.formula_aliases ⇒ Object
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.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'bundle/formula_dumper.rb', line 81 def self.formula_aliases return @formula_aliases if @formula_aliases @formula_aliases = {} formulae.each do |f| aliases = f[:aliases] next if aliases.blank? aliases.each do |a| @formula_aliases[a] = f[:full_name] if f[:full_name].include? "/" # tap formula tap_name = f[:full_name].rpartition("/").first @formula_aliases["#{tap_name}/#{a}"] = f[:full_name] end end end @formula_aliases end |
.formula_oldnames ⇒ Object
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.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'bundle/formula_dumper.rb', line 100 def self.formula_oldnames return @formula_oldnames if @formula_oldnames @formula_oldnames = {} formulae.each do |f| oldnames = f[:oldnames] next if oldnames.blank? oldnames.each do |oldname| @formula_oldnames[oldname] = f[:full_name] if f[:full_name].include? "/" # tap formula tap_name = f[:full_name].rpartition("/").first @formula_oldnames["#{tap_name}/#{oldname}"] = f[:full_name] end end end @formula_oldnames end |
.formulae ⇒ Object
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.
25 26 27 28 29 30 |
# File 'bundle/formula_dumper.rb', line 25 def self.formulae return @formulae if @formulae formulae_by_full_name @formulae end |
.formulae_by_full_name(name = nil) ⇒ Object
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.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'bundle/formula_dumper.rb', line 32 def self.formulae_by_full_name(name = nil) return @formulae_by_full_name[name] if name.present? && @formulae_by_full_name&.key?(name) require "formula" require "formulary" Formulary.enable_factory_cache! @formulae_by_name ||= {} @formulae_by_full_name ||= {} if name.nil? formulae = Formula.installed.map(&method(:add_formula)) sort!(formulae) return @formulae_by_full_name end formula = Formula[name] add_formula(formula) rescue FormulaUnavailableError => e opoo "'#{name}' formula is unreadable: #{e}" {} end |
.formulae_by_name(name) ⇒ Object
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.
55 56 57 |
# File 'bundle/formula_dumper.rb', line 55 def self.formulae_by_name(name) formulae_by_full_name(name) || @formulae_by_name[name] end |
.reset! ⇒ Object
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.
14 15 16 17 18 19 20 21 22 23 |
# File 'bundle/formula_dumper.rb', line 14 def self.reset! require "bundle/brew_services" Homebrew::Bundle::BrewServices.reset! @formulae = nil @formulae_by_full_name = nil @formulae_by_name = nil @formula_aliases = nil @formula_oldnames = nil end |