class Puppet::Pops::Issues::Issue
Describes an issue, and can produce a message for an occurrence of the issue.
Attributes
Names that must be bound in an occurrence of the issue to be able to produce a message. These are the names in addition to requirements stipulated by the Issue
formatter contract; i.e. :label`, and `:semantic`.
If this issue can have its severity lowered to :warning, :deprecation, or :ignored
The issue code @return [Symbol]
A block producing the message @return [Proc]
Public Class Methods
Configures the Issue
with required arguments (bound by occurrence), and a block producing a message.
# File lib/puppet/pops/issues.rb 26 def initialize issue_code, *args, &block 27 @issue_code = issue_code 28 @message_block = block 29 @arg_names = args 30 @demotable = true 31 end
Public Instance Methods
Returns true if it is allowed to demote this issue
# File lib/puppet/pops/issues.rb 34 def demotable? 35 @demotable 36 end
Formats a message for an occurrence of the issue with argument bindings passed in a hash. The hash must contain a LabelProvider
bound to the key `label` and the semantic model element bound to the key `semantic`. All required arguments as specified by `arg_names` must be bound in the given `hash`. @api public
# File lib/puppet/pops/issues.rb 44 def format(hash ={}) 45 # Create a Message Data where all hash keys become methods for convenient interpolation 46 # in issue text. 47 msgdata = MessageData.new(*arg_names) 48 begin 49 # Evaluate the message block in the msg data's binding 50 msgdata.format(hash, &message_block) 51 rescue StandardError => e 52 raise RuntimeError, _("Error while reporting issue: %{code}. %{message}") % { code: issue_code, message: e.message }, caller 53 end 54 end