Method: Puppet::Graph::SimpleGraph#report_cycles_in_graph

Defined in:
lib/puppet/graph/simple_graph.rb

#report_cycles_in_graphArray

Returns array of dependency cycles (arrays).

Returns:

  • (Array)

    array of dependency cycles (arrays)



228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/puppet/graph/simple_graph.rb', line 228

def report_cycles_in_graph
  cycles = find_cycles_in_graph
  number_of_cycles = cycles.length
  return if number_of_cycles == 0

  message = n_("Found %{num} dependency cycle:\n", "Found %{num} dependency cycles:\n", number_of_cycles) % { num: number_of_cycles }

  cycles.each do |cycle|
    paths = paths_in_cycle(cycle)
    message += paths.map { |path| '(' + path.join(' => ') + ')' }.join('\n') + '\n'
  end

  if Puppet[:graph] then
    filename = write_cycles_to_graph(cycles)
    message += _("Cycle graph written to %{filename}.") % { filename: filename }
  else
    # TRANSLATORS '--graph' refers to a command line option and OmniGraffle and GraphViz are program names and should not be translated
    message += _("Try the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz")
  end
  Puppet.err(message)
  cycles
end