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 312 def format diagnostic 313 if (location = format_location diagnostic) != "" 314 "#{format_severity(diagnostic)}#{format_message(diagnostic)}#{location}" 315 else 316 format_message(diagnostic) 317 end 318 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 322 def format_location diagnostic 323 file = diagnostic.file 324 file = (file.is_a?(String) && file.empty?) ? nil : file 325 line = pos = nil 326 if diagnostic.source_pos 327 line = diagnostic.source_pos.line 328 pos = diagnostic.source_pos.pos 329 end 330 331 if file && line && pos 332 " at #{file}:#{line}:#{pos}" 333 elsif file && line 334 " at #{file}:#{line}" 335 elsif line && pos 336 " at line #{line}:#{pos}" 337 elsif line 338 " at line #{line}" 339 elsif file 340 " in #{file}" 341 else 342 "" 343 end 344 end