lib/berkshelf/formatters/json.rb in berkshelf-2.0.18 vs lib/berkshelf/formatters/json.rb in berkshelf-3.0.0.beta1
- old
+ new
@@ -4,19 +4,18 @@
include AbstractFormatter
register_formatter :json
def initialize
- Berkshelf.ui.mute!
-
@output = {
cookbooks: Array.new,
errors: Array.new,
messages: Array.new
}
@cookbooks = Hash.new
- super
+
+ Berkshelf.ui.mute { super }
end
def cleanup_hook
cookbooks.each do |name, details|
details[:name] = name
@@ -24,18 +23,29 @@
end
print ::JSON.pretty_generate(output)
end
+ # @param [Berkshelf::Dependency] dependency
+ def fetch(dependency)
+ cookbooks[dependency] ||= {}
+ cookbooks[dependency][:version] = dependency.cached_cookbook.version
+ cookbooks[dependency][:location] = dependency.location
+ end
+
# Add a Cookbook installation entry to delayed output
#
# @param [String] cookbook
# @param [String] version
# @param [~Location] location
def install(cookbook, version, location)
cookbooks[cookbook] ||= {}
cookbooks[cookbook][:version] = version
- cookbooks[cookbook][:location] = location.to_s
+
+ if location && location.is_a?(PathLocation)
+ cookbooks[cookbook][:metadata] = true if location.metadata?
+ cookbooks[cookbook][:location] = location.relative_path
+ end
end
# Add a Cookbook use entry to delayed output
#
# @param [String] cookbook