Class: Lutaml::Xsd::PackageSource

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

Overview

Represents a loaded package as a source of schemas/types Not serializable - created at runtime from BasePackageConfig

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(package_path:, config:, repository:) ⇒ PackageSource

Returns a new instance of PackageSource.

Parameters:

  • package_path (String)

    Path to the LXR package

  • config (BasePackageConfig)

    Configuration for this package

  • repository (SchemaRepository)

    Loaded schema repository



15
16
17
18
19
# File 'lib/lutaml/xsd/package_source.rb', line 15

def initialize(package_path:, config:, repository:)
  @package_path = package_path
  @config = config
  @repository = repository
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



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

def config
  @config
end

#package_pathObject (readonly)

Returns the value of attribute package_path.



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

def package_path
  @package_path
end

#repositoryObject (readonly)

Returns the value of attribute repository.



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

def repository
  @repository
end

Instance Method Details

#conflict_resolutionString

Get conflict resolution strategy

Returns:

  • (String)


29
30
31
# File 'lib/lutaml/xsd/package_source.rb', line 29

def conflict_resolution
  @config.conflict_resolution
end

#include_schema?(schema_path) ⇒ Boolean

Check if a schema should be included

Parameters:

  • schema_path (String)

    Schema file path

Returns:

  • (Boolean)


61
62
63
# File 'lib/lutaml/xsd/package_source.rb', line 61

def include_schema?(schema_path)
  @config.include_schema?(schema_path)
end

#inspectString

Detailed inspection

Returns:

  • (String)


73
74
75
76
77
78
79
# File 'lib/lutaml/xsd/package_source.rb', line 73

def inspect
  "#<PackageSource:#{object_id} " \
    "path=#{@package_path.inspect} " \
    "priority=#{priority} " \
    "strategy=#{conflict_resolution} " \
    "namespaces=#{namespaces.size}>"
end

#namespace_remappingArray<NamespaceUriRemapping>

Get namespace remapping rules

Returns:



54
55
56
# File 'lib/lutaml/xsd/package_source.rb', line 54

def namespace_remapping
  @config.namespace_remapping || []
end

#namespacesArray<String>

Get all namespaces in this package

Returns:

  • (Array<String>)


35
36
37
# File 'lib/lutaml/xsd/package_source.rb', line 35

def namespaces
  @repository.all_namespaces
end

#priorityInteger

Get priority for conflict resolution

Returns:

  • (Integer)


23
24
25
# File 'lib/lutaml/xsd/package_source.rb', line 23

def priority
  @config.priority
end

#schema_filesArray<String>

Get all schema files in this package

Returns:

  • (Array<String>)


48
49
50
# File 'lib/lutaml/xsd/package_source.rb', line 48

def schema_files
  @repository.files || []
end

#to_sString

String representation

Returns:

  • (String)


67
68
69
# File 'lib/lutaml/xsd/package_source.rb', line 67

def to_s
  "PackageSource(#{File.basename(@package_path)}, priority=#{priority})"
end

#types_in_namespace(namespace_uri) ⇒ Array<String>

Get all type names in a specific namespace

Parameters:

  • namespace_uri (String)

    The namespace URI

Returns:

  • (Array<String>)


42
43
44
# File 'lib/lutaml/xsd/package_source.rb', line 42

def types_in_namespace(namespace_uri)
  @repository.all_type_names(namespace: namespace_uri)
end