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_descriptor.rb,
lib/chef/formatters/error_inspectors.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, Minimal, NullFormatter, Outputter, UnknownFormatter

Class Method Summary collapse

Class Method Details

.available_formattersObject



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

def self.available_formatters
  formatters_by_name.keys
end

.by_name(name) ⇒ Object



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

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

.formatters_by_nameObject



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

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?



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

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

  formatter_class.new(out, err)
end

.register(name, formatter) ⇒ Object



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

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