Class: Homebrew::Bundle::Cargo Private
- Inherits:
-
Extension
- Object
- Homebrew::Bundle::Checker::Base
- Extension
- Homebrew::Bundle::Cargo
- Defined in:
- bundle/extensions/cargo.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.
:cargo- 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.
"Cargo Package"- BANNER_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.
"Cargo packages"
Constants inherited from Extension
Class Method Summary collapse
- .install_package!(name, with: nil, verbose: false) ⇒ Boolean private
- .installed_packages ⇒ Array<String> private
- .package_manager_name ⇒ String private
- .packages ⇒ Array<String> private
- .parse_package_list(output) ⇒ Array<String> private
- .reset! ⇒ void private
Methods inherited from Extension
add_supported?, banner_name, check, check_label, cleanup!, cleanup_heading, cleanup_items, cleanup_supported?, dump, dump_disable_description, dump_disable_env, dump_disable_predicate_method, dump_disable_supported?, dump_entry, dump_name, dump_supported?, dump_with, entry, #failure_reason, flag, inherited, install!, install_supported?, #installed_and_up_to_date?, legacy_cleanup_method, package_description, package_installed?, package_manager_executable, package_manager_installed?, package_record, predicate_method, preinstall!, quote, remove_supported?, switch_description, type
Methods inherited from Homebrew::Bundle::Checker::Base
#checkable_entries, #exit_early_check, #failure_reason, #find_actionable, #format_checkable, #full_check, #installed_and_up_to_date?
Class Method Details
.install_package!(name, with: nil, verbose: 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.
48 49 50 51 52 53 54 55 56 57 58 |
# File 'bundle/extensions/cargo.rb', line 48 def install_package!(name, with: nil, verbose: false) _ = with cargo = package_manager_executable return false if cargo.nil? env = { "PATH" => "#{cargo.dirname}:#{ENV.fetch("PATH")}" } with_env(env) do Bundle.system(cargo.to_s, "install", "--locked", name, verbose:) end end |
.installed_packages ⇒ Array<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.
61 62 63 64 65 66 |
# File 'bundle/extensions/cargo.rb', line 61 def installed_packages installed_packages = @installed_packages return installed_packages if installed_packages @installed_packages = packages.dup end |
.package_manager_name ⇒ 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.
21 22 23 |
# File 'bundle/extensions/cargo.rb', line 21 def package_manager_name "rust" end |
.packages ⇒ Array<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.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'bundle/extensions/cargo.rb', line 26 def packages packages = @packages return packages if packages @packages = if Bundle.cargo_installed? cargo = Bundle.which_cargo return [] if cargo.nil? return [] if cargo.to_s.start_with?("/") && !cargo.exist? parse_package_list(`#{cargo} install --list`) else [] end end |
.parse_package_list(output) ⇒ Array<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.
69 70 71 72 73 74 75 76 |
# File 'bundle/extensions/cargo.rb', line 69 def parse_package_list(output) output.lines.filter_map do |line| next if line.match?(/^\s/) match = line.match(/\A(?<name>[^\s:]+)\s+v[0-9A-Za-z.+-]+/) match[:name] if match end.uniq end |
.reset! ⇒ 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.
15 16 17 18 |
# File 'bundle/extensions/cargo.rb', line 15 def reset! @packages = T.let(nil, T.nilable(T::Array[String])) @installed_packages = T.let(nil, T.nilable(T::Array[String])) end |