Class: ArchSpec::Rules::NoCyclesRule
- Inherits:
-
Object
- Object
- ArchSpec::Rules::NoCyclesRule
- Defined in:
- lib/archspec/rules/cycle_rule.rb
Instance Attribute Summary collapse
-
#components ⇒ Object
readonly
Returns the value of attribute components.
Instance Method Summary collapse
- #evaluate(graph) ⇒ Object
- #id ⇒ Object
-
#initialize(among: nil) ⇒ NoCyclesRule
constructor
A new instance of NoCyclesRule.
Constructor Details
#initialize(among: nil) ⇒ NoCyclesRule
Returns a new instance of NoCyclesRule.
6 7 8 |
# File 'lib/archspec/rules/cycle_rule.rb', line 6 def initialize(among: nil) @components = Array(among).compact.map(&:to_sym) end |
Instance Attribute Details
#components ⇒ Object (readonly)
Returns the value of attribute components.
4 5 6 |
# File 'lib/archspec/rules/cycle_rule.rb', line 4 def components @components end |
Instance Method Details
#evaluate(graph) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/archspec/rules/cycle_rule.rb', line 14 def evaluate(graph) cycles(graph).map do |cycle| location = first_location_for_cycle(graph, cycle) || SourceLocation.new(graph.root, 1, 1) Diagnostic.new( rule: id, message: "component dependency cycle: #{cycle.join(" -> ")}", location: location, evidence: cycle.join(" -> ") ) end end |
#id ⇒ Object
10 11 12 |
# File 'lib/archspec/rules/cycle_rule.rb', line 10 def id "dependencies.no_cycles" end |