Class: PuppetGenerator::Models::ErrorMessage
- Defined in:
- lib/puppet_generator/models/error_message.rb
Class Attribute Summary collapse
-
.postscript ⇒ Object
Returns the value of attribute postscript.
-
.preambel ⇒ Object
Returns the value of attribute preambel.
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#postscript ⇒ Object
Returns the value of attribute postscript.
-
#preambel ⇒ Object
Returns the value of attribute preambel.
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, code, template) ⇒ ErrorMessage
constructor
A new instance of ErrorMessage.
- #text(options = {}) ⇒ Object
Methods inherited from Base
#<=>, all, all_names_as_string, clear, create, delete, #enable, enable, #enabled?, #eql?, find, find_all, inherited, #name?, register
Constructor Details
#initialize(name, code, template) ⇒ ErrorMessage
Returns a new instance of ErrorMessage.
37 38 39 40 41 42 |
# File 'lib/puppet_generator/models/error_message.rb', line 37 def initialize(name, code, template) super(name) @code = code @template = template end |
Class Attribute Details
.postscript ⇒ Object
Returns the value of attribute postscript.
7 8 9 |
# File 'lib/puppet_generator/models/error_message.rb', line 7 def postscript @postscript end |
.preambel ⇒ Object
Returns the value of attribute preambel.
7 8 9 |
# File 'lib/puppet_generator/models/error_message.rb', line 7 def preambel @preambel end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
5 6 7 |
# File 'lib/puppet_generator/models/error_message.rb', line 5 def code @code end |
#postscript ⇒ Object
Returns the value of attribute postscript.
5 6 7 |
# File 'lib/puppet_generator/models/error_message.rb', line 5 def postscript @postscript end |
#preambel ⇒ Object
Returns the value of attribute preambel.
5 6 7 |
# File 'lib/puppet_generator/models/error_message.rb', line 5 def preambel @preambel end |
Class Method Details
.init ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/puppet_generator/models/error_message.rb', line 16 def init Models::ErrorMessage.preambel = "Sorry, but I can't fullfill your request. " Models::ErrorMessage.postscript = "\n\n=================\nPlease read the manual on \"http://github.com/maxmeyer/puppet_generator\" for more information on how to use the script." Models::ErrorMessage.create :invalid_source, 1, "You entered an invalid source \"<%= @source %>\": it's not possible to use this source with \"<%= @command %>." Models::ErrorMessage.create :invalid_output_channel, 2, "You entered an invalid output channel: file or directory can be used." Models::ErrorMessage.create :empty_source, 3, "The source \"<%= @source %>\" you tell me to use does not contain any entries. Giving up." Models::ErrorMessage.create :unknown_import_filter, 4, "There's no import filter \"<%= @requested_import_filter %>\". Available import filters: <%= @available_import_filter %>." Models::ErrorMessage.create :invalid_yaml_input, 5, "The input is no YAML valid for this use case." Models::ErrorMessage.create :invalid_passwd_input, 6, "The input is no passwd file valid for this use case." Models::ErrorMessage.create :unknown_action, 7, "There's no action \"<%= @requested_actions %>\". Available actions: <%= @available_actions %>." Models::ErrorMessage.create :filesystem_error, 8, "The file/directory \"<%= @fs_object %>\" does not exist." Models::ErrorMessage.create :wrong_template_chosen, 9, "I was not able to find a suitable template for the given command \"<%= @command %>\", for the given tags \"<%= @tags %>\" and for the given destination \"<%= @destination %>\"." Models::ErrorMessage.create :interrupt, 98, "You pressed \"CTRL-C\". Exiting." m = Models::ErrorMessage.create :internal_error, 99, "Sorry, an internal error occured. This should not happen. Please send a bug report to the author and add the following output to that report:\n\n<%= @exception_message %>" m.postscript = "\n\n=================\nPlease go to \"http://github.com/maxmeyer/puppet_generator\" to open the bug report. Thank you very much." end |
.reset ⇒ Object
9 10 11 12 13 14 |
# File 'lib/puppet_generator/models/error_message.rb', line 9 def reset self.clear self.preambel = nil self.postscript = nil end |
Instance Method Details
#text(options = {}) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/puppet_generator/models/error_message.rb', line 44 def text(={}) result = [] result << ( preambel ? preambel : self.class.preambel ) result << Erubis::Eruby.new(@template).evaluate() result << ( postscript ? postscript : self.class.postscript ) result.join end |