lutaml 0.9.10 → 0.9.11

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: 59f3f41813beaec8f6ffe17b8077aa9ad9d0a1a49861d12075b86e579e4d8287
4
- data.tar.gz: f52b06e26ebecc5088248fa0d83696bfae5d26b6b2c31d32bca1d3210db5493d
3
+ metadata.gz: 9de4708a54b2e1e0cd6994dc7931e56711d2e257d1077f96003c4f8de6260c7e
4
+ data.tar.gz: 461a1f380240be81347038fac000ab836067599ac3485ed7d9e5ba61594f379f
5
5
  SHA512:
6
- metadata.gz: f0b91cc8fcf077286165cb879a9896f401ccd45f72db55fb8a2ef0f89aca841f7d57bdf581194f3487f2f8edfc83103c68b174f36f95cdaa4710d2303ac01d64
7
- data.tar.gz: e16c5a41385564b5e9c3c89850114daa5e8ff0ae1a0a4bac5ed5f12c40155d4164c087e74b1e80841ab8a5d58af305ab6caa621f93a321f97fe44fa0604960f2
6
+ metadata.gz: 40e3e939f49e84407257d9d80cebe83e42ef74ba87d5763f5f0c245d445b857273bce8576f24948a4e0e836fa6df2a6f15980c7add173176910a3180da5b4477
7
+ data.tar.gz: 0c0c19132496f42ee08b6f9773d1807be9df6f4a3ada9ac49a3d846ee612742db086ca7e15494afbfee601f6ca6571ea532a28a2758f61c7576ba255602718ef
@@ -1,3 +1,3 @@
1
1
  module Lutaml
2
- VERSION = "0.9.10".freeze
2
+ VERSION = "0.9.11".freeze
3
3
  end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module XMI
5
+ class AssociationDrop < Liquid::Drop
6
+ def initialize(model) # rubocop:disable Lint/MissingSuper
7
+ @model = model
8
+ end
9
+
10
+ def xmi_id
11
+ @model[:xmi_id]
12
+ end
13
+
14
+ def member_end
15
+ @model[:member_end]
16
+ end
17
+
18
+ def member_end_type
19
+ @model[:member_end_type]
20
+ end
21
+
22
+ def member_end_cardinality
23
+ ::Lutaml::XMI::CardinalityDrop.new(@model[:member_end_cardinality])
24
+ end
25
+
26
+ def member_end_attribute_name
27
+ @model[:member_end_attribute_name]
28
+ end
29
+
30
+ def member_end_xmi_id
31
+ @model[:member_end_xmi_id]
32
+ end
33
+
34
+ def owner_end
35
+ @model[:owner_end]
36
+ end
37
+
38
+ def owner_end_xmi_id
39
+ @model[:owner_end_xmi_id]
40
+ end
41
+
42
+ def definition
43
+ @model[:definition]
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module XMI
5
+ class AttributeDrop < Liquid::Drop
6
+ def initialize(model) # rubocop:disable Lint/MissingSuper
7
+ @model = model
8
+ end
9
+
10
+ def id
11
+ @model[:id]
12
+ end
13
+
14
+ def name
15
+ @model[:name]
16
+ end
17
+
18
+ def type
19
+ @model[:type]
20
+ end
21
+
22
+ def xmi_id
23
+ @model[:xmi_id]
24
+ end
25
+
26
+ def is_derived
27
+ @model[:is_derived]
28
+ end
29
+
30
+ def cardinality
31
+ ::Lutaml::XMI::CardinalityDrop.new(@model[:cardinality])
32
+ end
33
+
34
+ def definition
35
+ @model[:definition]
36
+ end
37
+
38
+ def association
39
+ @model[:association]
40
+ end
41
+
42
+ def type_ns
43
+ @model[:type_ns]
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module XMI
5
+ class CardinalityDrop < Liquid::Drop
6
+ def initialize(model) # rubocop:disable Lint/MissingSuper
7
+ @model = model
8
+ end
9
+
10
+ def min
11
+ @model["min"]
12
+ end
13
+
14
+ def max
15
+ @model["max"]
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module XMI
5
+ class ConstraintDrop < Liquid::Drop
6
+ def initialize(model) # rubocop:disable Lint/MissingSuper
7
+ @model = model
8
+ end
9
+
10
+ def name
11
+ @model[:name]
12
+ end
13
+
14
+ def type
15
+ @model[:type]
16
+ end
17
+
18
+ def weight
19
+ @model[:weight]
20
+ end
21
+
22
+ def status
23
+ @model[:status]
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module XMI
5
+ class DataTypeDrop < Liquid::Drop
6
+ def initialize(model) # rubocop:disable Lint/MissingSuper
7
+ @model = model
8
+ end
9
+
10
+ def xmi_id
11
+ @model[:xmi_id]
12
+ end
13
+
14
+ def name
15
+ @model[:name]
16
+ end
17
+
18
+ def attributes
19
+ @model[:attributes]&.map do |attribute|
20
+ ::Lutaml::XMI::AttributeDrop.new(attribute)
21
+ end
22
+ end
23
+
24
+ def operations
25
+ @model[:operations]&.map do |operation|
26
+ ::Lutaml::XMI::OperationDrop.new(operation)
27
+ end
28
+ end
29
+
30
+ def associations
31
+ @model[:associations]&.map do |association|
32
+ ::Lutaml::XMI::AssociationDrop.new(association)
33
+ end
34
+ end
35
+
36
+ def constraints
37
+ @model[:constraints]&.map do |constraint|
38
+ ::Lutaml::XMI::ConstraintDrop.new(constraint)
39
+ end
40
+ end
41
+
42
+ def is_abstract
43
+ @model[:is_abstract]
44
+ end
45
+
46
+ def definition
47
+ @model[:definition]
48
+ end
49
+
50
+ def stereotype
51
+ @model[:stereotype]
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module XMI
5
+ class DiagramDrop < Liquid::Drop
6
+ def initialize(model) # rubocop:disable Lint/MissingSuper
7
+ @model = model
8
+ end
9
+
10
+ def xmi_id
11
+ @model[:xmi_id]
12
+ end
13
+
14
+ def name
15
+ @model[:name]
16
+ end
17
+
18
+ def definition
19
+ @model[:definition]
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module XMI
5
+ class EnumDrop < Liquid::Drop
6
+ def initialize(model) # rubocop:disable Lint/MissingSuper
7
+ @model = model
8
+ end
9
+
10
+ def xmi_id
11
+ @model[:xmi_id]
12
+ end
13
+
14
+ def name
15
+ @model[:name]
16
+ end
17
+
18
+ def values
19
+ @model[:values].map do |value|
20
+ ::Lutaml::XMI::EnumOwnedLiteralDrop.new(value)
21
+ end
22
+ end
23
+
24
+ def definition
25
+ @model[:definition]
26
+ end
27
+
28
+ def stereotype
29
+ @model[:stereotype]
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module XMI
5
+ class EnumOwnedLiteralDrop < Liquid::Drop
6
+ def initialize(model) # rubocop:disable Lint/MissingSuper
7
+ @model = model
8
+ end
9
+
10
+ def name
11
+ @model[:name]
12
+ end
13
+
14
+ def type
15
+ @model[:type]
16
+ end
17
+
18
+ def definition
19
+ @model[:definition]
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module XMI
5
+ class KlassDrop < Liquid::Drop
6
+ def initialize(model) # rubocop:disable Lint/MissingSuper
7
+ @model = model
8
+ end
9
+
10
+ def xmi_id
11
+ @model[:xmi_id]
12
+ end
13
+
14
+ def name
15
+ @model[:name]
16
+ end
17
+
18
+ def package
19
+ ::Lutaml::XMI::PackageDrop.new(@model[:package])
20
+ end
21
+
22
+ def type
23
+ @model[:type]
24
+ end
25
+
26
+ def attributes
27
+ @model[:attributes]&.map do |attribute|
28
+ ::Lutaml::XMI::AttributeDrop.new(attribute)
29
+ end
30
+ end
31
+
32
+ def associations
33
+ @model[:associations]&.map do |association|
34
+ ::Lutaml::XMI::AssociationDrop.new(association)
35
+ end
36
+ end
37
+
38
+ def operations
39
+ @model[:operations]&.map do |operation|
40
+ ::Lutaml::XMI::OperationDrop.new(operation)
41
+ end
42
+ end
43
+
44
+ def constraints
45
+ @model[:constraints]&.map do |constraint|
46
+ ::Lutaml::XMI::ConstraintDrop.new(constraint)
47
+ end
48
+ end
49
+
50
+ def is_abstract
51
+ @model[:is_abstract]
52
+ end
53
+
54
+ def definition
55
+ @model[:definition]
56
+ end
57
+
58
+ def stereotype
59
+ @model[:stereotype]
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module XMI
5
+ class OperationDrop < Liquid::Drop
6
+ def initialize(model) # rubocop:disable Lint/MissingSuper
7
+ @model = model
8
+ end
9
+
10
+ def id
11
+ @model[:id]
12
+ end
13
+
14
+ def xmi_id
15
+ @model[:xmi_id]
16
+ end
17
+
18
+ def name
19
+ @model[:name]
20
+ end
21
+
22
+ def definition
23
+ @model[:definition]
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module XMI
5
+ class PackageDrop < Liquid::Drop
6
+ def initialize(model) # rubocop:disable Lint/MissingSuper
7
+ @model = model
8
+ @children_packages ||= packages.map do |pkg|
9
+ [pkg, pkg.packages, pkg.packages.map(&:children_packages)]
10
+ end.flatten.uniq
11
+ end
12
+
13
+ def xmi_id
14
+ @model[:xmi_id]
15
+ end
16
+
17
+ def name
18
+ @model[:name]
19
+ end
20
+
21
+ def klasses
22
+ @model[:classes].map do |klass|
23
+ ::Lutaml::XMI::KlassDrop.new(klass)
24
+ end
25
+ end
26
+ alias classes klasses
27
+
28
+ def enums
29
+ @model[:enums].map do |enum|
30
+ ::Lutaml::XMI::EnumDrop.new(enum)
31
+ end
32
+ end
33
+
34
+ def data_types
35
+ @model[:data_types].map do |data_type|
36
+ ::Lutaml::XMI::DataTypeDrop.new(data_type)
37
+ end
38
+ end
39
+
40
+ def diagrams
41
+ @model[:diagrams].map do |diagram|
42
+ ::Lutaml::XMI::DiagramDrop.new(diagram)
43
+ end
44
+ end
45
+
46
+ def packages
47
+ @model[:packages].map do |package|
48
+ ::Lutaml::XMI::PackageDrop.new(package)
49
+ end
50
+ end
51
+
52
+ def children_packages
53
+ @children_packages
54
+ end
55
+
56
+ def definition
57
+ @model[:definition]
58
+ end
59
+
60
+ def stereotype
61
+ @model[:stereotype]
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module XMI
5
+ class RootDrop < Liquid::Drop
6
+ def initialize(model) # rubocop:disable Lint/MissingSuper
7
+ @model = model
8
+ @children_packages ||= packages.map do |pkg|
9
+ [pkg, pkg.packages, pkg.packages.map(&:children_packages)]
10
+ end.flatten.uniq
11
+ end
12
+
13
+ def name
14
+ @model[:name]
15
+ end
16
+
17
+ def packages
18
+ @model[:packages].map do |package|
19
+ ::Lutaml::XMI::PackageDrop.new(package)
20
+ end
21
+ end
22
+
23
+ def children_packages
24
+ @children_packages
25
+ end
26
+ end
27
+ end
28
+ end
@@ -32,6 +32,13 @@ module Lutaml
32
32
  new.serialize_xmi(xmi_model)
33
33
  end
34
34
 
35
+ # @param xml [String] path to xml
36
+ # @return [Liquid::Drop]
37
+ def serialize_xmi_to_liquid(xml)
38
+ xmi_model = get_xmi_model(xml)
39
+ new.serialize_xmi_to_liquid(xmi_model)
40
+ end
41
+
35
42
  # @param xml [String] path to xml
36
43
  # @param name [String]
37
44
  # @return [Hash]
@@ -67,6 +74,16 @@ module Lutaml
67
74
  serialize_to_hash(xmi_model)
68
75
  end
69
76
 
77
+ # @param xmi_model [Shale::Mapper]
78
+ # return [Liquid::Drop]
79
+ def serialize_xmi_to_liquid(xmi_model)
80
+ @xmi_cache = {}
81
+ @xmi_root_model = xmi_model
82
+ serialized_hash = serialize_xmi(xmi_model)
83
+
84
+ ::Lutaml::XMI::RootDrop.new(serialized_hash)
85
+ end
86
+
70
87
  # @param xmi_model [Shale::Mapper]
71
88
  # @param name [String]
72
89
  # @return [Hash]
data/lib/lutaml/xmi.rb CHANGED
@@ -1,5 +1,10 @@
1
1
  require "lutaml/xmi/version"
2
2
  require "lutaml/xmi/parsers/xml"
3
+ require "liquid"
4
+
5
+ Dir["#{File.dirname(__FILE__)}/xmi/liquid_drops/**/*.rb"].sort.each do |f|
6
+ require f
7
+ end
3
8
 
4
9
  module Lutaml
5
10
  module XMI
data/lutaml.gemspec CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  spec.required_ruby_version = ">= 2.7.0"
31
31
 
32
+ spec.add_runtime_dependency "liquid"
32
33
  spec.add_runtime_dependency "expressir", "~> 1.3"
33
34
  spec.add_runtime_dependency "hashie", "~> 4.1.0"
34
35
  spec.add_runtime_dependency "htmlentities"
@@ -45,4 +46,4 @@ Gem::Specification.new do |spec|
45
46
  spec.add_development_dependency "rspec", "~> 3.11"
46
47
  spec.add_development_dependency "rubocop", "~> 1.58"
47
48
  spec.add_development_dependency "rubocop-performance", "~> 1.19"
48
- end
49
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lutaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.10
4
+ version: 0.9.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -10,6 +10,20 @@ bindir: exe
10
10
  cert_chain: []
11
11
  date: 2024-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: liquid
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: expressir
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -354,6 +368,18 @@ files:
354
368
  - lib/lutaml/version.rb
355
369
  - lib/lutaml/xmi.rb
356
370
  - lib/lutaml/xmi/README.adoc
371
+ - lib/lutaml/xmi/liquid_drops/association_drop.rb
372
+ - lib/lutaml/xmi/liquid_drops/attribute_drop.rb
373
+ - lib/lutaml/xmi/liquid_drops/cardinality_drop.rb
374
+ - lib/lutaml/xmi/liquid_drops/constraint_drop.rb
375
+ - lib/lutaml/xmi/liquid_drops/data_type_drop.rb
376
+ - lib/lutaml/xmi/liquid_drops/diagram_drop.rb
377
+ - lib/lutaml/xmi/liquid_drops/enum_drop.rb
378
+ - lib/lutaml/xmi/liquid_drops/enum_owned_literal_drop.rb
379
+ - lib/lutaml/xmi/liquid_drops/klass_drop.rb
380
+ - lib/lutaml/xmi/liquid_drops/operation_drop.rb
381
+ - lib/lutaml/xmi/liquid_drops/package_drop.rb
382
+ - lib/lutaml/xmi/liquid_drops/root_drop.rb
357
383
  - lib/lutaml/xmi/parsers/xml.rb
358
384
  - lib/lutaml/xmi/version.rb
359
385
  - lib/lutaml/xml.rb