Exception: Machinery::Errors::MissingExtractedFiles

Inherits:
SystemDescriptionError show all
Defined in:
lib/exceptions.rb

Instance Method Summary collapse

Constructor Details

#initialize(description, scopes) ⇒ MissingExtractedFiles

Returns a new instance of MissingExtractedFiles.



56
57
58
59
# File 'lib/exceptions.rb', line 56

def initialize(description, scopes)
  @description = description
  @scopes = scopes
end

Instance Method Details

#to_sObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/exceptions.rb', line 61

def to_s
  meta = @description[@scopes.first].meta
  hostname = @scopes.map do |s|
    @description[s].meta.hostname if @description[s].meta
  end.compact.first || "<HOSTNAME>"
  formatted_scopes = Machinery::Ui.internal_scope_list_to_string(@scopes)

  cmd = "#{$0} inspect --extract-files --scope=#{formatted_scopes.delete(" ")}"
  cmd += " --name='#{@description.name}'" if hostname != @description.name
  cmd += " #{hostname}"

  if @scopes.count > 1
    output = "The following scopes '#{formatted_scopes}' are part of the system description"
  else
    output = "The scope '#{formatted_scopes}' is part of the system description"
  end
  output += " but the corresponding files weren't extracted during inspection.\n" \
  "The files are required to continue with this command." \
  " Run `#{cmd}` to extract them."
end