Class: ArchUnit::Slices::FluentApi::SliceScopeBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/archunit/slices/fluentapi/slice_scope_builder.rb

Overview

Immutable scope describing how project files become named slices.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_locator: nil, projection: Projection.identity) ⇒ SliceScopeBuilder

Returns a new instance of SliceScopeBuilder.



19
20
21
22
23
# File 'lib/archunit/slices/fluentapi/slice_scope_builder.rb', line 19

def initialize(project_locator: nil, projection: Projection.identity)
  @project_locator = immutable_project_locator(project_locator)
  @projection = projection_value(projection)
  freeze
end

Instance Attribute Details

#project_locatorObject (readonly)

Returns the value of attribute project_locator.



17
18
19
# File 'lib/archunit/slices/fluentapi/slice_scope_builder.rb', line 17

def project_locator
  @project_locator
end

#projectionObject (readonly)

Returns the value of attribute projection.



17
18
19
# File 'lib/archunit/slices/fluentapi/slice_scope_builder.rb', line 17

def projection
  @projection
end

Instance Method Details

#defined_by(pattern, except: nil) ⇒ Object



25
26
27
# File 'lib/archunit/slices/fluentapi/slice_scope_builder.rb', line 25

def defined_by(pattern, except: nil)
  copy(projection: Projection.slice_by_pattern(pattern, except:))
end

#defined_by_regex(regexp, except: nil) ⇒ Object



29
30
31
# File 'lib/archunit/slices/fluentapi/slice_scope_builder.rb', line 29

def defined_by_regex(regexp, except: nil)
  copy(projection: Projection.slice_by_regex(regexp, except:))
end

#export_as_plantuml(output_path, options = nil) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/archunit/slices/fluentapi/slice_scope_builder.rb', line 47

def export_as_plantuml(output_path, options = nil)
  graph = extract_graph(options)
  edges = Common::Projection.project_edges(graph, projection)
  Uml::PlantUmlRenderer.export(
    edges, output_path, components: projection.slice_labels(graph)
  )
end

#shouldObject



37
38
39
# File 'lib/archunit/slices/fluentapi/slice_scope_builder.rb', line 37

def should
  PositiveSliceConditionBuilder.new(self)
end

#should_notObject



33
34
35
# File 'lib/archunit/slices/fluentapi/slice_scope_builder.rb', line 33

def should_not
  NegativeSliceConditionBuilder.new(self)
end

#to_plantuml(options = nil) ⇒ Object



41
42
43
44
45
# File 'lib/archunit/slices/fluentapi/slice_scope_builder.rb', line 41

def to_plantuml(options = nil)
  graph = extract_graph(options)
  edges = Common::Projection.project_edges(graph, projection)
  Uml::PlantUmlRenderer.render(edges, components: projection.slice_labels(graph))
end