diff options
author | Tim Smith <tsmith@chef.io> | 2018-08-31 12:05:05 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-08-31 12:05:05 -0700 |
commit | 8fc37006ff1e496e0063ddb839d7c28682b32a55 (patch) | |
tree | c64ad9478233566103c499af75390f208d647aad /lib/chef/resource_inspector.rb | |
parent | 783d39e049f863e620b9518ca1ddfebdae74831b (diff) | |
download | chef-8fc37006ff1e496e0063ddb839d7c28682b32a55.tar.gz |
Allow resource_inspector be used outside the binaryinspector_library
Prevously the inspect method wrote out to stdout which makes it
impossible to use as a library. Now it returns data which the start
method will write to stdout. This allowed me to use this as a library
for autogenerating docs.
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/chef/resource_inspector.rb')
-rw-r--r-- | lib/chef/resource_inspector.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/chef/resource_inspector.rb b/lib/chef/resource_inspector.rb index 10fa42c842..1559932940 100644 --- a/lib/chef/resource_inspector.rb +++ b/lib/chef/resource_inspector.rb @@ -81,7 +81,8 @@ module ResourceInspector # otherwise, if we have a path then extract all the resources from the cookbook # or else do a list of built in resources # - # @param complete [TrueClass, FalseClass] Whether to show properties defined in the base Resource class + # @param complete [TrueClass, FalseClass] Whether to show properties defined in the base Resource class + # @return [String] JSON formatting of all resources def self.inspect(arguments = [], complete: false) output = if arguments.empty? ObjectSpace.each_object(Class).select { |k| k < Chef::Resource }.each_with_object({}) { |klass, acc| acc[klass.resource_name] = extract_resource(klass) } @@ -96,11 +97,11 @@ module ResourceInspector end end - puts Chef::JSONCompat.to_json_pretty(output) + Chef::JSONCompat.to_json_pretty(output) end def self.start - inspect(ARGV, complete: true) + puts inspect(ARGV, complete: true) end end |