xsd 2.6.1 → 2.6.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73e87995baa341819126aaf56de8b4a865395423b6ea2f64c8a3aa8e702a611a
4
- data.tar.gz: d330c3d390ff34c43d7988e0fe30b99d8538c62ff60205e0164d3119118ed1c4
3
+ metadata.gz: f1d2b1ea3cf4fb7f11e131e1a7cb9f446682b8be0bb1a38bb90817a9c0ef8717
4
+ data.tar.gz: edbb623f773bd0909284728b42e71e8a49d6663159e7382d12cb9229f4057b05
5
5
  SHA512:
6
- metadata.gz: 0bfc579e3376d04a72c4ac593d9c944c7739b0dc4ffe0ea94399fbdfb11771bb8f7a4d356609a257e47e5ff3fefa7bae6c34a0ac0cb76c1b149614b25fe58994
7
- data.tar.gz: 2d44c024e3b658e2b907614a621db0d2367feac05e6abeb8c5e7bee027d830c3be6f4a438941141e17b1df626f3b5899793a9e7befc612bd28caae804812cf7b
6
+ metadata.gz: 0b474c9ac63f1dd09b4b1aef416eee487aeaa84135f12242ba7a9fde520094a42279a738b5ef99e4540b622c35b4dc0b581d1ec3b44fd6a98217022dba1ab66a
7
+ data.tar.gz: ea99e743a50f84952b78f2d43463482ab630175c7eafcc92567bb9a35044698a50b2b2d6e92d33f274b07a3b8f6b3d639358d6d4020b8db140350396c3e3e9c2
data/.rubocop.yml CHANGED
@@ -4,7 +4,7 @@ require:
4
4
  - rubocop-rspec
5
5
 
6
6
  AllCops:
7
- TargetRubyVersion: 3.2.2
7
+ TargetRubyVersion: 3.2.3
8
8
  NewCops: enable
9
9
  SuggestExtensions: false
10
10
 
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [2.6.3] - 2024-04-13
2
+
3
+ - Fix retrieving documentation for referenced elements
4
+ - Cache "namespace" call result
5
+
6
+ ## [2.6.2] - 2024-04-12
7
+
8
+ - Get default value for element/attribute "form" property from schema
9
+
1
10
  ## [2.6.1] - 2024-04-12
2
11
 
3
12
  - Correctly detect namespace for referenced elements
@@ -189,7 +189,16 @@ module XSD
189
189
  # Return element documentation
190
190
  # @return Array<String>
191
191
  def documentation
192
- documentation_for(node)
192
+ @documentation ||= begin
193
+ docs = documentation_for(node)
194
+ if docs.any?
195
+ docs
196
+ elsif is_a?(Referenced) && referenced?
197
+ documentation_for(reference.node)
198
+ else
199
+ []
200
+ end
201
+ end
193
202
  end
194
203
 
195
204
  # Return documentation for specified node
@@ -304,20 +313,24 @@ module XSD
304
313
  # check for property first
305
314
  if (property = self.class.properties[method])
306
315
  value = property[:resolve] ? property[:resolve].call(self) : node[property[:name].to_s]
307
- result = if value.nil?
308
- # if object has reference - search property in referenced object
309
- node['ref'] ? reference.send(method, *args) : property[:default]
310
- else
311
- case property[:type]
312
- when :integer
313
- property[:name] == :maxOccurs && value == 'unbounded' ? :unbounded : value.to_i
314
- when :boolean
315
- value == 'true'
316
- else
317
- value
318
- end
319
- end
320
- return @cache[method] = result
316
+ r = if value.nil?
317
+ if node['ref']
318
+ # if object has reference - search property in referenced object
319
+ reference.send(method, *args)
320
+ else
321
+ property[:default].is_a?(Proc) ? instance_eval(&property[:default]) : property[:default]
322
+ end
323
+ else
324
+ case property[:type]
325
+ when :integer
326
+ property[:name] == :maxOccurs && value == 'unbounded' ? :unbounded : value.to_i
327
+ when :boolean
328
+ value == 'true'
329
+ else
330
+ value
331
+ end
332
+ end
333
+ return @cache[method] = r
321
334
  end
322
335
 
323
336
  # if object has ref it cannot contain any type and children, so proxy call to target object
@@ -28,15 +28,14 @@ module XSD
28
28
  property :fixed, :string
29
29
 
30
30
  # Optional. Specifies the form for the attribute. The default value is the value of the attributeFormDefault
31
- # attribute of the element containing the attribute. Can be set to one of the following:
31
+ # attribute of the schema containing the attribute. Can be set to one of the following:
32
32
  # qualified - indicates that this attribute must be qualified with the namespace prefix and the no-colon-name
33
33
  # (NCName) of the attribute
34
34
  # unqualified - indicates that this attribute is not required to be qualified with the namespace prefix and is
35
35
  # matched against the (NCName) of the attribute
36
36
  # @!attribute form
37
- # @return String, nil
38
- # TODO: support default value from parent
39
- property :form, :string
37
+ # @return String
38
+ property :form, :string, default: proc { schema.attribute_form_default }
40
39
 
41
40
  # Optional. Specifies a built-in data type or a simple type. The type attribute can only be present when the
42
41
  # content does not contain a simpleType element
@@ -47,7 +47,7 @@ module XSD
47
47
  # cannot be used if the parent element is the schema element
48
48
  # @!attribute form
49
49
  # @return String
50
- property :form, :string
50
+ property :form, :string, default: proc { schema.element_form_default }
51
51
 
52
52
  # Optional. Specifies whether an explicit null value can be assigned to the element. True enables an instance of
53
53
  # the element to have the null attribute set to true. The null attribute is defined as part of the XML Schema
@@ -5,8 +5,7 @@ module XSD
5
5
  # Get definition namespace
6
6
  # @return String
7
7
  def namespace
8
- is_referenced = respond_to?(:referenced?)
9
- is_referenced && referenced? ? reference.schema.target_namespace : schema.target_namespace
8
+ @namespace ||= (is_a?(Referenced) && referenced? ? reference.schema : schema).target_namespace
10
9
  end
11
10
 
12
11
  # Get absolute definition name
data/lib/xsd/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module XSD
4
- VERSION = '2.6.1'
4
+ VERSION = '2.6.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xsd
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.1
4
+ version: 2.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - d.arkhipov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-12 00:00:00.000000000 Z
11
+ date: 2024-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder