Class: Puppet::Pops::Validation::DiagnosticFormatterPuppetStyle
- Inherits:
-
DiagnosticFormatter
- Object
- DiagnosticFormatter
- Puppet::Pops::Validation::DiagnosticFormatterPuppetStyle
- Defined in:
- lib/puppet/pops/validation.rb
Overview
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
-
#format_location(diagnostic) ⇒ Object
The somewhat (machine) unusable format in current use by puppet.
Methods inherited from DiagnosticFormatter
#format_message, #format_severity
Instance Method Details
#format(diagnostic) ⇒ Object
279 280 281 282 283 284 285 |
# File 'lib/puppet/pops/validation.rb', line 279 def format diagnostic if (location = format_location diagnostic) != "" "#{format_severity(diagnostic)}#{format_message(diagnostic)}#{location}" else (diagnostic) end end |
#format_location(diagnostic) ⇒ Object
The somewhat (machine) unusable format in current use by puppet. have to be used here for backwards compatibility.
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
# File 'lib/puppet/pops/validation.rb', line 289 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 and line " at #{file}:#{line}" elsif line && pos " at line #{line}:#{pos}" elsif line " at line #{line}" elsif file " in #{file}" else "" end end |