Class: Lutaml::Xsd::NamespacePrefixManager
- Inherits:
-
Object
- Object
- Lutaml::Xsd::NamespacePrefixManager
- Defined in:
- lib/lutaml/xsd/namespace_prefix_manager.rb
Overview
Manages namespace prefix information in a repository Single responsibility: analyze and report prefix usage
Instance Attribute Summary collapse
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
Instance Method Summary collapse
-
#detailed_prefix_info ⇒ Object
Get detailed prefix information Returns array of NamespacePrefixInfo objects.
-
#find_schema_for_namespace(namespace_uri) ⇒ Schema?
Find schema that defines a namespace.
-
#get_package_location(namespace_uri) ⇒ String?
Get package location for namespace’s schema.
-
#initialize(repository) ⇒ NamespacePrefixManager
constructor
A new instance of NamespacePrefixManager.
Constructor Details
#initialize(repository) ⇒ NamespacePrefixManager
Returns a new instance of NamespacePrefixManager.
10 11 12 |
# File 'lib/lutaml/xsd/namespace_prefix_manager.rb', line 10 def initialize(repository) @repository = repository end |
Instance Attribute Details
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
8 9 10 |
# File 'lib/lutaml/xsd/namespace_prefix_manager.rb', line 8 def repository @repository end |
Instance Method Details
#detailed_prefix_info ⇒ Object
Get detailed prefix information Returns array of NamespacePrefixInfo objects
16 17 18 19 20 |
# File 'lib/lutaml/xsd/namespace_prefix_manager.rb', line 16 def detailed_prefix_info repository.namespace_mappings.map do |mapping| NamespacePrefixInfo.new(mapping, repository) end end |
#find_schema_for_namespace(namespace_uri) ⇒ Schema?
Find schema that defines a namespace
25 26 27 28 29 30 31 32 33 |
# File 'lib/lutaml/xsd/namespace_prefix_manager.rb', line 25 def find_schema_for_namespace(namespace_uri) all_schemas = repository.send(:get_all_processed_schemas) all_schemas.each_value do |schema| return schema if schema.target_namespace == namespace_uri end nil end |
#get_package_location(namespace_uri) ⇒ String?
Get package location for namespace’s schema
38 39 40 41 42 43 44 45 46 |
# File 'lib/lutaml/xsd/namespace_prefix_manager.rb', line 38 def get_package_location(namespace_uri) all_schemas = repository.send(:get_all_processed_schemas) all_schemas.each do |file_path, schema| return file_path if schema.target_namespace == namespace_uri end nil end |