Class: Lutaml::Xsd::CoverageReport

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

Overview

Value object representing coverage analysis results Immutable data structure with computed properties

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(all_types:, used_types:, entry_types:, by_namespace:) ⇒ CoverageReport

Returns a new instance of CoverageReport.



151
152
153
154
155
156
# File 'lib/lutaml/xsd/coverage_analyzer.rb', line 151

def initialize(all_types:, used_types:, entry_types:, by_namespace:)
  @all_types = all_types
  @used_types = used_types
  @entry_types = entry_types
  @by_namespace = by_namespace
end

Instance Attribute Details

#all_typesObject (readonly)

Returns the value of attribute all_types.



149
150
151
# File 'lib/lutaml/xsd/coverage_analyzer.rb', line 149

def all_types
  @all_types
end

#by_namespaceObject (readonly)

Returns the value of attribute by_namespace.



149
150
151
# File 'lib/lutaml/xsd/coverage_analyzer.rb', line 149

def by_namespace
  @by_namespace
end

#entry_typesObject (readonly)

Returns the value of attribute entry_types.



149
150
151
# File 'lib/lutaml/xsd/coverage_analyzer.rb', line 149

def entry_types
  @entry_types
end

#used_typesObject (readonly)

Returns the value of attribute used_types.



149
150
151
# File 'lib/lutaml/xsd/coverage_analyzer.rb', line 149

def used_types
  @used_types
end

Instance Method Details

#coverage_percentageFloat

Overall coverage percentage

Returns:

  • (Float)


184
185
186
187
188
# File 'lib/lutaml/xsd/coverage_analyzer.rb', line 184

def coverage_percentage
  return 0.0 if total_types.zero?

  (used_count.to_f / total_types * 100).round(2)
end

#to_hHash

Convert to hash for serialization

Returns:

  • (Hash)


192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/lutaml/xsd/coverage_analyzer.rb', line 192

def to_h
  {
    summary: {
      total_types: total_types,
      used_types: used_count,
      unused_types: unused_count,
      coverage_percentage: coverage_percentage,
      entry_types: entry_types,
    },
    by_namespace: format_namespace_data,
    unused_type_details: format_unused_types,
  }
end

#total_typesInteger

Total number of types in the repository

Returns:

  • (Integer)


160
161
162
# File 'lib/lutaml/xsd/coverage_analyzer.rb', line 160

def total_types
  all_types.size
end

#unused_countInteger

Number of unused types

Returns:

  • (Integer)


178
179
180
# File 'lib/lutaml/xsd/coverage_analyzer.rb', line 178

def unused_count
  unused_types.size
end

#unused_typesSet<String>

Get unused types (MECE: mutually exclusive with used_types)

Returns:

  • (Set<String>)


172
173
174
# File 'lib/lutaml/xsd/coverage_analyzer.rb', line 172

def unused_types
  all_types - used_types
end

#used_countInteger

Number of used types

Returns:

  • (Integer)


166
167
168
# File 'lib/lutaml/xsd/coverage_analyzer.rb', line 166

def used_count
  used_types.size
end