xsd 2.6.1 → 2.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73e87995baa341819126aaf56de8b4a865395423b6ea2f64c8a3aa8e702a611a
4
- data.tar.gz: d330c3d390ff34c43d7988e0fe30b99d8538c62ff60205e0164d3119118ed1c4
3
+ metadata.gz: d3f894631bb4ecfab0ab93c8b67f1a4d2d85dc88aeef5c69890e424c018ea7a0
4
+ data.tar.gz: 6be2dfdee0a06f955d80ba57cbc39739fa6c09c06d6af80d194e77ccf32c8797
5
5
  SHA512:
6
- metadata.gz: 0bfc579e3376d04a72c4ac593d9c944c7739b0dc4ffe0ea94399fbdfb11771bb8f7a4d356609a257e47e5ff3fefa7bae6c34a0ac0cb76c1b149614b25fe58994
7
- data.tar.gz: 2d44c024e3b658e2b907614a621db0d2367feac05e6abeb8c5e7bee027d830c3be6f4a438941141e17b1df626f3b5899793a9e7befc612bd28caae804812cf7b
6
+ metadata.gz: 7d45a0c77011c0bdfd4bdee3998eef649129cb51d2c248b733a35b9c2c19bb8678b2b41035afcc95f69f02e37df550bd90ef5c57a03225789de34ff7dfb65c11
7
+ data.tar.gz: dd2673d5e862524a8fad13f8ce55857d9ec3c7daed215542b9806491c428e778ce011b77c26f2dc3aa6ba24a60bfd5d1bdf9ed6cc59a702ac4daa23725fa9dce
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [2.6.2] - 2024-04-12
2
+
3
+ - Get default value for element/attribute "form" property from schema
4
+
1
5
  ## [2.6.1] - 2024-04-12
2
6
 
3
7
  - Correctly detect namespace for referenced elements
@@ -304,20 +304,24 @@ module XSD
304
304
  # check for property first
305
305
  if (property = self.class.properties[method])
306
306
  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
307
+ r = if value.nil?
308
+ if node['ref']
309
+ # if object has reference - search property in referenced object
310
+ reference.send(method, *args)
311
+ else
312
+ property[:default].is_a?(Proc) ? instance_eval(&property[:default]) : property[:default]
313
+ end
314
+ else
315
+ case property[:type]
316
+ when :integer
317
+ property[:name] == :maxOccurs && value == 'unbounded' ? :unbounded : value.to_i
318
+ when :boolean
319
+ value == 'true'
320
+ else
321
+ value
322
+ end
323
+ end
324
+ return @cache[method] = r
321
325
  end
322
326
 
323
327
  # 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
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.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - d.arkhipov