lib/berkshelf/formatters/json.rb in berkshelf-1.4.6 vs lib/berkshelf/formatters/json.rb in berkshelf-2.0.0.beta
- old
+ new
@@ -5,10 +5,12 @@
include AbstractFormatter
register_formatter :json
def initialize
+ Berkshelf.ui.mute!
+
@output = {
cookbooks: Array.new,
errors: Array.new,
messages: Array.new
}
@@ -20,11 +22,11 @@
cookbooks.each do |name, details|
details[:name] = name
output[:cookbooks] << details
end
- print MultiJson.dump(output)
+ print ::JSON.pretty_generate(output)
end
# Add a Cookbook installation entry to delayed output
#
# @param [String] cookbook
@@ -54,9 +56,18 @@
# @param [String] chef_api_url
def upload(cookbook, version, chef_api_url)
cookbooks[cookbook] ||= {}
cookbooks[cookbook][:version] = version
cookbooks[cookbook][:uploaded_to] = chef_api_url
+ end
+
+ # Add a Cookbook package entry to delayed output
+ #
+ # @param [String] cookbook
+ # @param [String] destination
+ def package(cookbook, destination)
+ cookbooks[cookbook] ||= {}
+ cookbooks[cookbook][:destination] = destination
end
# Add a generic message entry to delayed output
#
# @param [String] message