Class: Lutaml::UmlRepository::StatisticsCalculator

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/uml_repository/statistics_calculator.rb

Overview

StatisticsCalculator provides comprehensive statistics about a UML repository

Calculates detailed metrics including:

  • Package statistics (depth distribution, sizes)

  • Class statistics (by stereotype, complexity)

  • Attribute statistics (type distribution, multiplicity)

  • Association statistics

  • Diagram statistics

  • Model quality metrics

Examples:

Getting repository statistics

calculator = StatisticsCalculator.new(document, indexes)
stats = calculator.calculate
puts "Total packages: #{stats[:total_packages]}"
puts "Most complex class: #{stats[:most_complex_classes].first[:name]}"

Instance Method Summary collapse

Constructor Details

#initialize(document, indexes) ⇒ StatisticsCalculator

Returns a new instance of StatisticsCalculator.

Parameters:



26
27
28
29
# File 'lib/lutaml/uml_repository/statistics_calculator.rb', line 26

def initialize(document, indexes)
  @document = document
  @indexes = indexes
end

Instance Method Details

#calculateHash

Calculate comprehensive statistics for the repository

Returns:

  • (Hash)

    Statistics hash with detailed metrics



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/lutaml/uml_repository/statistics_calculator.rb', line 34

def calculate # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
  {
    # Basic counts
    total_packages: package_count,
    total_classes: class_count,
    total_data_types: data_type_count,
    total_enums: enum_count,
    total_diagrams: diagram_count,

    # Package statistics
    packages_by_depth: packages_by_depth,
    max_package_depth: max_depth,
    avg_package_depth: avg_package_depth,

    # Class statistics
    classes_by_stereotype: classes_by_stereotype,
    most_complex_classes: most_complex_classes(limit: 10),
    avg_class_complexity: avg_class_complexity,

    # Attribute statistics
    total_attributes: attribute_count,
    attribute_type_distribution: attribute_type_distribution,

    # Association statistics
    total_associations: association_count,

    # Inheritance statistics
    total_inheritance_relationships: inheritance_count,
    max_inheritance_depth: max_inheritance_depth,

    # Model quality metrics
    abstract_class_count: abstract_class_count,
    classes_without_documentation: undocumented_classes_count,
    classes_without_attributes: classes_without_attributes_count,
  }
end