lutaml-xsd 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/lutaml/xsd/schema.rb +12 -17
- data/lib/lutaml/xsd/version.rb +1 -1
- data/lib/lutaml/xsd.rb +23 -3
- data/lib/lutaml_xsd.rb +3 -0
- metadata +3 -3
- data/lib/lutaml/xsd/xsd.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8d8b1ad8e625ee8cab24750b1431684ee5a7129c5fbd94d2f238bc1742eaf0b
|
4
|
+
data.tar.gz: fd018a29d844d9a4c2e6ae3b7b59a2c6520e4a3ca2a9f5c6ab59548a125806bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f2f77d3f47cb88123d7addac782e80f41f2ee6362758841aabfc90934976b3ac26e7d47e7eadd975c6d5744acfa1d2f8a53462e949f486e3ad5b0152a2bfec5
|
7
|
+
data.tar.gz: 1da9d9df59da0f84fb0f1f374b7b28e7ff1d3d83ced963513482630dec9954b2fcffc5482c81134ebe1d160b6920c2248ad5008d722ec9ad7f846da6746da20e
|
data/lib/lutaml/xsd/schema.rb
CHANGED
@@ -9,6 +9,7 @@ module Lutaml
|
|
9
9
|
attribute :xmlns, :string
|
10
10
|
attribute :version, :string
|
11
11
|
attribute :imported, :boolean
|
12
|
+
attribute :included, :boolean
|
12
13
|
attribute :final_default, :string
|
13
14
|
attribute :block_default, :string
|
14
15
|
attribute :target_namespace, :string
|
@@ -57,7 +58,7 @@ module Lutaml
|
|
57
58
|
|
58
59
|
def import_from_schema(model, value)
|
59
60
|
value.each do |schema|
|
60
|
-
setup_import_and_include("import", model, schema, namespace: schema
|
61
|
+
setup_import_and_include("import", model, schema, namespace: schema.attributes["namespace"].value)
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
@@ -77,16 +78,18 @@ module Lutaml
|
|
77
78
|
end
|
78
79
|
|
79
80
|
def include_to_schema(model, parent, _doc)
|
80
|
-
model.
|
81
|
+
return if model.included
|
82
|
+
|
83
|
+
model.included = true
|
84
|
+
model.includes.each do |schema_hash|
|
81
85
|
parent.add_child(schema_hash.to_xml)
|
82
|
-
model.includes.delete_at(index)
|
83
86
|
end
|
84
87
|
end
|
85
88
|
|
86
89
|
private
|
87
90
|
|
88
91
|
def setup_import_and_include(klass, model, schema, args = {})
|
89
|
-
instance = init_instance_of(klass, schema
|
92
|
+
instance = init_instance_of(klass, schema.attributes || {}, args)
|
90
93
|
annotation_object(instance, schema)
|
91
94
|
model.send("#{klass}s") << instance
|
92
95
|
schema_path = instance.schema_path
|
@@ -97,17 +100,9 @@ module Lutaml
|
|
97
100
|
self.class.remove_in_progress(schema_path)
|
98
101
|
end
|
99
102
|
|
100
|
-
def dig_schema_location(schema_hash)
|
101
|
-
schema_hash&.dig("__schema_location", :schema_location)
|
102
|
-
end
|
103
|
-
|
104
|
-
def schema_location?(schema_hash)
|
105
|
-
schema_hash&.dig("__schema_location")&.key?(:schema_location)
|
106
|
-
end
|
107
|
-
|
108
103
|
def init_instance_of(klass, schema_hash, args = {})
|
109
|
-
args[:id] = schema_hash["id"]
|
110
|
-
args[:schema_path] =
|
104
|
+
args[:id] = schema_hash["id"].value if schema_hash&.key?("id")
|
105
|
+
args[:schema_path] = schema_hash["schemaLocation"].value if schema_hash&.key?("schemaLocation")
|
111
106
|
Lutaml::Xsd.const_get(klass.capitalize).new(**args)
|
112
107
|
end
|
113
108
|
|
@@ -132,11 +127,11 @@ module Lutaml
|
|
132
127
|
end
|
133
128
|
|
134
129
|
def annotation_object(instance, schema)
|
135
|
-
elements = schema
|
136
|
-
annotation_key = elements.
|
130
|
+
elements = schema.children || []
|
131
|
+
annotation_key = elements.find { |element| element.unprefixed_name == "annotation" }
|
137
132
|
return unless annotation_key
|
138
133
|
|
139
|
-
instance.annotation = Annotation.apply_mappings(
|
134
|
+
instance.annotation = Annotation.apply_mappings(annotation_key, :xml)
|
140
135
|
end
|
141
136
|
|
142
137
|
class << self
|
data/lib/lutaml/xsd/version.rb
CHANGED
data/lib/lutaml/xsd.rb
CHANGED
@@ -2,11 +2,31 @@
|
|
2
2
|
|
3
3
|
require "zeitwerk"
|
4
4
|
require "lutaml/model"
|
5
|
-
|
6
|
-
|
5
|
+
require "lutaml/model/xml_adapter/nokogiri_adapter"
|
7
6
|
Lutaml::Model::Config.xml_adapter_type = :nokogiri
|
8
7
|
|
9
8
|
loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: true)
|
9
|
+
loader.push_dir(__dir__, namespace: Lutaml)
|
10
10
|
loader.push_dir("#{__dir__}/xsd", namespace: Lutaml::Xsd)
|
11
|
-
loader.ignore("#{__dir__}/lib/lutaml/xsd.rb")
|
12
11
|
loader.setup
|
12
|
+
|
13
|
+
module Lutaml
|
14
|
+
module Xsd
|
15
|
+
class Error < StandardError; end
|
16
|
+
|
17
|
+
module_function
|
18
|
+
|
19
|
+
def parse(xsd, location: nil, nested_schema: false)
|
20
|
+
Schema.reset_processed_schemas unless nested_schema
|
21
|
+
|
22
|
+
Glob.path_or_url(location)
|
23
|
+
Schema.from_xml(xsd)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
begin
|
29
|
+
loader.eager_load(force: true)
|
30
|
+
rescue Zeitwerk::NameError => e
|
31
|
+
flunk e.message
|
32
|
+
end
|
data/lib/lutaml_xsd.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lutaml-xsd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lutaml-model
|
@@ -106,7 +106,7 @@ files:
|
|
106
106
|
- lib/lutaml/xsd/unique.rb
|
107
107
|
- lib/lutaml/xsd/version.rb
|
108
108
|
- lib/lutaml/xsd/white_space.rb
|
109
|
-
- lib/
|
109
|
+
- lib/lutaml_xsd.rb
|
110
110
|
- lutaml-xsd.gemspec
|
111
111
|
- sig/lutaml/xsd.rbs
|
112
112
|
homepage: https://github.com/lutaml/expressir
|
data/lib/lutaml/xsd/xsd.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Lutaml
|
4
|
-
module Xsd
|
5
|
-
class Error < StandardError; end
|
6
|
-
|
7
|
-
module_function
|
8
|
-
|
9
|
-
def parse(xsd, location: nil, nested_schema: false)
|
10
|
-
Schema.reset_processed_schemas unless nested_schema
|
11
|
-
|
12
|
-
Glob.path_or_url(location)
|
13
|
-
Schema.from_xml(xsd)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|