Module: ArchUnit::Slices::Assertion

Defined in:
lib/archunit/slices/assertion/adhere_to_diagram.rb,
lib/archunit/slices/assertion/contain_dependency.rb,
lib/archunit/slices/assertion/diagram_adherence_options.rb,
lib/archunit/slices/assertion/slice_dependency_violation.rb

Overview

Pure assertions over projected slice dependencies.

Defined Under Namespace

Classes: DiagramAdherenceOptions, SliceDependencyViolation

Class Method Summary collapse

Class Method Details

.gather_diagram_adherence_violations(edges, diagram, options = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/archunit/slices/assertion/adhere_to_diagram.rb', line 14

def gather_diagram_adherence_violations(edges, diagram, options = nil)
  validate_diagram_arguments(edges, diagram, options)
  options ||= DiagramAdherenceOptions.new

  edges.filter_map do |edge|
    next if ignored_diagram_edge?(edge, diagram, options)
    next if diagram.allows?(edge.source_label, edge.target_label)

    SliceDependencyViolation.new(
      dependency: edge, source_slice: edge.source_label,
      target_slice: edge.target_label, rule: :adhere_to_diagram, is_negated: false
    )
  end
end

.gather_forbidden_slice_dependency_violations(edges, source_slice, target_slice) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/archunit/slices/assertion/contain_dependency.rb', line 12

def gather_forbidden_slice_dependency_violations(edges, source_slice, target_slice)
  validate_edges(edges)
  source_slice = validated_slice_name(source_slice, :source_slice)
  target_slice = validated_slice_name(target_slice, :target_slice)

  edges.filter_map do |edge|
    next unless edge.source_label == source_slice && edge.target_label == target_slice

    SliceDependencyViolation.new(
      dependency: edge, source_slice:, target_slice:,
      rule: :contain_dependency, is_negated: true
    )
  end
end