Class: Chef::Formatters::ErrorDescription

Inherits:
Object
  • Object
show all
Defined in:
lib/chef/formatters/error_descriptor.rb

Overview

Formatters::ErrorDescription

Class for displaying errors on STDOUT.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title) ⇒ ErrorDescription

Returns a new instance of ErrorDescription.


28
29
30
31
# File 'lib/chef/formatters/error_descriptor.rb', line 28

def initialize(title)
  @title = title
  @sections = []
end

Instance Attribute Details

#sectionsObject (readonly)

Returns the value of attribute sections


26
27
28
# File 'lib/chef/formatters/error_descriptor.rb', line 26

def sections
  @sections
end

Instance Method Details

#display(out) ⇒ Object


37
38
39
40
41
42
43
44
45
# File 'lib/chef/formatters/error_descriptor.rb', line 37

def display(out)
  out.puts "=" * 80
  out.puts @title, :red
  out.puts "=" * 80
  out.puts "\n"
  sections.each do |section|
    display_section(section, out)
  end
end

#for_jsonObject


47
48
49
50
51
52
# File 'lib/chef/formatters/error_descriptor.rb', line 47

def for_json()
  {
    'title' => @title,
    'sections' => @sections
  }
end

#section(heading, text) ⇒ Object


33
34
35
# File 'lib/chef/formatters/error_descriptor.rb', line 33

def section(heading, text)
  @sections << [heading, text]
end