Class: ArchUnit::GraphReporting::FluentApi::ProjectGraphBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/archunit/graph/fluentapi/project_graph_builder.rb

Overview

Immutable query builder for dependency graph snapshots and reports.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_locator: nil, options: nil, check_options: nil) ⇒ ProjectGraphBuilder

Returns a new instance of ProjectGraphBuilder.



16
17
18
19
20
21
# File 'lib/archunit/graph/fluentapi/project_graph_builder.rb', line 16

def initialize(project_locator: nil, options: nil, check_options: nil)
  @project_locator = immutable_project_locator(project_locator)
  @options = Projection::GraphQueryOptions.resolve(options)
  @check_options = immutable_check_options(check_options)
  freeze
end

Instance Attribute Details

#check_optionsObject (readonly)

Returns the value of attribute check_options.



14
15
16
# File 'lib/archunit/graph/fluentapi/project_graph_builder.rb', line 14

def check_options
  @check_options
end

#optionsObject (readonly)

Returns the value of attribute options.



14
15
16
# File 'lib/archunit/graph/fluentapi/project_graph_builder.rb', line 14

def options
  @options
end

#project_locatorObject (readonly)

Returns the value of attribute project_locator.



14
15
16
# File 'lib/archunit/graph/fluentapi/project_graph_builder.rb', line 14

def project_locator
  @project_locator
end

Instance Method Details

#collapse_by_pattern(pattern, replacement = '\\1') ⇒ Object



50
51
52
53
# File 'lib/archunit/graph/fluentapi/project_graph_builder.rb', line 50

def collapse_by_pattern(pattern, replacement = '\\1')
  collapse = Projection::PatternCollapse.from(pattern, replacement)
  with_options(options.with(collapse:))
end

#collapse_to_folder_depth(depth) ⇒ Object



46
47
48
# File 'lib/archunit/graph/fluentapi/project_graph_builder.rb', line 46

def collapse_to_folder_depth(depth)
  with_options(options.with(collapse: Projection::FolderDepthCollapse.new(depth:)))
end

#dependents_of(pattern, except: nil) ⇒ Object



41
42
43
44
# File 'lib/archunit/graph/fluentapi/project_graph_builder.rb', line 41

def dependents_of(pattern, except: nil)
  filter = Common::RegexFactory.path_matcher(pattern, except:)
  with_options(options.with(dependents_of: filter))
end

#focus_on(pattern, depth = 1, except: nil) ⇒ Object



31
32
33
34
# File 'lib/archunit/graph/fluentapi/project_graph_builder.rb', line 31

def focus_on(pattern, depth = 1, except: nil)
  filter = Common::RegexFactory.path_matcher(pattern, except:)
  with_options(options.with(focus: filter, focus_depth: depth))
end

#include_external_dependenciesObject



23
24
25
# File 'lib/archunit/graph/fluentapi/project_graph_builder.rb', line 23

def include_external_dependencies
  with_options(options.with(include_external_dependencies: true))
end

#include_self_dependenciesObject



27
28
29
# File 'lib/archunit/graph/fluentapi/project_graph_builder.rb', line 27

def include_self_dependencies
  with_options(options.with(include_self_dependencies: true))
end

#reachable_from(pattern, except: nil) ⇒ Object



36
37
38
39
# File 'lib/archunit/graph/fluentapi/project_graph_builder.rb', line 36

def reachable_from(pattern, except: nil)
  filter = Common::RegexFactory.path_matcher(pattern, except:)
  with_options(options.with(reachable_from: filter))
end

#snapshotObject



63
64
65
66
# File 'lib/archunit/graph/fluentapi/project_graph_builder.rb', line 63

def snapshot
  graph = ArchUnit::Extraction.extract_graph(project_locator, options: check_options)
  Projection::SnapshotFactory.create(graph, options)
end

#summaryObject



68
69
70
# File 'lib/archunit/graph/fluentapi/project_graph_builder.rb', line 68

def summary
  snapshot.summary
end

#titled(title) ⇒ Object



55
56
57
# File 'lib/archunit/graph/fluentapi/project_graph_builder.rb', line 55

def titled(title)
  with_options(options.with(title:))
end

#with_check_options(value) ⇒ Object



59
60
61
# File 'lib/archunit/graph/fluentapi/project_graph_builder.rb', line 59

def with_check_options(value)
  self.class.new(project_locator:, options:, check_options: value)
end