Class: Lutaml::Xsd::CoverageAnalyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/xsd/coverage_analyzer.rb

Overview

Analyzes schema coverage based on entry point types Single responsibility: trace type usage from entry points

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository) ⇒ CoverageAnalyzer

Returns a new instance of CoverageAnalyzer.



12
13
14
15
16
# File 'lib/lutaml/xsd/coverage_analyzer.rb', line 12

def initialize(repository)
  @repository = repository
  @type_index = repository.instance_variable_get(:@type_index)
  @dependency_grapher = DependencyGrapher.new(repository)
end

Instance Attribute Details

#repositoryObject (readonly)

Returns the value of attribute repository.



10
11
12
# File 'lib/lutaml/xsd/coverage_analyzer.rb', line 10

def repository
  @repository
end

Instance Method Details

#analyze(entry_types: []) ⇒ CoverageReport

Analyze coverage starting from entry types

Parameters:

  • entry_types (Array<String>) (defaults to: [])

    Entry point type names

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/lutaml/xsd/coverage_analyzer.rb', line 21

def analyze(entry_types: [])
  # Collect all types across all namespaces
  all_types = collect_all_types

  # Trace all types reachable from entry points
  used_types = trace_dependencies_from_entries(entry_types)

  # Calculate coverage per namespace
  by_namespace = analyze_by_namespace(all_types, used_types)

  CoverageReport.new(
    all_types: all_types,
    used_types: used_types,
    entry_types: entry_types,
    by_namespace: by_namespace,
  )
end