Class: McpDiff::Core::Rule
- Inherits:
-
Object
- Object
- McpDiff::Core::Rule
- Defined in:
- lib/mcp_diff/core/rule.rb
Overview
A single classification rule. The match block is instance_exec'd on the
rule so it can call finding(...) and read id/severity — mirroring the
TS this.id / this.class shape. Returns a Finding hash, an array of
them, or nil. Findings use string keys to match the --json output shape.
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
Instance Method Summary collapse
- #finding(target, message) ⇒ Object
-
#initialize(id:, severity:, description:, &match) ⇒ Rule
constructor
A new instance of Rule.
- #match(change) ⇒ Object
Constructor Details
#initialize(id:, severity:, description:, &match) ⇒ Rule
Returns a new instance of Rule.
12 13 14 15 16 17 |
# File 'lib/mcp_diff/core/rule.rb', line 12 def initialize(id:, severity:, description:, &match) @id = id @severity = severity @description = description @match = match end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
10 11 12 |
# File 'lib/mcp_diff/core/rule.rb', line 10 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/mcp_diff/core/rule.rb', line 10 def id @id end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
10 11 12 |
# File 'lib/mcp_diff/core/rule.rb', line 10 def severity @severity end |
Instance Method Details
#finding(target, message) ⇒ Object
23 24 25 |
# File 'lib/mcp_diff/core/rule.rb', line 23 def finding(target, ) { "ruleId" => @id, "class" => @severity, "target" => target, "message" => } end |
#match(change) ⇒ Object
19 20 21 |
# File 'lib/mcp_diff/core/rule.rb', line 19 def match(change) instance_exec(change, &@match) end |