class Berkshelf::HumanFormatter

Public Instance Methods

deprecation(message) click to toggle source

Output a deprecation warning

@param [String] message

# File lib/berkshelf/formatters/human.rb, line 159
def deprecation(message)
  Berkshelf.ui.info "DEPRECATED: #{message}"
end
error(message) click to toggle source

Output an error message using {Berkshelf.ui}

@param [String] message

# File lib/berkshelf/formatters/human.rb, line 145
def error(message)
  Berkshelf.ui.error message
end
fetch(dependency) click to toggle source

@param [Berkshelf::Dependency] dependency

# File lib/berkshelf/formatters/human.rb, line 9
def fetch(dependency)
  Berkshelf.ui.info "Fetching '#{dependency.name}' from #{dependency.location}"
end
info(cookbook) click to toggle source

Output the important information about a cookbook using {Berkshelf.ui}.

@param [CachedCookbook] cookbook

# File lib/berkshelf/formatters/human.rb, line 93
def info(cookbook)
  Berkshelf.ui.info(cookbook.pretty_print)
end
install(source, cookbook) click to toggle source

Output a Cookbook installation message using {Berkshelf.ui}

@param [Source] source

the source the dependency is being downloaded from

@param [RemoteCookbook] cookbook

the cookbook to be downloaded
# File lib/berkshelf/formatters/human.rb, line 19
def install(source, cookbook)
  message = "Installing #{cookbook.name} (#{cookbook.version})"

  if source.type == :chef_repo
    message << " from #{cookbook.location_path}"
  elsif !source.default?
    message << " from #{source}"
    message << " ([#{cookbook.location_type}] #{cookbook.location_path})"
  end

  Berkshelf.ui.info(message)
end
list(dependencies) click to toggle source

Output a list of cookbooks using {Berkshelf.ui}

@param [Array<Dependency>] list

# File lib/berkshelf/formatters/human.rb, line 100
def list(dependencies)
  Berkshelf.ui.info "Cookbooks installed by your Berksfile:"
  dependencies.each do |dependency|
    out =  "  * #{dependency}"
    out << " from #{dependency.location}" if dependency.location
    Berkshelf.ui.info(out)
  end
end
msg(message) click to toggle source

Output a generic message using {Berkshelf.ui}

@param [String] message

# File lib/berkshelf/formatters/human.rb, line 138
def msg(message)
  Berkshelf.ui.info message
end
outdated(hash) click to toggle source

Output a list of outdated cookbooks and the most recent version using {Berkshelf.ui}

@param [Hash] hash

the list of outdated cookbooks in the format
{ 'cookbook' => { 'supermarket.chef.io' => #<Cookbook> } }
# File lib/berkshelf/formatters/human.rb, line 63
def outdated(hash)
  if hash.empty?
    Berkshelf.ui.info("All cookbooks up to date!")
  else
    Berkshelf.ui.info("The following cookbooks have newer versions:")

    hash.each do |name, info|
      info["remote"].each do |remote_source, remote_version|
        out = "  * #{name} (#{info["local"]} => #{remote_version})"

        unless remote_source.default?
          out << " [#{remote_source.uri}]"
        end

        Berkshelf.ui.info(out)
      end
    end
  end
end
package(destination) click to toggle source

Output a Cookbook package message using {Berkshelf.ui}

@param [String] destination

# File lib/berkshelf/formatters/human.rb, line 86
def package(destination)
  Berkshelf.ui.info "Cookbook(s) packaged to #{destination}"
end
show(cookbook) click to toggle source

Output Cookbook path using {Berkshelf.ui}

@param [CachedCookbook] cookbook

# File lib/berkshelf/formatters/human.rb, line 121
def show(cookbook)
  path = File.expand_path(cookbook.path)
  Berkshelf.ui.info(path)
end
skipping(cookbook, conn) click to toggle source

Output a Cookbook skip message using {Berkshelf.ui}

@param [Berkshelf::CachedCookbook] cookbook @param [Ridley::Connection] conn

# File lib/berkshelf/formatters/human.rb, line 53
def skipping(cookbook, conn)
  Berkshelf.ui.info "Skipping #{cookbook.cookbook_name} (#{cookbook.version}) (frozen)"
end
uploaded(cookbook, conn) click to toggle source

Output a Cookbook upload message using {Berkshelf.ui}

@param [Berkshelf::CachedCookbook] cookbook @param [Ridley::Connection] conn

# File lib/berkshelf/formatters/human.rb, line 45
def uploaded(cookbook, conn)
  Berkshelf.ui.info "Uploaded #{cookbook.cookbook_name} (#{cookbook.version}) to: '#{conn.server_url}'"
end
use(dependency) click to toggle source

Output a Cookbook use message using {Berkshelf.ui}

@param [Dependency] dependency

# File lib/berkshelf/formatters/human.rb, line 35
def use(dependency)
  message =  "Using #{dependency.name} (#{dependency.locked_version})"
  message << " from #{dependency.location}" if dependency.location
  Berkshelf.ui.info(message)
end
vendor(cookbook, destination) click to toggle source

Output Cookbook vendor info message using {Berkshelf.ui}

@param [CachedCookbook] cookbook @param [String] destination

# File lib/berkshelf/formatters/human.rb, line 130
def vendor(cookbook, destination)
  cookbook_destination = File.join(destination, cookbook.cookbook_name)
  Berkshelf.ui.info "Vendoring #{cookbook.cookbook_name} (#{cookbook.version}) to #{cookbook_destination}"
end
version() click to toggle source

Output the version of Berkshelf

# File lib/berkshelf/formatters/human.rb, line 4
def version
  Berkshelf.ui.info Berkshelf::VERSION
end
warn(message) click to toggle source

Output a warning message using {Berkshelf.ui}

@param [String] message

# File lib/berkshelf/formatters/human.rb, line 152
def warn(message)
  Berkshelf.ui.warn message
end