Class: Chef::Formatters::Base
- Inherits:
-
EventDispatch::Base
- Object
- EventDispatch::Base
- Chef::Formatters::Base
- Includes:
- ErrorMapper
- Defined in:
- lib/chef/formatters/base.rb
Overview
Formatters::Base
Base class that all formatters should inherit from.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#err ⇒ Object
readonly
Returns the value of attribute err.
-
#out ⇒ Object
readonly
Returns the value of attribute out.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Class Method Summary collapse
Instance Method Summary collapse
-
#attribute_file_load_failed(path, exception) ⇒ Object
Delegates to #file_load_failed.
-
#attribute_file_loaded(path) ⇒ Object
Delegates to #file_loaded.
- #cookbook_resolution_failed(expanded_run_list, exception) ⇒ Object
- #cookbook_sync_failed(cookbooks, exception) ⇒ Object
-
#definition_file_load_failed(path, exception) ⇒ Object
Delegates to #file_load_failed.
-
#definition_file_loaded(path) ⇒ Object
Delegates to #file_loaded.
-
#display_error(description) ⇒ Object
Input: a Formatters::ErrorDescription object.
-
#file_load_failed(path, exception) ⇒ Object
Generic callback for any attribute/library/lwrp/recipe file throwing an exception when loaded.
-
#file_loaded(path) ⇒ Object
Generic callback for any attribute/library/lwrp/recipe file in a cookbook getting loaded.
-
#initialize(out, err) ⇒ Base
constructor
A new instance of Base.
-
#library_file_load_failed(path, exception) ⇒ Object
Delegates to #file_load_failed.
-
#library_file_loaded(path) ⇒ Object
Delegates to #file_loaded.
-
#lwrp_file_load_failed(path, exception) ⇒ Object
Delegates to #file_load_failed.
-
#lwrp_file_loaded(path) ⇒ Object
Delegates to #file_loaded.
- #node_load_failed(node_name, exception, config) ⇒ Object
- #print(*args) ⇒ Object
- #puts(*args) ⇒ Object
-
#recipe_file_load_failed(path, exception) ⇒ Object
Delegates to #file_load_failed.
-
#recipe_file_loaded(path) ⇒ Object
Delegates to #file_loaded.
- #recipe_not_found(exception) ⇒ Object
- #registration_failed(node_name, exception, config) ⇒ Object
- #resource_failed(resource, action, exception) ⇒ Object
- #run_list_expand_failed(node, exception) ⇒ Object
Methods included from ErrorMapper
cookbook_resolution_failed, cookbook_sync_failed, file_load_failed, node_load_failed, registration_failed, resource_failed, run_list_expand_failed
Methods inherited from EventDispatch::Base
#attribute_load_complete, #attribute_load_start, #converge_complete, #converge_start, #cookbook_clean_complete, #cookbook_clean_start, #cookbook_resolution_complete, #cookbook_resolution_start, #cookbook_sync_complete, #cookbook_sync_start, #definition_load_complete, #definition_load_start, #handler_executed, #handlers_completed, #handlers_start, #library_load_complete, #library_load_start, #lwrp_load_complete, #lwrp_load_start, #msg, #node_load_completed, #node_load_start, #ohai_completed, #provider_requirement_failed, #recipe_load_complete, #recipe_load_start, #registration_completed, #registration_start, #removed_cookbook_file, #resource_action_start, #resource_bypassed, #resource_completed, #resource_current_state_load_bypassed, #resource_current_state_loaded, #resource_failed_retriable, #resource_skipped, #resource_up_to_date, #resource_update_applied, #resource_updated, #run_completed, #run_failed, #run_start, #skipping_registration, #synchronized_cookbook, #updated_cookbook_file, #whyrun_assumption
Constructor Details
Instance Attribute Details
#err ⇒ Object (readonly)
Returns the value of attribute err.
111 112 113 |
# File 'lib/chef/formatters/base.rb', line 111 def err @err end |
#out ⇒ Object (readonly)
Returns the value of attribute out.
110 111 112 |
# File 'lib/chef/formatters/base.rb', line 110 def out @out end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
112 113 114 |
# File 'lib/chef/formatters/base.rb', line 112 def output @output end |
Class Method Details
.cli_name(name) ⇒ Object
106 107 108 |
# File 'lib/chef/formatters/base.rb', line 106 def self.cli_name(name) Chef::Formatters.register(name, self) end |
Instance Method Details
#attribute_file_load_failed(path, exception) ⇒ Object
Delegates to #file_load_failed
212 213 214 |
# File 'lib/chef/formatters/base.rb', line 212 def attribute_file_load_failed(path, exception) file_load_failed(path, exception) end |
#attribute_file_loaded(path) ⇒ Object
Delegates to #file_loaded
207 208 209 |
# File 'lib/chef/formatters/base.rb', line 207 def attribute_file_loaded(path) file_loaded(path) end |
#cookbook_resolution_failed(expanded_run_list, exception) ⇒ Object
149 150 151 152 |
# File 'lib/chef/formatters/base.rb', line 149 def cookbook_resolution_failed(, exception) description = ErrorMapper.cookbook_resolution_failed(, exception) display_error(description) end |
#cookbook_sync_failed(cookbooks, exception) ⇒ Object
154 155 156 157 |
# File 'lib/chef/formatters/base.rb', line 154 def cookbook_sync_failed(cookbooks, exception) description = ErrorMapper.cookbook_sync_failed(cookbooks, exception) display_error(description) end |
#definition_file_load_failed(path, exception) ⇒ Object
Delegates to #file_load_failed
222 223 224 |
# File 'lib/chef/formatters/base.rb', line 222 def definition_file_load_failed(path, exception) file_load_failed(path, exception) end |
#definition_file_loaded(path) ⇒ Object
Delegates to #file_loaded
217 218 219 |
# File 'lib/chef/formatters/base.rb', line 217 def definition_file_loaded(path) file_loaded(path) end |
#display_error(description) ⇒ Object
Input: a Formatters::ErrorDescription object. Outputs error to SDOUT.
128 129 130 131 |
# File 'lib/chef/formatters/base.rb', line 128 def display_error(description) puts("") description.display(output) end |
#file_load_failed(path, exception) ⇒ Object
Generic callback for any attribute/library/lwrp/recipe file throwing an exception when loaded. Default behavior is to use CompileErrorInspector to print contextual info about the failure.
176 177 178 179 |
# File 'lib/chef/formatters/base.rb', line 176 def file_load_failed(path, exception) description = ErrorMapper.file_load_failed(path, exception) display_error(description) end |
#file_loaded(path) ⇒ Object
Generic callback for any attribute/library/lwrp/recipe file in a cookbook getting loaded. The per-filetype callbacks for file load are overriden so that they call this instead. This means that a subclass of Formatters::Base can implement #file_loaded to do the same thing for every kind of file that Chef loads from a recipe instead of implementing all the per-filetype callbacks.
170 171 |
# File 'lib/chef/formatters/base.rb', line 170 def file_loaded(path) end |
#library_file_load_failed(path, exception) ⇒ Object
Delegates to #file_load_failed
192 193 194 |
# File 'lib/chef/formatters/base.rb', line 192 def library_file_load_failed(path, exception) file_load_failed(path, exception) end |
#library_file_loaded(path) ⇒ Object
Delegates to #file_loaded
187 188 189 |
# File 'lib/chef/formatters/base.rb', line 187 def library_file_loaded(path) file_loaded(path) end |
#lwrp_file_load_failed(path, exception) ⇒ Object
Delegates to #file_load_failed
202 203 204 |
# File 'lib/chef/formatters/base.rb', line 202 def lwrp_file_load_failed(path, exception) file_load_failed(path, exception) end |
#lwrp_file_loaded(path) ⇒ Object
Delegates to #file_loaded
197 198 199 |
# File 'lib/chef/formatters/base.rb', line 197 def lwrp_file_loaded(path) file_loaded(path) end |
#node_load_failed(node_name, exception, config) ⇒ Object
139 140 141 142 |
# File 'lib/chef/formatters/base.rb', line 139 def node_load_failed(node_name, exception, config) description = ErrorMapper.node_load_failed(node_name, exception, config) display_error(description) end |
#print(*args) ⇒ Object
122 123 124 |
# File 'lib/chef/formatters/base.rb', line 122 def print(*args) @output.print(*args) end |
#puts(*args) ⇒ Object
118 119 120 |
# File 'lib/chef/formatters/base.rb', line 118 def puts(*args) @output.puts(*args) end |
#recipe_file_load_failed(path, exception) ⇒ Object
Delegates to #file_load_failed
232 233 234 |
# File 'lib/chef/formatters/base.rb', line 232 def recipe_file_load_failed(path, exception) file_load_failed(path, exception) end |
#recipe_file_loaded(path) ⇒ Object
Delegates to #file_loaded
227 228 229 |
# File 'lib/chef/formatters/base.rb', line 227 def recipe_file_loaded(path) file_loaded(path) end |
#recipe_not_found(exception) ⇒ Object
181 182 183 184 |
# File 'lib/chef/formatters/base.rb', line 181 def recipe_not_found(exception) description = ErrorMapper.file_load_failed(nil, exception) display_error(description) end |
#registration_failed(node_name, exception, config) ⇒ Object
133 134 135 136 137 |
# File 'lib/chef/formatters/base.rb', line 133 def registration_failed(node_name, exception, config) #A Formatters::ErrorDescription object description = ErrorMapper.registration_failed(node_name, exception, config) display_error(description) end |
#resource_failed(resource, action, exception) ⇒ Object
159 160 161 162 |
# File 'lib/chef/formatters/base.rb', line 159 def resource_failed(resource, action, exception) description = ErrorMapper.resource_failed(resource, action, exception) display_error(description) end |
#run_list_expand_failed(node, exception) ⇒ Object
144 145 146 147 |
# File 'lib/chef/formatters/base.rb', line 144 def (node, exception) description = ErrorMapper.(node, exception) display_error(description) end |