Sha256: d40f05ccc3d01777a717ef0f09353665196ade93fea7d49863c50d561f2f76d8
Contents?: true
Size: 1 KB
Versions: 5
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true require 'puppet-debugger/input_responder_plugin' module PuppetDebugger module InputResponders class Resources < InputResponderPlugin COMMAND_WORDS = %w[resources].freeze SUMMARY = 'List all the resources current in the catalog.' COMMAND_GROUP = :scope def run(args = []) filter = args resources = find_resources(debugger.catalog.resources, filter) modified = resources.map do |res| res.to_s.gsub(/\[/, "['").gsub(/\]/, "']") # ensure the title has quotes end output = "Resources not shown in any specific order\n".warning output + modified.ai end def find_resources(resources, filter = []) return resources if filter.nil? || filter.empty? filter_string = filter.join(' ').downcase resources.find_all do |resource| resource.name.to_s.downcase.include?(filter_string) || resource.type.to_s.downcase.include?(filter_string) end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems