Class: Puppet::Pops::Validation::Diagnostic

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/pops/validation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(severity, issue, file, source_pos, arguments = {}, exception = nil) ⇒ Diagnostic

Returns a new instance of Diagnostic.



226
227
228
229
230
231
232
233
234
235
# File 'lib/puppet/pops/validation.rb', line 226

def initialize severity, issue, file, source_pos, arguments={}, exception=nil
  @severity = severity
  @issue = issue
  @file = file
  @source_pos = source_pos
  @arguments = arguments
  # TODO: Currently unused, the intention is to provide more information (stack backtrace, etc.) when
  # debugging or similar - this to catch internal problems reported as higher level issues.
  @exception = exception
end

Instance Attribute Details

#argumentsObject (readonly)



222
223
224
# File 'lib/puppet/pops/validation.rb', line 222

def arguments
  @arguments
end

#exceptionObject (readonly)



223
224
225
# File 'lib/puppet/pops/validation.rb', line 223

def exception
  @exception
end

#fileObject (readonly)



224
225
226
# File 'lib/puppet/pops/validation.rb', line 224

def file
  @file
end

#issueObject (readonly)



221
222
223
# File 'lib/puppet/pops/validation.rb', line 221

def issue
  @issue
end

#severityObject (readonly)



220
221
222
# File 'lib/puppet/pops/validation.rb', line 220

def severity
  @severity
end

#source_posObject (readonly)



225
226
227
# File 'lib/puppet/pops/validation.rb', line 225

def source_pos
  @source_pos
end

Instance Method Details

#==(o) ⇒ Object Also known as: eql?

Two diagnostics are considered equal if the have the same issue, location and severity (arguments and exception are ignored)



240
241
242
243
244
245
246
# File 'lib/puppet/pops/validation.rb', line 240

def ==(o)
  self.class            == o.class             &&
    same_position?(o)                          &&
    issue.issue_code    == o.issue.issue_code  &&
    file                == o.file              &&
    severity            == o.severity
end

#hashObject



255
256
257
# File 'lib/puppet/pops/validation.rb', line 255

def hash
  @hash ||= [file, source_pos.offset, issue.issue_code, severity].hash
end