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.



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

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.



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

def all_types
  @all_types
end

#by_namespaceObject (readonly)

Returns the value of attribute by_namespace.



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

def by_namespace
  @by_namespace
end

#entry_typesObject (readonly)

Returns the value of attribute entry_types.



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

def entry_types
  @entry_types
end

#used_typesObject (readonly)

Returns the value of attribute used_types.



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

def used_types
  @used_types
end

Instance Method Details

#coverage_percentageFloat

Overall coverage percentage

Returns:

  • (Float)


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

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)


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

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)


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

def total_types
  all_types.size
end

#unused_countInteger

Number of unused types

Returns:

  • (Integer)


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

def unused_count
  unused_types.size
end

#unused_typesSet<String>

Get unused types (MECE: mutually exclusive with used_types)

Returns:

  • (Set<String>)


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

def unused_types
  all_types - used_types
end

#used_countInteger

Number of used types

Returns:

  • (Integer)


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

def used_count
  used_types.size
end