lutaml-uml 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +36 -0
  3. data/.github/workflows/ubuntu.yml +38 -0
  4. data/.github/workflows/windows.yml +41 -0
  5. data/.gitignore +1 -0
  6. data/Gemfile +2 -1
  7. data/LUTAML.adoc +314 -0
  8. data/{README.md → README.adoc} +15 -16
  9. data/Rakefile +3 -1
  10. data/bin/console +1 -0
  11. data/bin/lutaml2dotpng +23 -0
  12. data/bin/yaml2lutaml +108 -0
  13. data/exe/lutaml-uml +4 -3
  14. data/lib/lutaml/layout/engine.rb +15 -0
  15. data/lib/lutaml/layout/graph_viz_engine.rb +16 -0
  16. data/lib/lutaml/uml.rb +3 -0
  17. data/lib/lutaml/uml/abstraction.rb +7 -5
  18. data/lib/lutaml/uml/activity.rb +7 -5
  19. data/lib/lutaml/uml/actor.rb +14 -12
  20. data/lib/lutaml/uml/association.rb +40 -14
  21. data/lib/lutaml/uml/behavior.rb +7 -5
  22. data/lib/lutaml/uml/class.rb +56 -16
  23. data/lib/lutaml/uml/classifier.rb +9 -6
  24. data/lib/lutaml/uml/connector.rb +16 -12
  25. data/lib/lutaml/uml/constraint.rb +8 -7
  26. data/lib/lutaml/uml/constructor_end.rb +11 -8
  27. data/lib/lutaml/uml/data_type.rb +9 -4
  28. data/lib/lutaml/uml/dependency.rb +16 -13
  29. data/lib/lutaml/uml/document.rb +71 -0
  30. data/lib/lutaml/uml/enum.rb +33 -0
  31. data/lib/lutaml/uml/event.rb +7 -5
  32. data/lib/lutaml/uml/final_state.rb +7 -5
  33. data/lib/lutaml/uml/formatter.rb +21 -0
  34. data/lib/lutaml/uml/formatter/base.rb +67 -0
  35. data/lib/lutaml/uml/formatter/graphviz.rb +335 -0
  36. data/lib/lutaml/uml/has_attributes.rb +14 -0
  37. data/lib/lutaml/uml/has_members.rb +30 -0
  38. data/lib/lutaml/uml/instance.rb +15 -10
  39. data/lib/lutaml/uml/interface/base.rb +28 -0
  40. data/lib/lutaml/uml/interface/command_line.rb +265 -0
  41. data/lib/lutaml/uml/model.rb +11 -8
  42. data/lib/lutaml/uml/node/base.rb +21 -0
  43. data/lib/lutaml/uml/node/class_node.rb +57 -0
  44. data/lib/lutaml/uml/node/class_relationship.rb +14 -0
  45. data/lib/lutaml/uml/node/document.rb +18 -0
  46. data/lib/lutaml/uml/node/field.rb +34 -0
  47. data/lib/lutaml/uml/node/has_name.rb +15 -0
  48. data/lib/lutaml/uml/node/has_type.rb +15 -0
  49. data/lib/lutaml/uml/node/method.rb +29 -0
  50. data/lib/lutaml/uml/node/method_argument.rb +16 -0
  51. data/lib/lutaml/uml/node/relationship.rb +28 -0
  52. data/lib/lutaml/uml/opaque_behavior.rb +7 -6
  53. data/lib/lutaml/uml/package.rb +16 -13
  54. data/lib/lutaml/uml/parsers/attribute.rb +70 -0
  55. data/lib/lutaml/uml/parsers/dsl.rb +375 -0
  56. data/lib/lutaml/uml/parsers/dsl_preprocessor.rb +44 -0
  57. data/lib/lutaml/uml/parsers/dsl_transform.rb +27 -0
  58. data/lib/lutaml/uml/parsers/yaml.rb +46 -0
  59. data/lib/lutaml/uml/port.rb +6 -4
  60. data/lib/lutaml/uml/primitive_type.rb +9 -4
  61. data/lib/lutaml/uml/property.rb +25 -15
  62. data/lib/lutaml/uml/pseudostate.rb +7 -6
  63. data/lib/lutaml/uml/realization.rb +7 -5
  64. data/lib/lutaml/uml/region.rb +7 -6
  65. data/lib/lutaml/uml/serializers/association.rb +58 -0
  66. data/lib/lutaml/uml/serializers/base.rb +16 -0
  67. data/lib/lutaml/uml/serializers/class.rb +29 -0
  68. data/lib/lutaml/uml/serializers/top_element_attribute.rb +14 -0
  69. data/lib/lutaml/uml/serializers/yaml_view.rb +18 -0
  70. data/lib/lutaml/uml/state.rb +8 -6
  71. data/lib/lutaml/uml/state_machine.rb +7 -5
  72. data/lib/lutaml/uml/top_element.rb +45 -35
  73. data/lib/lutaml/uml/top_element_attribute.rb +25 -0
  74. data/lib/lutaml/uml/transition.rb +8 -6
  75. data/lib/lutaml/uml/trigger.rb +8 -6
  76. data/lib/lutaml/uml/version.rb +3 -1
  77. data/lib/lutaml/uml/vertex.rb +7 -5
  78. data/lutaml-uml.gemspec +9 -2
  79. data/spec/fixtures/datamodel/models/AddressClassProfile.yml +90 -0
  80. data/spec/fixtures/datamodel/models/AddressComponentProfile.yml +63 -0
  81. data/spec/fixtures/datamodel/models/AddressComponentSpecification.yml +15 -0
  82. data/spec/fixtures/datamodel/models/AddressProfile.yml +36 -0
  83. data/spec/fixtures/datamodel/models/AttributeProfile.yml +32 -0
  84. data/spec/fixtures/datamodel/models/InterchangeAddressClassProfile.yml +79 -0
  85. data/spec/fixtures/datamodel/models/Localization copy.yml +23 -0
  86. data/spec/fixtures/datamodel/models/Localization.yml +23 -0
  87. data/spec/fixtures/datamodel/models/ProfileCompliantAddress.yml +36 -0
  88. data/spec/fixtures/datamodel/models/ProfileCompliantAddressComponent.yml +15 -0
  89. data/spec/fixtures/datamodel/models/Signature.yml +20 -0
  90. data/spec/fixtures/datamodel/models/SignatureBlankDefinition.yml +20 -0
  91. data/spec/fixtures/datamodel/models/TextDirectionCode copy.yml +16 -0
  92. data/spec/fixtures/datamodel/models/TextDirectionCode.yml +16 -0
  93. data/spec/fixtures/datamodel/models/Validity.yml +14 -0
  94. data/spec/fixtures/datamodel/models/iso19160-1/Address.yml +22 -0
  95. data/spec/fixtures/datamodel/models/iso19160-1/AddressComponent.yml +2 -0
  96. data/spec/fixtures/datamodel/style.uml.inc +37 -0
  97. data/spec/fixtures/datamodel/views/AddressClassProfile.yml +12 -0
  98. data/spec/fixtures/datamodel/views/AddressProfile.yml +3 -0
  99. data/spec/fixtures/datamodel/views/CommonModels.yml +9 -0
  100. data/spec/fixtures/datamodel/views/TopDown.yml +62 -0
  101. data/spec/fixtures/dsl/diagram.lutaml +3 -0
  102. data/spec/fixtures/dsl/diagram_attributes.lutaml +5 -0
  103. data/spec/fixtures/dsl/diagram_class_assocation.lutaml +29 -0
  104. data/spec/fixtures/dsl/diagram_class_fields.lutaml +19 -0
  105. data/spec/fixtures/dsl/diagram_comments.lutaml +28 -0
  106. data/spec/fixtures/dsl/diagram_concept_model.lutaml +132 -0
  107. data/spec/fixtures/dsl/diagram_data_types.lutaml +24 -0
  108. data/spec/fixtures/dsl/diagram_includes.lutaml +6 -0
  109. data/spec/fixtures/dsl/diagram_multiply_classes.lutaml +7 -0
  110. data/spec/fixtures/dsl/shared.lutaml +3 -0
  111. data/spec/fixtures/dsl/shared1.lutaml +4 -0
  112. data/spec/fixtures/generated_dot/AddressClassProfile.dot +170 -0
  113. data/spec/fixtures/generated_dot/AddressProfile.dot +34 -0
  114. data/spec/lutaml/uml/formatter/graphviz_spec.rb +41 -0
  115. data/spec/lutaml/uml/parsers/dsl_spec.rb +252 -0
  116. data/spec/lutaml/uml/parsers/yaml_spec.rb +18 -0
  117. data/spec/lutaml/uml/serializers/yaml_view_spec.rb +20 -0
  118. data/spec/lutaml/uml_spec.rb +2 -4
  119. data/spec/spec_helper.rb +11 -0
  120. metadata +161 -13
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lutaml
4
+ module Uml
5
+ class TopElementAttribute
6
+ include HasAttributes
7
+
8
+ attr_accessor :name,
9
+ :visibility,
10
+ :type,
11
+ :definition,
12
+ :contain,
13
+ :static,
14
+ :cardinality,
15
+ :keyword
16
+
17
+ # rubocop:disable Rails/ActiveRecordAliases
18
+ def initialize(attributes = {})
19
+ @visibility = "public"
20
+ update_attributes(attributes)
21
+ end
22
+ # rubocop:enable Rails/ActiveRecordAliases
23
+ end
24
+ end
25
+ end
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ##
2
4
  ## Behaviour metamodel
3
5
  ##
4
- module Lutaml::Uml
5
-
6
- class Transition < TopElement
7
- attr_accessor :source, :target, :guard, :effect
8
- end
9
-
6
+ module Lutaml
7
+ module Uml
8
+ class Transition < TopElement
9
+ attr_accessor :source, :target, :guard, :effect
10
+ end
11
+ end
10
12
  end
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ##
2
4
  ## Behaviour metamodel
3
5
  ##
4
- module Lutaml::Uml
5
-
6
- class Trigger < TopElement
7
- attr_accessor :event
6
+ module Lutaml
7
+ module Uml
8
+ class Trigger < TopElement
9
+ attr_accessor :event
10
+ end
11
+ end
8
12
  end
9
-
10
- end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Lutaml
2
4
  module Uml
3
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
4
6
  end
5
7
  end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  ##
2
4
  ## Behaviour metamodel
3
5
  ##
4
- module Lutaml::Uml
5
-
6
- class Vertex < TopElement
6
+ module Lutaml
7
+ module Uml
8
+ class Vertex < TopElement
9
+ end
10
+ end
7
11
  end
8
-
9
- end
@@ -1,4 +1,6 @@
1
- require_relative 'lib/lutaml/uml/version'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/lutaml/uml/version"
2
4
 
3
5
  Gem::Specification.new do |spec|
4
6
  spec.name = "lutaml-uml"
@@ -22,9 +24,14 @@ Gem::Specification.new do |spec|
22
24
  spec.require_paths = ["lib"]
23
25
  spec.executables = %w[lutaml-uml]
24
26
 
25
- spec.add_runtime_dependency "thor", "~> 1.0"
26
27
  spec.add_runtime_dependency "activesupport", "~> 5.0"
28
+ spec.add_runtime_dependency "hashie", "~> 4.1.0"
29
+ spec.add_runtime_dependency "parslet", "~> 1.7.1"
30
+ spec.add_runtime_dependency "ruby-graphviz", "~> 1.2"
31
+ spec.add_runtime_dependency "thor", "~> 1.0"
32
+ spec.add_development_dependency "byebug"
27
33
  spec.add_development_dependency "nokogiri", "~> 1.10"
34
+ spec.add_development_dependency "rubocop", "~> 0.54.0"
28
35
 
29
36
  spec.add_development_dependency "bundler", "~> 2.0"
30
37
  spec.add_development_dependency "pry", "~> 0.12.2"
@@ -0,0 +1,90 @@
1
+ modelType: class
2
+ # TODO
3
+ definition: |
4
+ An `AddressClassProfile` represents a profile of a `ProfileCompliantAddress`.
5
+ It corresponds to the concept of an `AddressClass` originally
6
+ expressed in <<ISO19160-1>> as a referenced codelist.
7
+
8
+ It represents additional attributes and restrictions to the
9
+ `ProfileCompliantAddress` model. It also represents metadata for the use of
10
+ the profile.
11
+
12
+ A single profile can include and support multiple types of
13
+ address formats, such as a numbered street address and a
14
+ "`PO Box`" address simultaneously. Each of these address formats
15
+ is represented as an interchange address class.
16
+
17
+ [example]
18
+ --
19
+ The US Numbered Thoroughfare Address with this syntax can be
20
+ represented as an address class profile:
21
+
22
+ *{sp}{ Complete Landmark Name or Complete Place Name } +
23
+ *{sp}{ Complete Address Number * } +
24
+ *{sp}{ Complete Street Name * } +
25
+ *{sp}{ Complete Subaddress } +
26
+ *{sp}{ Complete Place Name * } +
27
+ *{sp}{ State Name * } +
28
+ *{sp}{ Zip Code } +
29
+ *{sp}{ Zip Plus 4 } +
30
+ *{sp}{ Country Name }
31
+ --
32
+ attributes:
33
+ id:
34
+ definition: Unique identifier of this AddressClassProfile.
35
+ type: CharacterString
36
+ type:
37
+ definition: Intended usage of this profile.
38
+ type: CharacterString
39
+ description:
40
+ definition: Textual description of this profile.
41
+ type: CharacterString
42
+ localization:
43
+ definition: The language and script used within this profile.
44
+ type: Localization
45
+ signature:
46
+ definition: The digital signature to verify the integrity of this profile, and the identity of the publishing authority.
47
+ type: Signature
48
+ cardinality:
49
+ min: 0
50
+ max: 1
51
+ areaApplicability:
52
+ definition: The geographic representation of which this AddressClassProfile applies to. Overlapping geographic areas are allowed across different profiles.
53
+ type: iso19115MD_SpatialRepresentation
54
+ cardinality:
55
+ min: 0
56
+ max: "*"
57
+ timeToLive:
58
+ definition: The maximum time interval between refreshing of this profile via an authoritative source, in seconds.
59
+ type: Integer
60
+ validity:
61
+ definition: The period of date and time that this profile should be considered as valid.
62
+ type: Validity
63
+ relations:
64
+ - target: AttributeProfile
65
+ relationship:
66
+ source:
67
+ type: aggregation
68
+ attribute:
69
+ addressClassProfile:
70
+ target:
71
+ type: direct
72
+ attribute:
73
+ attributeProfile:
74
+ cardinality:
75
+ min: 0
76
+ max: '*'
77
+
78
+ - target: ProfileCompliantAddress
79
+ relationship:
80
+ source:
81
+ attribute:
82
+ profile:
83
+ cardinality:
84
+ min: 1
85
+ max: 1
86
+ target:
87
+ type: direct
88
+ action:
89
+ verb: compliesWith
90
+ direction: source
@@ -0,0 +1,63 @@
1
+ name: AddressComponentProfile
2
+ modelType: class
3
+ definition: |
4
+ An `AddressComponentProfile` represents a profile of a `ProfileCompliantAddressComponent`,
5
+ which is extended from the `AddressComponent` model defined in <<ISO19160-1>>.
6
+
7
+ It represents additional attributes and restrictions to the `Address` model
8
+ of a `ProfileCompliantAddress`. It also represents metadata for the use of
9
+ the profile.
10
+ attributes:
11
+ key:
12
+ definition: An identifier of this `AddressComponentProfile`, shall be unique within the `AddressProfile`.
13
+ type: CharacterString
14
+ description:
15
+ definition: Textual description of this component.
16
+ type: CharacterString
17
+ example:
18
+ definition: A textual example to demonstrate the correct use of this component.
19
+ type: CharacterString
20
+ cardinality:
21
+ min: 0
22
+ max: 1
23
+ relations:
24
+ - target: AddressClassProfile
25
+ relationship:
26
+ target:
27
+ type: aggregation
28
+ attribute:
29
+ componentProfile:
30
+ cardinality:
31
+ min: 0
32
+ max: "*"
33
+ association: AddressComponentSpecification
34
+ action:
35
+ verb: uses
36
+ direction: source
37
+
38
+ - target: AttributeProfile
39
+ relationship:
40
+ source:
41
+ type: aggregation
42
+ attribute:
43
+ addressClassProfile:
44
+ target:
45
+ type: direct
46
+ attribute:
47
+ attributeProfile:
48
+ cardinality:
49
+ min: 0
50
+ max: '*'
51
+
52
+ - target: ProfileCompliantAddressComponent
53
+ relationship:
54
+ target:
55
+ type: direct
56
+ attribute:
57
+ profile:
58
+ cardinality:
59
+ min: 1
60
+ max: 1
61
+ action:
62
+ verb: compliesWith
63
+ direction: source
@@ -0,0 +1,15 @@
1
+ name: AddressComponentSpecification
2
+ modelType: class
3
+ definition: |
4
+ An `AddressComponentSpecification` specifies the cardinalities between a
5
+ `ProfileCompliantAddress` and `ProfileCompliantAddressComponents`.
6
+
7
+ A `ProfileComplinatAddress` MUST conform to this
8
+ `AddressComponentSpecification` to specifies its components.
9
+ attributes:
10
+ maxCardinality:
11
+ definition: The maximum number of instances of the specific `ProfileCompliantAddressComponent` of a `ProfileCompliantAddress`.
12
+ type: Integer
13
+ minCardinality:
14
+ definition: The minimum number of instances of the specific `ProfileCompliantAddressComponent` of a `ProfileCompliantAddress`.
15
+ type: Integer
@@ -0,0 +1,36 @@
1
+ name: AddressProfile
2
+ modelType: class
3
+ definition:
4
+ attributes:
5
+ country:
6
+ definition: The country of which this AddressProfile represents.
7
+ type: iso3166Code
8
+ cardinality:
9
+ min: 0
10
+ max: "*"
11
+ relations:
12
+ - target: AddressComponentProfile
13
+ relationship:
14
+ source:
15
+ type: aggregation
16
+ attribute:
17
+ componentProfile:
18
+ cardinality:
19
+ min: 0
20
+ max: "*"
21
+ action:
22
+ verb: defines
23
+ direction: target
24
+
25
+ - target: AddressClassProfile
26
+ relationship:
27
+ source:
28
+ type: aggregation
29
+ attribute:
30
+ addressProfile:
31
+ cardinality:
32
+ min: 0
33
+ max: "*"
34
+ action:
35
+ verb: defines
36
+ direction: target
@@ -0,0 +1,32 @@
1
+ modelType: class
2
+ definition: |
3
+ An `AttributeProfile` represents name, cardinalities and value type of an
4
+ attribute in a model that complies with a profile that includes this
5
+ AttributeProfile.
6
+
7
+ If it represents an attribute that has been previously defined, e.g. an
8
+ attribute in Address model defined in <<ISO19160-1>>, it extends the
9
+ definition of the attribute by redefining the name, cardinalities and value
10
+ type.
11
+ attributes:
12
+ name:
13
+ definition: The name of the attribute represented by this AttributeProfile.
14
+ type: CharacterString
15
+ minCardinality:
16
+ definition: The minimum number of occurrences of the attribute represented by this AttributeProfile.
17
+ type: Integer
18
+ cardinality:
19
+ min: 0
20
+ max: 1
21
+ maxCardinality:
22
+ definition: The maximum number of occurences of the attribute represented by this AttributeProfile.
23
+ type: Integer
24
+ cardinality:
25
+ min: 0
26
+ max: 1
27
+ valueType:
28
+ definition: The data type of values of the attribute represented by this AttributeProfile.
29
+ type: CharacterString
30
+ cardinality:
31
+ min: 0
32
+ max: 1
@@ -0,0 +1,79 @@
1
+ name: InterchangeAddressClassProfile
2
+ modelType: class
3
+ definition: |
4
+ This `InterchangeAddressClassProfile` extends from `AddressClassProfile` to
5
+ enforce the existence of several subclasses of `AttributeProfile` for
6
+ interchange.
7
+
8
+ It also introduces `FormTemplate` and `DisplayTemplate` to
9
+ to allow the display, entry of, and the interchange of an
10
+ `ProfileCompliantAddress` (address
11
+ instance complying with an `InterchangeAddressClassProfile`).
12
+ --
13
+ attributes:
14
+ relations:
15
+ - target: AddressClassProfile
16
+ relationship:
17
+ target:
18
+ type: inheritance
19
+
20
+ - target: AttributeProfileSignature
21
+ relationship:
22
+ source:
23
+ type: aggregation
24
+ attribute:
25
+ attributeProfile:
26
+ target:
27
+ type: direct
28
+ attribute:
29
+ addressClassProfile:
30
+
31
+ - target: AttributeProfileAddressFeature
32
+ relationship:
33
+ source:
34
+ type: aggregation
35
+ attribute:
36
+ attributeProfile:
37
+ target:
38
+ type: direct
39
+ attribute:
40
+ addressClassProfile:
41
+
42
+ - target: AttributeProfileValidity
43
+ relationship:
44
+ source:
45
+ type: aggregation
46
+ attribute:
47
+ attributeProfile:
48
+ target:
49
+ type: direct
50
+ attribute:
51
+ addressClassProfile:
52
+
53
+ - target: FormTemplate
54
+ relationship:
55
+ source:
56
+ type: aggregation
57
+ target:
58
+ attribute:
59
+ formTemplate:
60
+ cardinality:
61
+ min: 0
62
+ max: "*"
63
+ action:
64
+ verb: defines
65
+ direction: target
66
+
67
+ - target: DisplayTemplate
68
+ relationship:
69
+ source:
70
+ type: aggregation
71
+ target:
72
+ attribute:
73
+ displayTemplate:
74
+ cardinality:
75
+ min: 0
76
+ max: "*"
77
+ action:
78
+ verb: defines
79
+ direction: target
@@ -0,0 +1,23 @@
1
+ name: Localization
2
+ modelType: class
3
+ definition: |
4
+ The language and script used within the parent object.
5
+
6
+ Represented by the `PT_Locale` object defined in <<ISO19115-1>> and an
7
+ <<ISO15924>> script code.
8
+ attributes:
9
+ locale:
10
+ definition: The locale of the parent object.
11
+ type: iso19115PT_Locale
12
+ script:
13
+ definition: The type of written script used in the parent object.
14
+ type: iso15924Code
15
+ textDirection:
16
+ definition: Indicating in which direction the text of the parent should be read.
17
+ type: TextDirectionCode
18
+ relations:
19
+ - target: Validity
20
+ relationship:
21
+ target:
22
+ type: direct
23
+ direction: "[hidden]"