Exception: Puppet::ModuleTool::Errors::ModuleIsRequiredError Private

Inherits:
UninstallError show all
Defined in:
lib/puppet/module_tool/errors/uninstaller.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary

Attributes inherited from Error

#original

Instance Method Summary collapse

Methods inherited from ModuleToolError

#v, #vstring

Constructor Details

#initialize(options) ⇒ ModuleIsRequiredError

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ModuleIsRequiredError.



26
27
28
29
30
31
32
33
# File 'lib/puppet/module_tool/errors/uninstaller.rb', line 26

def initialize(options)
  @module_name       = options[:module_name]
  @required_by       = options[:required_by]
  @requested_version = options[:requested_version]
  @installed_version = options[:installed_version]

  super _("Could not uninstall '%{module_name}'; installed modules still depend upon it") % { module_name: @module_name }
end

Instance Method Details

#multilineObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/puppet/module_tool/errors/uninstaller.rb', line 35

def multiline
  message = []
  if @requested_version
    message << _("Could not uninstall module '%{module_name}' (v%{requested_version})") % { module_name: @module_name, requested_version: @requested_version }
  else
    message << _("Could not uninstall module '%{module_name}'") % { module_name: @module_name }
  end
  message << _("  Other installed modules have dependencies on '%{module_name}' (%{version})") % { module_name: @module_name, version: v(@installed_version) }
  message += @required_by.map do |mod|
    _("    '%{module_name}' (%{version}) requires '%{module_dep}' (%{dep_version})") % { module_name: mod['name'], version: v(mod['version']), module_dep: @module_name, dep_version: v(mod['version_requirement']) }
  end
  # TRANSLATORS `puppet module uninstall --force` is a command line option that should not be translated
  message << _("    Use `puppet module uninstall --force` to uninstall this module anyway")
  message.join("\n")
end