Class: ArchSpec::Rules::MustBeEmptyRule
- Inherits:
-
Object
- Object
- ArchSpec::Rules::MustBeEmptyRule
- Defined in:
- lib/archspec/rules/component_rules.rb
Instance Attribute Summary collapse
-
#because ⇒ Object
readonly
Returns the value of attribute because.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #evaluate(graph) ⇒ Object
- #id ⇒ Object
-
#initialize(source, because: nil) ⇒ MustBeEmptyRule
constructor
A new instance of MustBeEmptyRule.
- #merge_key ⇒ Object
Constructor Details
#initialize(source, because: nil) ⇒ MustBeEmptyRule
Returns a new instance of MustBeEmptyRule.
8 9 10 11 |
# File 'lib/archspec/rules/component_rules.rb', line 8 def initialize(source, because: nil) @source = source.to_sym @because = because end |
Instance Attribute Details
#because ⇒ Object (readonly)
Returns the value of attribute because.
6 7 8 |
# File 'lib/archspec/rules/component_rules.rb', line 6 def because @because end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
6 7 8 |
# File 'lib/archspec/rules/component_rules.rb', line 6 def source @source end |
Instance Method Details
#evaluate(graph) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/archspec/rules/component_rules.rb', line 21 def evaluate(graph) component = graph.components[source] return [] unless component component.files.sort.map do |path| relative = graph.files[path]&.relative_path || path Diagnostic.new( rule: id, message: because ? "#{source} must stay empty: #{because}" : "#{source} must stay empty", location: SourceLocation.new(path, 1, 1), evidence: "#{relative} belongs to #{source}" ) end end |
#id ⇒ Object
17 18 19 |
# File 'lib/archspec/rules/component_rules.rb', line 17 def id 'components.empty' end |
#merge_key ⇒ Object
13 14 15 |
# File 'lib/archspec/rules/component_rules.rb', line 13 def merge_key [self.class, source] end |