Module: Chef::Formatters

Defined in:
lib/chef/formatters/base.rb,
lib/chef/formatters/doc.rb,
lib/chef/formatters/minimal.rb,
lib/chef/formatters/error_mapper.rb,
lib/chef/formatters/error_inspectors.rb,
lib/chef/formatters/error_description.rb,
lib/chef/formatters/indentable_output_stream.rb,
lib/chef/formatters/error_inspectors/api_error_formatting.rb,
lib/chef/formatters/error_inspectors/compile_error_inspector.rb,
lib/chef/formatters/error_inspectors/node_load_error_inspector.rb,
lib/chef/formatters/error_inspectors/resource_failure_inspector.rb,
lib/chef/formatters/error_inspectors/registration_error_inspector.rb,
lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb,
lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb,
lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb

Overview

Chef::Formatters

Formatters handle printing output about the progress/status of a chef client run to the user’s screen.

Defined Under Namespace

Modules: APIErrorFormatting, ErrorInspectors, ErrorMapper Classes: Base, Doc, ErrorDescription, IndentableOutputStream, Minimal, NullFormatter, UnknownFormatter

Class Method Summary collapse

Class Method Details

.available_formattersObject



47
48
49
# File 'lib/chef/formatters/base.rb', line 47

def self.available_formatters
  formatters_by_name.keys
end

.by_name(name) ⇒ Object



43
44
45
# File 'lib/chef/formatters/base.rb', line 43

def self.by_name(name)
  formatters_by_name[name]
end

.formatters_by_nameObject



35
36
37
# File 'lib/chef/formatters/base.rb', line 35

def self.formatters_by_name
  @formatters_by_name ||= {}
end

.new(name, out, err) ⇒ Object

– TODO: is it too clever to be defining new() on a module like this?

Raises:



53
54
55
56
57
58
# File 'lib/chef/formatters/base.rb', line 53

def self.new(name, out, err)
  formatter_class = by_name(name.to_s)
  raise UnknownFormatter, "No output formatter found for #{name} (available: #{available_formatters.join(", ")})" unless formatter_class

  formatter_class.new(out, err)
end

.register(name, formatter) ⇒ Object



39
40
41
# File 'lib/chef/formatters/base.rb', line 39

def self.register(name, formatter)
  formatters_by_name[name.to_s] = formatter
end