Class: ArchSpec::Diagnostic
- Inherits:
-
Object
- Object
- ArchSpec::Diagnostic
- Defined in:
- lib/archspec/diagnostic.rb
Instance Attribute Summary collapse
-
#confidence ⇒ Object
readonly
Returns the value of attribute confidence.
-
#evidence ⇒ Object
readonly
Returns the value of attribute evidence.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#rule ⇒ Object
readonly
Returns the value of attribute rule.
Instance Method Summary collapse
- #fingerprint(root: nil) ⇒ Object
-
#initialize(rule:, message:, location:, evidence:, confidence: :high) ⇒ Diagnostic
constructor
A new instance of Diagnostic.
- #to_h(root:) ⇒ Object
Constructor Details
#initialize(rule:, message:, location:, evidence:, confidence: :high) ⇒ Diagnostic
Returns a new instance of Diagnostic.
7 8 9 10 11 12 13 |
# File 'lib/archspec/diagnostic.rb', line 7 def initialize(rule:, message:, location:, evidence:, confidence: :high) @rule = rule @message = @location = location @evidence = evidence @confidence = confidence end |
Instance Attribute Details
#confidence ⇒ Object (readonly)
Returns the value of attribute confidence.
5 6 7 |
# File 'lib/archspec/diagnostic.rb', line 5 def confidence @confidence end |
#evidence ⇒ Object (readonly)
Returns the value of attribute evidence.
5 6 7 |
# File 'lib/archspec/diagnostic.rb', line 5 def evidence @evidence end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
5 6 7 |
# File 'lib/archspec/diagnostic.rb', line 5 def location @location end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'lib/archspec/diagnostic.rb', line 5 def @message end |
#rule ⇒ Object (readonly)
Returns the value of attribute rule.
5 6 7 |
# File 'lib/archspec/diagnostic.rb', line 5 def rule @rule end |
Instance Method Details
#fingerprint(root: nil) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/archspec/diagnostic.rb', line 15 def fingerprint(root: nil) path = root ? location.relative_path(root) : location.path Digest::SHA256.hexdigest( [rule, , path, location.line, evidence].join("\0") )[0, 24] end |
#to_h(root:) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/archspec/diagnostic.rb', line 23 def to_h(root:) { id: fingerprint(root: root), rule: rule, message: , path: location.relative_path(root), line: location.line, column: location.column, evidence: evidence, confidence: confidence.to_s } end |