Class: Homebrew::Bundle::Cargo Private
- Inherits:
-
Extension
- Object
- PackageType
- 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.
Class Method Summary collapse
- .banner_name ⇒ String private
- .cargo_env(cargo) ⇒ Hash{String => String} private
- .check_label ⇒ String private
- .cleanup_heading ⇒ String? private
- .install_package!(name, with: nil, verbose: false) ⇒ Boolean private
- .installed_packages ⇒ Array<String> private
- .package_manager_env(executable) ⇒ Hash{String => String} private
- .package_manager_executable ⇒ Pathname? private
- .package_manager_name ⇒ String private
- .packages ⇒ Array<String> private
- .parse_package_list(output) ⇒ Array<String> private
- .reset! ⇒ void private
- .type ⇒ Symbol private
- .uninstall_package!(name, executable: Pathname.new("")) ⇒ void private
Methods inherited from Extension
add_supported?, check, cleanup!, cleanup_disable_description, cleanup_disable_env, cleanup_item_name, cleanup_items, cleanup_supported?, disable_predicate_method, dump, dump_disable_description, dump_disable_env, dump_disable_predicate_method, dump_disable_supported?, dump_entry, dump_name, dump_output, dump_supported?, dump_with, entry, #failure_reason, fetchable_name, flag, inherited, install!, install_supported?, install_verb, #installed_and_up_to_date?, legacy_check_step, package_description, package_installed?, package_manager_executable!, package_manager_installed?, package_record, predicate_method, preinstall!, quote, remove_supported?, switch_description, with_package_manager_env
Methods inherited from PackageType
check, #checkable_entries, dump, dump_output, dump_supported?, #exit_early_check, #failure_reason, fetchable_name, #find_actionable, #format_checkable, #full_check, inherited, install!, install_supported?, install_verb, #installed_and_up_to_date?, preinstall!
Class Method Details
.banner_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.
17 |
# File 'bundle/extensions/cargo.rb', line 17 def = "Cargo packages" |
.cargo_env(cargo) ⇒ Hash{String => 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.
103 104 105 106 107 108 109 110 |
# File 'bundle/extensions/cargo.rb', line 103 def cargo_env(cargo) { "CARGO_HOME" => ENV.fetch("HOMEBREW_CARGO_HOME", nil), "CARGO_INSTALL_ROOT" => ENV.fetch("HOMEBREW_CARGO_INSTALL_ROOT", nil), "PATH" => "#{cargo.dirname}:#{ENV.fetch("PATH")}", "RUSTUP_HOME" => ENV.fetch("HOMEBREW_RUSTUP_HOME", nil), }.compact end |
.check_label ⇒ 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.
14 |
# File 'bundle/extensions/cargo.rb', line 14 def check_label = "Cargo Package" |
.cleanup_heading ⇒ 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 |
# File 'bundle/extensions/cargo.rb', line 26 def cleanup_heading end |
.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.
63 64 65 66 67 68 69 70 71 |
# File 'bundle/extensions/cargo.rb', line 63 def install_package!(name, with: nil, verbose: false) _ = with cargo = package_manager_executable! with_env(cargo_env(cargo)) 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.
74 75 76 77 78 79 |
# File 'bundle/extensions/cargo.rb', line 74 def installed_packages installed_packages = @installed_packages return installed_packages if installed_packages @installed_packages = packages.dup end |
.package_manager_env(executable) ⇒ Hash{String => 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.
87 88 89 |
# File 'bundle/extensions/cargo.rb', line 87 def package_manager_env(executable) cargo_env(executable) end |
.package_manager_executable ⇒ 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.
36 37 38 |
# File 'bundle/extensions/cargo.rb', line 36 def package_manager_executable which("cargo", ORIGINAL_PATHS) 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.
31 32 33 |
# File 'bundle/extensions/cargo.rb', line 31 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.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'bundle/extensions/cargo.rb', line 41 def packages packages = @packages return packages if packages @packages = if (cargo = package_manager_executable) && (!cargo.to_s.start_with?("/") || cargo.exist?) with_env(cargo_env(cargo)) do parse_package_list(`#{cargo} install --list`) end end return [] if @packages.nil? @packages 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.
92 93 94 95 96 97 98 99 |
# File 'bundle/extensions/cargo.rb', line 92 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.
20 21 22 23 |
# File 'bundle/extensions/cargo.rb', line 20 def reset! @packages = T.let(nil, T.nilable(T::Array[String])) @installed_packages = T.let(nil, T.nilable(T::Array[String])) end |
.type ⇒ Symbol
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 |
# File 'bundle/extensions/cargo.rb', line 11 def type = :cargo |
.uninstall_package!(name, executable: Pathname.new("")) ⇒ 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.
82 83 84 |
# File 'bundle/extensions/cargo.rb', line 82 def uninstall_package!(name, executable: Pathname.new("")) Bundle.system(executable.to_s, "uninstall", name, verbose: false) end |