class Puppet::Pops::Validation::DiagnosticFormatterPuppetStyle
Produces a diagnostic output in the “puppet style”, where the location is appended with an “at …” if the location is known.
Public Instance Methods
format(diagnostic)
click to toggle source
# File lib/puppet/pops/validation.rb 313 def format diagnostic 314 if (location = format_location diagnostic) != "" 315 "#{format_severity(diagnostic)}#{format_message(diagnostic)}#{location}" 316 else 317 format_message(diagnostic) 318 end 319 end
format_location(diagnostic)
click to toggle source
The somewhat (machine) unusable format in current use by puppet. have to be used here for backwards compatibility.
# File lib/puppet/pops/validation.rb 323 def format_location diagnostic 324 file = diagnostic.file 325 file = (file.is_a?(String) && file.empty?) ? nil : file 326 line = pos = nil 327 if diagnostic.source_pos 328 line = diagnostic.source_pos.line 329 pos = diagnostic.source_pos.pos 330 end 331 332 if file && line && pos 333 " at #{file}:#{line}:#{pos}" 334 elsif file && line 335 " at #{file}:#{line}" 336 elsif line && pos 337 " at line #{line}:#{pos}" 338 elsif line 339 " at line #{line}" 340 elsif file 341 " in #{file}" 342 else 343 "" 344 end 345 end