Class: Asdf::ToolVersions
- Inherits:
-
Object
- Object
- Asdf::ToolVersions
- Defined in:
- lib/asdf/tool_versions.rb
Instance Method Summary collapse
- #default_tool_version_for(tool) ⇒ Object
- #default_version_for(tool) ⇒ Object
- #uninstall_unnecessary_software!(prompt: true) ⇒ Object
- #unnecessary_installed_versions_of_software ⇒ Object
- #unnecessary_software_to_uninstall? ⇒ Boolean
Instance Method Details
#default_tool_version_for(tool) ⇒ Object
7 8 9 |
# File 'lib/asdf/tool_versions.rb', line 7 def default_tool_version_for(tool) tool_versions[tool]&.default_tool_version end |
#default_version_for(tool) ⇒ Object
11 12 13 |
# File 'lib/asdf/tool_versions.rb', line 11 def default_version_for(tool) default_tool_version_for(tool)&.version end |
#uninstall_unnecessary_software!(prompt: true) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/asdf/tool_versions.rb', line 19 def uninstall_unnecessary_software!(prompt: true) return true unless work_to_do? if prompt inform return true unless confirm? end failed_to_uninstall = {} unnecessary_installed_versions_of_software.each do |name, versions| GDK::Output.print "Uninstalling #{name} " versions.each_with_index do |(version, tool_version), i| GDK::Output.print ', ' if i.positive? GDK::Output.print version begin tool_version.uninstall! rescue ToolVersion::UninstallFailedError failed_to_uninstall[name] ||= [] failed_to_uninstall[name] << version end end icon = if failed_to_uninstall.empty? :success elsif failed_to_uninstall.count == versions.count :error else :warning end GDK::Output.puts(" #{GDK::Output.icon(icon)}") end return true if failed_to_uninstall.empty? GDK::Output.puts(stderr: true) GDK::Output.warn("Failed to uninstall the following:\n\n") failed_to_uninstall.each do |name, versions| GDK::Output.puts("#{name} #{versions.join(', ')}") end false end |
#unnecessary_installed_versions_of_software ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/asdf/tool_versions.rb', line 66 def unnecessary_installed_versions_of_software installed_versions_of_wanted_software.each_with_object({}) do |(name, versions), unncessary_software| versions.each do |version, tool_version| next if wanted_software[name][version] unncessary_software[name] ||= {} unncessary_software[name][version] = tool_version end end end |
#unnecessary_software_to_uninstall? ⇒ Boolean
15 16 17 |
# File 'lib/asdf/tool_versions.rb', line 15 def unnecessary_software_to_uninstall? work_to_do?(output: false) end |