Class: Homebrew::Bundle::Checker::BrewServiceChecker Private

Inherits:
Base
  • Object
show all
Defined in:
bundle/brew_service_checker.rb

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.

Constant Summary collapse

PACKAGE_TYPE =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

:brew
PACKAGE_TYPE_NAME =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

"Service"
PACKAGE_ACTION_PREDICATE =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

"needs to be started."

Instance Method Summary collapse

Methods inherited from Base

#checkable_entries, #exit_early_check, #find_actionable, #full_check

Instance Method Details

#entry_to_formula(entry) ⇒ 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.



26
27
28
29
# File 'bundle/brew_service_checker.rb', line 26

def entry_to_formula(entry)
  require "bundle/brew_installer"
  Homebrew::Bundle::BrewInstaller.new(entry.name, entry.options)
end

#failure_reason(name, no_upgrade:) ⇒ 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.



12
13
14
# File 'bundle/brew_service_checker.rb', line 12

def failure_reason(name, no_upgrade:)
  "#{PACKAGE_TYPE_NAME} #{name} needs to be started."
end

#format_checkable(entries) ⇒ 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.



48
49
50
# File 'bundle/brew_service_checker.rb', line 48

def format_checkable(entries)
  checkable_entries(entries)
end

#formula_needs_to_start?(formula) ⇒ Boolean

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.

Returns:

  • (Boolean)


31
32
33
# File 'bundle/brew_service_checker.rb', line 31

def formula_needs_to_start?(formula)
  formula.start_service? || formula.restart_service?
end

#installed_and_up_to_date?(formula, no_upgrade: false) ⇒ Boolean

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.

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
# File 'bundle/brew_service_checker.rb', line 16

def installed_and_up_to_date?(formula, no_upgrade: false)
  return true unless formula_needs_to_start?(entry_to_formula(formula))
  return true if service_is_started?(formula.name)

  old_name = lookup_old_name(formula.name)
  return true if old_name && service_is_started?(old_name)

  false
end

#lookup_old_name(service_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.



40
41
42
43
44
45
46
# File 'bundle/brew_service_checker.rb', line 40

def lookup_old_name(service_name)
  require "bundle/brew_dumper"
  @old_names ||= Homebrew::Bundle::BrewDumper.formula_oldnames
  old_name = @old_names[service_name]
  old_name ||= @old_names[service_name.split("/").last]
  old_name
end

#service_is_started?(service_name) ⇒ Boolean

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.

Returns:

  • (Boolean)


35
36
37
38
# File 'bundle/brew_service_checker.rb', line 35

def service_is_started?(service_name)
  require "bundle/brew_services"
  Homebrew::Bundle::BrewServices.started?(service_name)
end