class Puppet::Pops::Validation::DiagnosticFormatter
Formats a diagnostic for output. Produces a diagnostic output typical for a compiler (suitable for interpretation by tools) The format is: `file:line:pos: Message`, where pos, line and file are included if available.
Public Instance Methods
format(diagnostic)
click to toggle source
# File lib/puppet/pops/validation.rb 271 def format diagnostic 272 "#{format_location(diagnostic)} #{format_severity(diagnostic)}#{format_message(diagnostic)}" 273 end
format_location(diagnostic)
click to toggle source
# File lib/puppet/pops/validation.rb 288 def format_location diagnostic 289 file = diagnostic.file 290 file = (file.is_a?(String) && file.empty?) ? nil : file 291 line = pos = nil 292 if diagnostic.source_pos 293 line = diagnostic.source_pos.line 294 pos = diagnostic.source_pos.pos 295 end 296 if file && line && pos 297 "#{file}:#{line}:#{pos}:" 298 elsif file && line 299 "#{file}:#{line}:" 300 elsif file 301 "#{file}:" 302 else 303 "" 304 end 305 end
format_message(diagnostic)
click to toggle source
# File lib/puppet/pops/validation.rb 275 def format_message diagnostic 276 diagnostic.issue.format(diagnostic.arguments) 277 end
format_severity(diagnostic)
click to toggle source
This produces “Deprecation notice: ” prefix if the diagnostic has :deprecation severity, otherwise “”. The idea is that all other diagnostics are emitted with the methods Puppet.err (or an exception), and Puppet.warning. @note Note that it is not a good idea to use Puppet.deprecation_warning as it is for internal deprecation.
# File lib/puppet/pops/validation.rb 284 def format_severity diagnostic 285 diagnostic.severity == :deprecation ? "Deprecation notice: " : "" 286 end