Class: ArchUnit::Slices::FluentApi::SliceScopeBuilder
- Inherits:
-
Object
- Object
- ArchUnit::Slices::FluentApi::SliceScopeBuilder
- Defined in:
- lib/archunit/slices/fluentapi/slice_scope_builder.rb
Overview
Immutable scope describing how project files become named slices.
Instance Attribute Summary collapse
-
#project_locator ⇒ Object
readonly
Returns the value of attribute project_locator.
-
#projection ⇒ Object
readonly
Returns the value of attribute projection.
Instance Method Summary collapse
-
#defined_by(pattern, except: nil) ⇒ SliceScopeBuilder
Captures slice names with the
(**)segment in a glob pattern. -
#defined_by_regex(regexp, except: nil) ⇒ SliceScopeBuilder
Captures slice names with the first group in a regular expression.
-
#export_as_plantuml(output_path, options = nil) ⇒ nil
Writes the real slice graph as PlantUML.
-
#initialize(project_locator: nil, projection: Projection.identity) ⇒ SliceScopeBuilder
constructor
A new instance of SliceScopeBuilder.
-
#should ⇒ PositiveSliceConditionBuilder
Enters the positive slice-rule mood.
-
#should_not ⇒ NegativeSliceConditionBuilder
Enters the negated slice-rule mood.
-
#to_plantuml(options = nil) ⇒ String
Renders the real slice graph as PlantUML.
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_locator ⇒ Object (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 |
#projection ⇒ Object (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) ⇒ SliceScopeBuilder
Captures slice names with the (**) segment in a glob pattern.
27 28 29 |
# File 'lib/archunit/slices/fluentapi/slice_scope_builder.rb', line 27 def defined_by(pattern, except: nil) copy(projection: Projection.slice_by_pattern(pattern, except:)) end |
#defined_by_regex(regexp, except: nil) ⇒ SliceScopeBuilder
Captures slice names with the first group in a regular expression.
33 34 35 |
# File 'lib/archunit/slices/fluentapi/slice_scope_builder.rb', line 33 def defined_by_regex(regexp, except: nil) copy(projection: Projection.slice_by_regex(regexp, except:)) end |
#export_as_plantuml(output_path, options = nil) ⇒ nil
Writes the real slice graph as PlantUML.
59 60 61 62 63 64 65 |
# File 'lib/archunit/slices/fluentapi/slice_scope_builder.rb', line 59 def export_as_plantuml(output_path, = nil) graph = extract_graph() edges = Common::Projection.project_edges(graph, projection) Uml::PlantUmlRenderer.export( edges, output_path, components: projection.slice_labels(graph) ) end |
#should ⇒ PositiveSliceConditionBuilder
Enters the positive slice-rule mood.
45 46 47 |
# File 'lib/archunit/slices/fluentapi/slice_scope_builder.rb', line 45 def should PositiveSliceConditionBuilder.new(self) end |
#should_not ⇒ NegativeSliceConditionBuilder
Enters the negated slice-rule mood.
39 40 41 |
# File 'lib/archunit/slices/fluentapi/slice_scope_builder.rb', line 39 def should_not NegativeSliceConditionBuilder.new(self) end |
#to_plantuml(options = nil) ⇒ String
Renders the real slice graph as PlantUML.
51 52 53 54 55 |
# File 'lib/archunit/slices/fluentapi/slice_scope_builder.rb', line 51 def to_plantuml( = nil) graph = extract_graph() edges = Common::Projection.project_edges(graph, projection) Uml::PlantUmlRenderer.render(edges, components: projection.slice_labels(graph)) end |
ArchUnitRuby