Module: Homebrew::Bundle::BrewDumper Private
- Defined in:
- bundle/brew_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
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.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'bundle/brew_dumper.rb', line 56 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.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'bundle/brew_dumper.rb', line 78 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.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'bundle/brew_dumper.rb', line 97 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.
22 23 24 25 26 27 |
# File 'bundle/brew_dumper.rb', line 22 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.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'bundle/brew_dumper.rb', line 29 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.
52 53 54 |
# File 'bundle/brew_dumper.rb', line 52 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.
11 12 13 14 15 16 17 18 19 20 |
# File 'bundle/brew_dumper.rb', line 11 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 |