Class: ArchUnit::Metrics::FluentApi::MetricsBuilder
- Inherits:
-
Object
- Object
- ArchUnit::Metrics::FluentApi::MetricsBuilder
- Defined in:
- lib/archunit/metrics/fluentapi/metrics_builder.rb
Overview
Immutable scope builder for numeric metrics over Ruby source.
Instance Attribute Summary collapse
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
-
#project_locator ⇒ Object
readonly
Returns the value of attribute project_locator.
Instance Method Summary collapse
- #analyze ⇒ Object
- #count ⇒ Object
- #custom_metric(name, description, calculation) ⇒ Object
- #distance ⇒ Object
- #for_classes_matching(pattern, except: nil) ⇒ Object
- #in_folder(pattern, except: nil) ⇒ Object
- #in_path(pattern, except: nil) ⇒ Object
-
#initialize(project_locator: nil, filters: []) ⇒ MetricsBuilder
constructor
A new instance of MetricsBuilder.
- #lcom ⇒ Object
- #with_name(pattern, except: nil) ⇒ Object
Constructor Details
#initialize(project_locator: nil, filters: []) ⇒ MetricsBuilder
Returns a new instance of MetricsBuilder.
20 21 22 23 24 |
# File 'lib/archunit/metrics/fluentapi/metrics_builder.rb', line 20 def initialize(project_locator: nil, filters: []) @project_locator = immutable_project_locator(project_locator) @filters = immutable_filters(filters) freeze end |
Instance Attribute Details
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
18 19 20 |
# File 'lib/archunit/metrics/fluentapi/metrics_builder.rb', line 18 def filters @filters end |
#project_locator ⇒ Object (readonly)
Returns the value of attribute project_locator.
18 19 20 |
# File 'lib/archunit/metrics/fluentapi/metrics_builder.rb', line 18 def project_locator @project_locator end |
Instance Method Details
#analyze ⇒ Object
58 59 60 61 62 |
# File 'lib/archunit/metrics/fluentapi/metrics_builder.rb', line 58 def analyze project = Extraction.extract_project_info(project_locator) selected_files = project.files.filter_map { |file| selected_file_info(file) } Extraction::ProjectInfo.new(project_root: project.project_root, files: selected_files) end |
#count ⇒ Object
42 43 44 |
# File 'lib/archunit/metrics/fluentapi/metrics_builder.rb', line 42 def count CountMetricsBuilder.new(self) end |
#custom_metric(name, description, calculation) ⇒ Object
54 55 56 |
# File 'lib/archunit/metrics/fluentapi/metrics_builder.rb', line 54 def custom_metric(name, description, calculation) CustomMetricBuilder.new(scope: self, name:, description:, calculation:) end |
#distance ⇒ Object
50 51 52 |
# File 'lib/archunit/metrics/fluentapi/metrics_builder.rb', line 50 def distance DistanceMetricsBuilder.new(self) end |
#for_classes_matching(pattern, except: nil) ⇒ Object
38 39 40 |
# File 'lib/archunit/metrics/fluentapi/metrics_builder.rb', line 38 def for_classes_matching(pattern, except: nil) with_filter(Common::RegexFactory.classname_matcher(pattern, except:)) end |
#in_folder(pattern, except: nil) ⇒ Object
30 31 32 |
# File 'lib/archunit/metrics/fluentapi/metrics_builder.rb', line 30 def in_folder(pattern, except: nil) with_filter(Common::RegexFactory.folder_matcher(pattern, except:)) end |
#in_path(pattern, except: nil) ⇒ Object
34 35 36 |
# File 'lib/archunit/metrics/fluentapi/metrics_builder.rb', line 34 def in_path(pattern, except: nil) with_filter(Common::RegexFactory.path_matcher(pattern, except:)) end |
#lcom ⇒ Object
46 47 48 |
# File 'lib/archunit/metrics/fluentapi/metrics_builder.rb', line 46 def lcom LCOMMetricsBuilder.new(self) end |
#with_name(pattern, except: nil) ⇒ Object
26 27 28 |
# File 'lib/archunit/metrics/fluentapi/metrics_builder.rb', line 26 def with_name(pattern, except: nil) with_filter(Common::RegexFactory.filename_matcher(pattern, except:)) end |