Class: Lutaml::Xsd::Conflicts::NamespaceConflict

Inherits:
Model::Serializable
  • Object
show all
Defined in:
lib/lutaml/xsd/conflicts/namespace_conflict.rb

Overview

Namespace URI conflict between packages Serializable for reporting

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sourcesObject

Runtime-only (not serialized)



20
21
22
# File 'lib/lutaml/xsd/conflicts/namespace_conflict.rb', line 20

def sources
  @sources
end

Class Method Details

.from_sources(namespace_uri:, sources:) ⇒ NamespaceConflict

Create from PackageSource objects

Parameters:

  • namespace_uri (String)

    The namespace URI

  • sources (Array<PackageSource>)

    Conflicting package sources

Returns:



26
27
28
29
30
31
32
33
34
# File 'lib/lutaml/xsd/conflicts/namespace_conflict.rb', line 26

def self.from_sources(namespace_uri:, sources:)
  conflict = new(
    namespace_uri: namespace_uri,
    package_paths: sources.map(&:package_path),
    priorities: sources.map(&:priority),
  )
  conflict.sources = sources
  conflict
end

Instance Method Details

#conflict_countObject



36
37
38
# File 'lib/lutaml/xsd/conflicts/namespace_conflict.rb', line 36

def conflict_count
  package_paths.size
end

#detailed_descriptionObject



48
49
50
51
52
53
54
55
56
57
# File 'lib/lutaml/xsd/conflicts/namespace_conflict.rb', line 48

def detailed_description
  lines = []
  lines << "Namespace URI Conflict:"
  lines << "  Namespace: {#{namespace_uri}}"
  lines << "  Defined in packages:"
  package_paths.each_with_index do |path, idx|
    lines << "    - #{path} (priority: #{priorities[idx]})"
  end
  lines.join("\n")
end

#highest_priority_sourceObject



40
41
42
# File 'lib/lutaml/xsd/conflicts/namespace_conflict.rb', line 40

def highest_priority_source
  sources&.min_by(&:priority)
end

#to_sObject



44
45
46
# File 'lib/lutaml/xsd/conflicts/namespace_conflict.rb', line 44

def to_s
  "Namespace '{#{namespace_uri}}' defined in #{conflict_count} packages"
end