Class: Puppet::Pops::Validation::DiagnosticFormatterPuppetStyle Private
- Inherits:
-
DiagnosticFormatter
- Object
- DiagnosticFormatter
- Puppet::Pops::Validation::DiagnosticFormatterPuppetStyle
- Defined in:
- lib/puppet/pops/validation.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Produces a diagnostic output in the “puppet style”, where the location is appended with an “at …” if the location is known.
Instance Method Summary collapse
- #format(diagnostic) ⇒ Object private
-
#format_location(diagnostic) ⇒ Object
private
The somewhat (machine) unusable format in current use by puppet.
Methods inherited from DiagnosticFormatter
#format_message, #format_severity
Instance Method Details
#format(diagnostic) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
315 316 317 318 319 320 321 |
# File 'lib/puppet/pops/validation.rb', line 315 def format diagnostic if (location = format_location diagnostic) != "" "#{format_severity(diagnostic)}#{(diagnostic)}#{location}" else (diagnostic) end end |
#format_location(diagnostic) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The somewhat (machine) unusable format in current use by puppet. have to be used here for backwards compatibility.
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/puppet/pops/validation.rb', line 325 def format_location diagnostic file = diagnostic.file file = (file.is_a?(String) && file.empty?) ? nil : file line = pos = nil if diagnostic.source_pos line = diagnostic.source_pos.line pos = diagnostic.source_pos.pos end if file && line && pos " at #{file}:#{line}:#{pos}" elsif file && line " at #{file}:#{line}" elsif line && pos " at line #{line}:#{pos}" elsif line " at line #{line}" elsif file " in #{file}" else "" end end |