class Berkshelf::JsonFormatter
def cleanup_hook
def cleanup_hook cookbooks.each do |name, details| details[:name] = name output[:cookbooks] << details end puts ::JSON.pretty_generate(output) end
def deprecation(message)
def deprecation(message) output[:warnings] << "DEPRECATED: #{message}" end
def error(message)
-
message
(String
) --
def error(message) output[:errors] << message end
def fetch(dependency)
-
dependency
(Berkshelf::Dependency
) --
def fetch(dependency) cookbooks[dependency] ||= {} cookbooks[dependency][:version] = dependency.locked_version.to_s cookbooks[dependency][:location] = dependency.location end
def info(cookbook)
-
cookbook
(CachedCookbook
) --
def info(cookbook) path = File.expand_path(cookbook.path) cookbooks[cookbook.cookbook_name] = { path: path } end
def initialize
def initialize @output = { cookbooks: [], errors: [], messages: [], warnings: [], } @cookbooks = {} Berkshelf.ui.mute { super } end
def install(source, cookbook)
-
cookbook
(RemoteCookbook
) -- -
source
(Source
) --
def install(source, cookbook) cookbooks[cookbook.name] ||= {} cookbooks[cookbook.name][:version] = cookbook.version unless source.default? cookbooks[cookbook.name][:api_source] = source.uri cookbooks[cookbook.name][:location_path] = cookbook.location_path end end
def list(dependencies)
-
dependencies
(Array
) --
def list(dependencies) dependencies.each do |dependency, cookbook| cookbooks[dependency.name] ||= {} cookbooks[dependency.name][:version] = dependency.locked_version.to_s if dependency.location cookbooks[dependency.name][:location] = dependency.location end end end
def msg(message)
-
message
(String
) --
def msg(message) output[:messages] << message end
def outdated(hash)
-
hash
(Hash
) --
def outdated(hash) hash.each do |name, info| info["remote"].each do |remote_source, remote_version| source = remote_source.uri.to_s cookbooks[name] ||= {} cookbooks[name][:local] = info["local"].to_s cookbooks[name][:remote] ||= {} cookbooks[name][:remote][source] = remote_version.to_s end end end
def package(destination)
-
destination
(String
) --
def package(destination) output[:messages] << "Cookbook(s) packaged to #{destination}" end
def search(results)
-
results
(Array
) --
def search(results) results.sort_by(&:name).each do |remote_cookbook| cookbooks[remote_cookbook.name] ||= {} cookbooks[remote_cookbook.name][:version] = remote_cookbook.version end end
def show(cookbook)
-
cookbook
(CachedCookbook
) --
def show(cookbook) path = File.expand_path(cookbook.path) cookbooks[cookbook.cookbook_name] = { path: path } end
def skipping(cookbook, conn)
-
conn
(Ridley::Connection
) -- -
cookbook
(Berkshelf::CachedCookbook
) --
def skipping(cookbook, conn) name = cookbook.cookbook_name cookbooks[name] ||= {} cookbooks[name][:version] = cookbook.version cookbooks[name][:skipped] = true end
def uploaded(cookbook, conn)
-
conn
(Ridley::Connection
) -- -
cookbook
(Berkshelf::CachedCookbook
) --
def uploaded(cookbook, conn) name = cookbook.cookbook_name cookbooks[name] ||= {} cookbooks[name][:version] = cookbook.version cookbooks[name][:uploaded_to] = conn.server_url end
def use(dependency)
-
dependency
(Dependency
) --
def use(dependency) cookbooks[dependency.name] ||= {} cookbooks[dependency.name][:version] = dependency.cached_cookbook.version if dependency.location.is_a?(PathLocation) cookbooks[dependency.name][:metadata] = true if dependency.location.metadata? cookbooks[dependency.name][:location] = dependency.location.relative_path end end
def vendor(cookbook, destination)
-
destination
(String
) -- -
cookbook
(CachedCookbook
) --
def vendor(cookbook, destination) cookbook_destination = File.join(destination, cookbook.cookbook_name) msg("Vendoring #{cookbook.cookbook_name} (#{cookbook.version}) to #{cookbook_destination}") end
def version
def version @output = { version: Berkshelf::VERSION } end
def warn(message)
-
message
(String
) --
def warn(message) output[:warnings] << message end