class Puppet::Pops::Issues::Issue

Describes an issue, and can produce a message for an occurrence of the issue.

Attributes

arg_names[R]

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`.

demotable[W]

If this issue can have its severity lowered to :warning, :deprecation, or :ignored

issue_code[R]

The issue code @return [Symbol]

message_block[R]

A block producing the message @return [Proc]

Public Instance Methods

demotable?() click to toggle source

Returns true if it is allowed to demote this issue

# File lib/puppet/pops/issues.rb, line 33
def demotable?
  @demotable
end
format(hash ={}) click to toggle source

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, line 43
def format(hash ={})
  # Create a Message Data where all hash keys become methods for convenient interpolation
  # in issue text.
  msgdata = MessageData.new(*arg_names)
  begin
    # Evaluate the message block in the msg data's binding
    msgdata.format(hash, &message_block)
  rescue StandardError => e
    Puppet::Pops::Issues::MessageData
    raise RuntimeError, "Error while reporting issue: #{issue_code}. #{e.message}", caller
  end
end

Public Class Methods

new(issue_code, *args, &block) click to toggle source

Configures the Issue with required arguments (bound by occurrence), and a block producing a message.

# File lib/puppet/pops/issues.rb, line 25
def initialize issue_code, *args, &block
  @issue_code = issue_code
  @message_block = block
  @arg_names = args
  @demotable = true
end