Module: Homebrew::Bundle::Dumper Private

Defined in:
bundle/dumper.rb

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.

Class Method Summary collapse

Class Method Details

.brewfile_path(global: false, file: nil) ⇒ 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.

Parameters:

  • global (Boolean) (defaults to: false)
  • file (String, nil) (defaults to: nil)

Returns:



71
72
73
74
# File 'bundle/dumper.rb', line 71

def self.brewfile_path(global: false, file: nil)
  require "bundle/brewfile"
  Brewfile.path(dash_writes_to_stdout: true, global:, file:)
end

.build_brewfile(describe:, no_restart:, formulae:, taps:, casks:, mas:, whalebrew:, vscode:) ⇒ 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.

Parameters:

  • describe (Boolean)
  • no_restart (Boolean)
  • formulae (Boolean)
  • taps (Boolean)
  • casks (Boolean)
  • mas (Boolean)
  • whalebrew (Boolean)
  • vscode (Boolean)

Returns:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'bundle/dumper.rb', line 29

def self.build_brewfile(describe:, no_restart:, formulae:, taps:, casks:, mas:, whalebrew:, vscode:)
  require "bundle/tap_dumper"
  require "bundle/formula_dumper"
  require "bundle/cask_dumper"
  require "bundle/mac_app_store_dumper"
  require "bundle/whalebrew_dumper"
  require "bundle/vscode_extension_dumper"

  content = []
  content << TapDumper.dump if taps
  content << FormulaDumper.dump(describe:, no_restart:) if formulae
  content << CaskDumper.dump(describe:) if casks
  content << MacAppStoreDumper.dump if mas
  content << WhalebrewDumper.dump if whalebrew
  content << VscodeExtensionDumper.dump if vscode
  "#{content.reject(&:empty?).join("\n")}\n"
end

.dump_brewfile(global:, file:, describe:, force:, no_restart:, formulae:, taps:, casks:, mas:, whalebrew:, vscode:) ⇒ 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.

Parameters:

  • global (Boolean)
  • file (String, nil)
  • describe (Boolean)
  • force (Boolean)
  • no_restart (Boolean)
  • formulae (Boolean)
  • taps (Boolean)
  • casks (Boolean)
  • mas (Boolean)
  • whalebrew (Boolean)
  • vscode (Boolean)


62
63
64
65
66
67
68
# File 'bundle/dumper.rb', line 62

def self.dump_brewfile(global:, file:, describe:, force:, no_restart:, formulae:, taps:, casks:, mas:,
                       whalebrew:, vscode:)
  path = brewfile_path(global:, file:)
  can_write_to_brewfile?(path, force:)
  content = build_brewfile(describe:, no_restart:, taps:, formulae:, casks:, mas:, whalebrew:, vscode:)
  write_file path, content
end

.write_file(file, content) ⇒ 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.

Parameters:



82
83
84
85
86
# File 'bundle/dumper.rb', line 82

def self.write_file(file, content)
  Bundle.exchange_uid_if_needed! do
    file.open("w") { |io| io.write content }
  end
end