lutaml-model 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +0 -5
  3. data/.rubocop_todo.yml +20 -101
  4. data/Gemfile +3 -18
  5. data/README.adoc +109 -6
  6. data/lib/lutaml/model/attribute.rb +15 -2
  7. data/lib/lutaml/model/config.rb +0 -1
  8. data/lib/lutaml/model/json_adapter/json_document.rb +20 -0
  9. data/lib/lutaml/model/json_adapter/json_object.rb +28 -0
  10. data/lib/lutaml/model/json_adapter/{multi_json.rb → multi_json_adapter.rb} +2 -3
  11. data/lib/lutaml/model/json_adapter/{standard.rb → standard_json_adapter.rb} +2 -3
  12. data/lib/lutaml/model/json_adapter.rb +1 -31
  13. data/lib/lutaml/model/key_value_mapping.rb +0 -1
  14. data/lib/lutaml/model/key_value_mapping_rule.rb +0 -1
  15. data/lib/lutaml/model/mapping_hash.rb +0 -2
  16. data/lib/lutaml/model/mapping_rule.rb +0 -1
  17. data/lib/lutaml/model/schema/json_schema.rb +0 -1
  18. data/lib/lutaml/model/schema/relaxng_schema.rb +0 -1
  19. data/lib/lutaml/model/schema/xsd_schema.rb +0 -1
  20. data/lib/lutaml/model/schema/yaml_schema.rb +0 -1
  21. data/lib/lutaml/model/schema.rb +0 -1
  22. data/lib/lutaml/model/serializable.rb +0 -1
  23. data/lib/lutaml/model/serialize.rb +22 -4
  24. data/lib/lutaml/model/toml_adapter/toml_document.rb +20 -0
  25. data/lib/lutaml/model/toml_adapter/toml_object.rb +28 -0
  26. data/lib/lutaml/model/toml_adapter/toml_rb_adapter.rb +2 -3
  27. data/lib/lutaml/model/toml_adapter/tomlib_adapter.rb +2 -3
  28. data/lib/lutaml/model/toml_adapter.rb +0 -31
  29. data/lib/lutaml/model/type/date_time.rb +20 -0
  30. data/lib/lutaml/model/type/json.rb +34 -0
  31. data/lib/lutaml/model/type/time_without_date.rb +4 -3
  32. data/lib/lutaml/model/type.rb +61 -124
  33. data/lib/lutaml/model/version.rb +1 -1
  34. data/lib/lutaml/model/xml_adapter/nokogiri_adapter.rb +5 -6
  35. data/lib/lutaml/model/xml_adapter/oga_adapter.rb +4 -5
  36. data/lib/lutaml/model/xml_adapter/ox_adapter.rb +8 -9
  37. data/lib/lutaml/model/xml_adapter/xml_attribute.rb +27 -0
  38. data/lib/lutaml/model/xml_adapter/xml_document.rb +184 -0
  39. data/lib/lutaml/model/xml_adapter/xml_element.rb +94 -0
  40. data/lib/lutaml/model/xml_adapter/xml_namespace.rb +49 -0
  41. data/lib/lutaml/model/xml_adapter.rb +0 -285
  42. data/lib/lutaml/model/xml_mapping.rb +1 -1
  43. data/lib/lutaml/model/xml_mapping_rule.rb +3 -4
  44. data/lib/lutaml/model/yaml_adapter/standard_yaml_adapter.rb +34 -0
  45. data/lib/lutaml/model/yaml_adapter/yaml_document.rb +20 -0
  46. data/lib/lutaml/model/yaml_adapter/yaml_object.rb +28 -0
  47. data/lib/lutaml/model/yaml_adapter.rb +1 -27
  48. data/lib/lutaml/model.rb +0 -5
  49. metadata +17 -5
  50. data/lib/lutaml/model/xml_namespace.rb +0 -47
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Model
5
+ module YamlAdapter
6
+ # Base class for YAML objects
7
+ class YamlObject
8
+ attr_reader :attributes
9
+
10
+ def initialize(attributes = {})
11
+ @attributes = attributes
12
+ end
13
+
14
+ def [](key)
15
+ @attributes[key]
16
+ end
17
+
18
+ def []=(key, value)
19
+ @attributes[key] = value
20
+ end
21
+
22
+ def to_h
23
+ @attributes
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,34 +1,8 @@
1
- # lib/lutaml/model/yaml_adapter.rb
2
- require "yaml"
1
+ # frozen_string_literal: true
3
2
 
4
3
  module Lutaml
5
4
  module Model
6
5
  module YamlAdapter
7
- class Standard
8
- def initialize(attributes)
9
- @attributes = attributes
10
- end
11
-
12
- def to_yaml(options = {})
13
- YAML.dump(@attributes, options)
14
- end
15
-
16
- def self.to_yaml(attributes, *args)
17
- new(attributes).to_yaml(*args)
18
- end
19
-
20
- def self.from_yaml(yaml, klass)
21
- data = parse(yaml)
22
- mapped_attrs = klass.send(:apply_mappings, data, :yaml)
23
- klass.new(mapped_attrs)
24
- end
25
-
26
- def self.parse(yaml)
27
- YAML.safe_load(yaml,
28
- permitted_classes: [Date, Time, DateTime, Symbol,
29
- BigDecimal, Hash, Array])
30
- end
31
- end
32
6
  end
33
7
  end
34
8
  end
data/lib/lutaml/model.rb CHANGED
@@ -1,11 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "model/version"
4
-
5
- # lib/lutaml/model.rb
6
- require "nokogiri"
7
- require "json"
8
- require "yaml"
9
4
  require_relative "model/type"
10
5
  require_relative "model/serializable"
11
6
  require_relative "model/json_adapter"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lutaml-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-13 00:00:00.000000000 Z
11
+ date: 2024-08-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'LutaML creating data models in Ruby
14
14
 
@@ -37,8 +37,10 @@ files:
37
37
  - lib/lutaml/model/error.rb
38
38
  - lib/lutaml/model/error/invalid_value_error.rb
39
39
  - lib/lutaml/model/json_adapter.rb
40
- - lib/lutaml/model/json_adapter/multi_json.rb
41
- - lib/lutaml/model/json_adapter/standard.rb
40
+ - lib/lutaml/model/json_adapter/json_document.rb
41
+ - lib/lutaml/model/json_adapter/json_object.rb
42
+ - lib/lutaml/model/json_adapter/multi_json_adapter.rb
43
+ - lib/lutaml/model/json_adapter/standard_json_adapter.rb
42
44
  - lib/lutaml/model/key_value_mapping.rb
43
45
  - lib/lutaml/model/key_value_mapping_rule.rb
44
46
  - lib/lutaml/model/mapping_hash.rb
@@ -51,19 +53,29 @@ files:
51
53
  - lib/lutaml/model/serializable.rb
52
54
  - lib/lutaml/model/serialize.rb
53
55
  - lib/lutaml/model/toml_adapter.rb
56
+ - lib/lutaml/model/toml_adapter/toml_document.rb
57
+ - lib/lutaml/model/toml_adapter/toml_object.rb
54
58
  - lib/lutaml/model/toml_adapter/toml_rb_adapter.rb
55
59
  - lib/lutaml/model/toml_adapter/tomlib_adapter.rb
56
60
  - lib/lutaml/model/type.rb
61
+ - lib/lutaml/model/type/date_time.rb
62
+ - lib/lutaml/model/type/json.rb
57
63
  - lib/lutaml/model/type/time_without_date.rb
58
64
  - lib/lutaml/model/version.rb
59
65
  - lib/lutaml/model/xml_adapter.rb
60
66
  - lib/lutaml/model/xml_adapter/nokogiri_adapter.rb
61
67
  - lib/lutaml/model/xml_adapter/oga_adapter.rb
62
68
  - lib/lutaml/model/xml_adapter/ox_adapter.rb
69
+ - lib/lutaml/model/xml_adapter/xml_attribute.rb
70
+ - lib/lutaml/model/xml_adapter/xml_document.rb
71
+ - lib/lutaml/model/xml_adapter/xml_element.rb
72
+ - lib/lutaml/model/xml_adapter/xml_namespace.rb
63
73
  - lib/lutaml/model/xml_mapping.rb
64
74
  - lib/lutaml/model/xml_mapping_rule.rb
65
- - lib/lutaml/model/xml_namespace.rb
66
75
  - lib/lutaml/model/yaml_adapter.rb
76
+ - lib/lutaml/model/yaml_adapter/standard_yaml_adapter.rb
77
+ - lib/lutaml/model/yaml_adapter/yaml_document.rb
78
+ - lib/lutaml/model/yaml_adapter/yaml_object.rb
67
79
  - lutaml-model.gemspec
68
80
  - sig/lutaml/model.rbs
69
81
  homepage: https://github.com/lutaml/lutaml-model
@@ -1,47 +0,0 @@
1
- # frozen_striing_literal: true
2
-
3
- module Lutaml
4
- module Model
5
- class XmlNamespace
6
- # Return name
7
- #
8
- # @return [String]
9
- #
10
- # @api private
11
- attr_accessor :uri
12
-
13
- # Return prefix
14
- #
15
- # @return [String]
16
- #
17
- # @api private
18
- attr_accessor :prefix
19
-
20
- # Initialize instance
21
- #
22
- # @param [String, nil] name
23
- # @param [String, nil] prefix
24
- #
25
- # @api private
26
- def initialize(uri = nil, prefix = nil)
27
- @uri = uri
28
- @prefix = normalize_prefix(prefix)
29
- end
30
-
31
- def normalize_prefix(prefix)
32
- normalized_prefix = prefix.to_s.gsub(/xmlns:?/, "")
33
- return if normalized_prefix.empty?
34
-
35
- normalized_prefix
36
- end
37
-
38
- def attr_name
39
- if prefix && !prefix.empty?
40
- "xmlns:#{prefix}"
41
- else
42
- "xmlns"
43
- end
44
- end
45
- end
46
- end
47
- end