lutaml-sysml 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a3c6b07fe3d6c16e44fa3102c8dbddfe3a313ff7f6784bd7719491477633dc30
4
+ data.tar.gz: 96757eefb826e1127c48b5439d3c547317409c83c0990ad6f41dd76e4a652a93
5
+ SHA512:
6
+ metadata.gz: f94d9a5b0f63577e5a240566a96934ec6c4ef7118240ecdc570dc065363b7105f201649aafbd9a6d7280e1d8210b29213a5e93738e96d7fc41135d4b62e4b44a
7
+ data.tar.gz: 316d98b6c7c5d0e11e4667e4f2e04fe8b7a1ec60859898d899de7761a94b3dacbfef82a1594407635f5819600dbdda0cd50e0459be879e7e887bc64c3e19e787
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.5
6
+ before_install: gem install bundler -v 2.1.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at ronald.tse@ribose.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in lutaml-sysml.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
@@ -0,0 +1,40 @@
1
+ # Lutaml::Sysml
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/lutaml/sysml`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'lutaml-sysml'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install lutaml-sysml
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lutaml-sysml. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/lutaml-sysml/blob/master/CODE_OF_CONDUCT.md).
36
+
37
+
38
+ ## Code of Conduct
39
+
40
+ Everyone interacting in the Lutaml::Sysml project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/lutaml-sysml/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "lutaml/sysml"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ # resolve bin path, ignoring symlinks
5
+ require "pathname"
6
+ bin_file = Pathname.new(__FILE__).realpath
7
+
8
+ # add self to libpath
9
+ $:.unshift File.expand_path("../../lib", bin_file)
10
+
11
+ # Fixes https://github.com/rubygems/rubygems/issues/1420
12
+ require "rubygems/specification"
13
+
14
+ class Gem::Specification
15
+ def this; self; end
16
+ end
17
+
18
+ # start up the CLI
19
+ require "reeper"
20
+ Reeper::Cli.start(ARGV)
@@ -0,0 +1,10 @@
1
+ require "lutaml/sysml/version"
2
+ require "lutaml/uml"
3
+ require 'nokogiri'
4
+
5
+ module Lutaml
6
+ module Sysml
7
+ class Error < StandardError; end
8
+ # Your code goes here...
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ module Lutaml::SysMl
2
+
3
+
4
+ class Allocate < Lutaml::Uml::Abstraction
5
+ attr_accessor :base_abstraction
6
+ end
7
+
8
+ end
@@ -0,0 +1,7 @@
1
+ module Lutaml::SysMl
2
+
3
+ class Allocated < Lutaml::Uml::TopElement
4
+ attr_accessor :base_named_element, :allocated_from, :allocated_to
5
+ end
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ module Lutaml::SysMl
2
+
3
+ class BindingConnector < Lutaml::Uml::Connector
4
+ attr_accessor :base_connector
5
+ end
6
+
7
+ end
@@ -0,0 +1,27 @@
1
+ module Lutaml::SysMl
2
+
3
+ class Block < Lutaml::Uml::Class
4
+ attr_accessor :base_class
5
+ def initialize
6
+ @xmi_id = nil
7
+ @nested_classifier = []
8
+ @stereotype = []
9
+ @namespace = nil
10
+ end
11
+
12
+ def name
13
+ if base_class != nil and base_class.name != nil
14
+ return base_class.name
15
+ end
16
+ return nil
17
+ end
18
+
19
+ def full_name
20
+ if base_class != nil and base_class.name != nil
21
+ return base_class.full_name
22
+ end
23
+ return nil
24
+ end
25
+ end
26
+
27
+ end
@@ -0,0 +1,12 @@
1
+ module Lutaml::SysMl
2
+
3
+ class ConstraintBlock < Block
4
+ def initialize
5
+ @xmi_id = nil
6
+ @nested_classifier = []
7
+ @stereotype = []
8
+ @namespace = nil
9
+ end
10
+ end
11
+
12
+ end
@@ -0,0 +1,6 @@
1
+ module Lutaml::SysMl
2
+
3
+ class Copy < Trace
4
+ end
5
+
6
+ end
@@ -0,0 +1,7 @@
1
+ module Lutaml::SysMl
2
+
3
+ class DeriveRequirement < Lutaml::Uml::TopElement
4
+ attr_accessor :base_abstraction
5
+ end
6
+
7
+ end
@@ -0,0 +1,11 @@
1
+ module Lutaml::SysMl
2
+
3
+ class NestedConnectorEnd < Lutaml::Uml::ConnectorEnd
4
+ attr_accessor :base_connectorend, :property_path
5
+ def initialize
6
+ @property_path = []
7
+ end
8
+ end
9
+
10
+
11
+ end
@@ -0,0 +1,7 @@
1
+ module Lutaml::SysMl
2
+
3
+ class Refine < Lutaml::Uml::TopElement
4
+ attr_accessor :base_abstraction
5
+ end
6
+
7
+ end
@@ -0,0 +1,34 @@
1
+ module Lutaml::Sysml
2
+
3
+ class Requirement < Lutaml::Uml::Class
4
+ attr_accessor :id, :text, :base_class, :refined_by, :traced_to, :derived_from, :satisfied_by
5
+ def initialize
6
+ @xmi_id = nil
7
+ @id = nil
8
+ @nested_classifier = []
9
+ @stereotype = []
10
+ @namespace = nil
11
+ end
12
+ def name
13
+ if base_class != nil and base_class.name != nil
14
+ return base_class.name
15
+ end
16
+ return nil
17
+ end
18
+ def full_name
19
+ if base_class != nil and base_class.name != nil
20
+ return base_class.full_name
21
+ end
22
+ return nil
23
+ end
24
+ ## def name
25
+ ## if base_class != nil and base_class.name != nil
26
+ ## base_class.name
27
+ ## else
28
+ ## nil
29
+ ## end
30
+ ## end
31
+ ## def full_name
32
+ ## get_base_class_full_name ( self )
33
+ ## end
34
+ end
@@ -0,0 +1,7 @@
1
+ module Lutaml::SysMl
2
+
3
+ class RequirementRelated < Lutaml::Uml::TopElement
4
+ attr_accessor :base_named_element, :satisfies, :refines
5
+ end
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ module Lutaml::SysMl
2
+
3
+ class Satisfy < Trace
4
+ attr_accessor :base_realization
5
+ end
6
+
7
+ end
@@ -0,0 +1,22 @@
1
+ module Lutaml::SysMl
2
+
3
+ class TestCase < Lutaml::Uml::TopElement
4
+ attr_accessor :base_behavior, :verifies
5
+
6
+ def name
7
+ if base_behavior != nil and base_behavior.name != nil
8
+ return base_behavior.name
9
+ end
10
+ return nil
11
+ end
12
+
13
+ def full_name
14
+ if base_behavior != nil and base_behavior.name != nil
15
+ return base_behavior.full_name
16
+ end
17
+ return nil
18
+ end
19
+
20
+ end
21
+
22
+ end
@@ -0,0 +1,7 @@
1
+ module Lutaml::SysMl
2
+
3
+ class Trace < Lutaml::Uml::TopElement
4
+ attr_accessor :base_abstraction
5
+ end
6
+
7
+ end
@@ -0,0 +1,6 @@
1
+ module Lutaml::SysMl
2
+
3
+ class Verify < Trace
4
+ end
5
+
6
+ end
@@ -0,0 +1,5 @@
1
+ module Lutaml
2
+ module Sysml
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,417 @@
1
+ module Lutaml::SysMl
2
+
3
+ class XmiFile
4
+
5
+ attr_accessor :package_list, :model_list, :class_list, :activity_list, :property_list, :port_list, :datatype_list, :instance_list,
6
+ :realization_list, :abstraction_list, :association_list , :connector_list, :connectorend_list, :constraint_list, :block_list , :constraintblock_list,
7
+ :requirement_list, :testcase_list, :binding_connector_list, :nested_connectorend_list, :derive_requirement_list,
8
+ :refine_requirement_list, :trace_requirement_list, :copy_requirement_list, :verify_requirement_list, :satisfy_requirement_list ,
9
+ :allocate_requirement_list, :element_hash
10
+
11
+ def initialize
12
+ @package_list = []
13
+ @model_list = []
14
+ @class_list = []
15
+ @activity_list = []
16
+ @property_list = []
17
+ @port_list = []
18
+ @datatype_list = []
19
+ @instance_list = []
20
+ @realization_list = []
21
+ @abstraction_list = []
22
+ @association_list = []
23
+ @connector_list = []
24
+ @connectorend_list = []
25
+ @constraint_list = []
26
+
27
+ @block_list = []
28
+ @constraintblock_list = []
29
+ @requirement_list = []
30
+ @testcase_list = []
31
+ @binding_connector_list = []
32
+ @nested_connectorend_list = []
33
+ @derive_requirement_list = []
34
+ @refine_requirement_list = []
35
+ @trace_requirement_list = []
36
+ @copy_requirement_list = []
37
+ @verify_requirement_list = []
38
+ @satisfy_requirement_list = []
39
+ @allocate_requirement_list = []
40
+
41
+ @element_hash = Hash.new
42
+ end
43
+
44
+ def parse (filename)
45
+ xmifile = File.new(filename, "r")
46
+ inxml = Nokogiri::XML(xmifile)
47
+
48
+ xmi_elements = inxml.xpath('//xmi:XMI')
49
+ if xmi_elements.size == 0
50
+ puts "ERROR : File contains no 'xmi:XMI' XML elements : #{filename}, may not be XMI file."
51
+ xmifile.close
52
+ exit
53
+ end
54
+
55
+ #setup xmi namespace
56
+ xmiNS = inxml.root.namespace_definitions.find{|ns| ns.prefix=="xmi"}
57
+
58
+ ## Step 1: Find UML and SysML Core Objects in XMI file and create as instance of metamodel
59
+
60
+ for xml_node in inxml.xpath('//*' )
61
+ element_new = nil
62
+
63
+ if xml_node.name.to_s == 'packagedElement' and xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Package'
64
+ element_new = Lutaml::Uml::Package.new
65
+ package_list.push element_new
66
+ end
67
+
68
+ if xml_node.name.to_s == 'Model'
69
+ element_new = Lutaml::Uml::Model.new
70
+ model_list.push element_new
71
+ element_new.viewpoint = xml_node['viewpoint']
72
+ element_new.href = xml_node['href']
73
+ end
74
+
75
+ if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Class'
76
+ element_new = Lutaml::Uml::Class.new
77
+ if xml_node['isAbstract'] != nil
78
+ element_new.is_abstract = xml_node['isAbstract'] == 'true'
79
+ end
80
+ class_list.push element_new
81
+ end
82
+
83
+ if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Activity'
84
+ element_new = Lutaml::Uml::Activity.new
85
+ activity_list.push element_new
86
+ end
87
+
88
+ if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Property'
89
+ element_new = Lutaml::Uml::Property.new
90
+ property_list.push element_new
91
+ end
92
+
93
+ if xml_node.attribute_with_ns('type',xmiNS.href).to_s== 'uml:InstanceSpecification'
94
+ element_new = Lutaml::Uml::Instance.new
95
+ instance_list.push element_new
96
+ end
97
+
98
+ if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:DataType'
99
+ element_new = Lutaml::Uml::DataType.new
100
+ datatype_list.push element_new
101
+ end
102
+
103
+ if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Port'
104
+ element_new = Lutaml::Uml::Port.new
105
+ port_list.push element_new
106
+ end
107
+
108
+ if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Connector'
109
+ element_new = Lutaml::Uml::Connector.new
110
+ connector_list.push element_new
111
+ end
112
+
113
+ if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:ConnectorEnd'
114
+ element_new = Lutaml::Uml::ConnectorEnd.new
115
+ connectorend_list.push element_new
116
+ end
117
+
118
+ if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Constraint'
119
+ element_new = Lutaml::Uml::Constraint.new
120
+ constraint_list.push element_new
121
+ end
122
+
123
+ if xml_node.name.to_s == 'Block'
124
+ element_new = SYSML::Block.new
125
+ block_list.push element_new
126
+ end
127
+
128
+ if xml_node.name.to_s == 'Template'
129
+ element_new = SYSML::Block.new
130
+ block_list.push element_new
131
+ end
132
+
133
+ if xml_node.name.to_s == 'ConstraintBlock'
134
+ element_new = SYSML::ConstraintBlock.new
135
+ constraintblock_list.push element_new
136
+ end
137
+
138
+ if xml_node.name.to_s.index('Requirement') or xml_node.name.to_s == 'designConstraint'
139
+ if xml_node.name.to_s != 'RequirementRelated'
140
+ element_new = SYSML::Requirement.new
141
+ requirement_list.push element_new
142
+ element_new.id = xml_node.attribute_with_ns('id',xmiNS.href).to_s.strip
143
+ element_new.text = xml_node['Text']
144
+ if xml_node.name != 'Requirement'
145
+ element_new.stereotype.push xml_node.name
146
+ end
147
+ end
148
+ end
149
+
150
+ if xml_node.name.to_s == 'TestCase'
151
+ element_new = SYSML::TestCase.new
152
+ testcase_list.push element_new
153
+ end
154
+
155
+ if xml_node.name.to_s == 'BindingConnector'
156
+ element_new = SYSML::BindingConnector.new
157
+ binding_connector_list.push element_new
158
+ end
159
+
160
+ if xml_node.name.to_s == 'NestedConnectorEnd'
161
+ element_new = SYSML::NestedConnectorEnd.new
162
+ nested_connectorend_list.push element_new
163
+ end
164
+
165
+ if xml_node.name.to_s == 'DeriveReqt'
166
+ element_new = SYSML::DeriveRequirement.new
167
+ derive_requirement_list.push element_new
168
+ end
169
+ if xml_node.name.to_s == 'refine'
170
+ element_new = SYSML::Refine.new
171
+ refine_requirement_list.push element_new
172
+ end
173
+ if xml_node.name.to_s == 'trace'
174
+ element_new = SYSML::Trace.new
175
+ trace_requirement_list.push element_new
176
+ end
177
+ if xml_node.name.to_s == 'Copy'
178
+ element_new = SYSML::Copy.new
179
+ copy_requirement_list.push element_new
180
+ end
181
+ if xml_node.name.to_s == 'Verify'
182
+ element_new = SYSML::Verify.new
183
+ verify_requirement_list.push element_new
184
+ end
185
+ if xml_node.name.to_s == 'Allocate'
186
+ element_new = SYSML::Allocate.new
187
+ allocate_requirement_list.push element_new
188
+ end
189
+
190
+ if xml_node.name.to_s == 'Satisfy'
191
+ element_new = SYSML::Satisfy.new
192
+ satisfy_requirement_list.push element_new
193
+ end
194
+
195
+ if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Abstraction'
196
+ element_new = Lutaml::Uml::Abstraction.new
197
+ abstraction_list.push element_new
198
+ end
199
+
200
+ if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Realization'
201
+ element_new = Lutaml::Uml::Realization.new
202
+ realization_list.push element_new
203
+ end
204
+
205
+ if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Association'
206
+ element_new = Lutaml::Uml::Association.new
207
+ association_list.push element_new
208
+ end
209
+
210
+ if element_new != nil
211
+ new_xmi_id_node = xml_node.attribute_with_ns('id',xmiNS.href)
212
+ new_xmi_uuid_node = xml_node.attribute_with_ns('uuid',xmiNS.href)
213
+ new_name_node = xml_node['name']
214
+ new_href_node = xml_node['href']
215
+
216
+ if new_xmi_id_node != nil
217
+ element_new.xmi_id = new_xmi_id_node.to_s
218
+ element_hash[element_new.xmi_id] = element_new
219
+ end
220
+
221
+ if new_xmi_uuid_node != nil
222
+ element_new.xmi_uuid = new_xmi_uuid_node.to_s
223
+ end
224
+
225
+ if new_name_node != nil
226
+ element_new.name = xml_node['name'].strip
227
+ end
228
+
229
+ if new_href_node != nil
230
+ element_new.href = new_href_node.to_s
231
+ if new_xmi_id_node == nil
232
+ element_hash[element_new.href] = element_new
233
+ end
234
+ if xml_node.at('xmi:Extension/referenceExtension') != nil
235
+ element_new.name = xml_node.at('xmi:Extension/referenceExtension')['referentPath']
236
+ end
237
+ end
238
+
239
+ if (xml_node.parent != nil and
240
+ xml_node.parent.attribute_with_ns('id',xmiNS.href) != nil and
241
+ element_hash[xml_node.parent.attribute_with_ns('id',xmiNS.href).to_s] != nil)
242
+
243
+ parent = element_hash[xml_node.parent.attribute_with_ns('id',xmiNS.href).to_s]
244
+ element_new.namespace = parent
245
+ if parent.kind_of? Lutaml::Uml::Package
246
+ parent.contents.push element_new
247
+ end
248
+ end
249
+ end
250
+ end
251
+
252
+ for xml_node in inxml.xpath('//*')
253
+
254
+ if (xml_node.attribute_with_ns('id',xmiNS.href) != nil and
255
+ element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s] != nil)
256
+
257
+ this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
258
+ end
259
+
260
+ if xml_node.name.to_s == 'nestedClassifier' and xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Class'
261
+ owning_class_xmi_id = xml_node.parent.attribute_with_ns('id',xmiNS.href).to_s
262
+ owned_class_xmi_id = xml_node.attribute_with_ns('id',xmiNS.href).to_s
263
+ owning_class = element_hash[owning_class_xmi_id]
264
+ owned_class = element_hash[owned_class_xmi_id]
265
+ owning_class.nested_classifier.push owned_class
266
+ end
267
+
268
+ if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Realization'
269
+ this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
270
+ supplier_xmi_id = xml_node.at('supplier')['idref']
271
+ client_xmi_id = xml_node.at('client')['idref']
272
+ this_thing.supplier.push element_hash[supplier_xmi_id]
273
+ this_thing.client.push element_hash[client_xmi_id]
274
+ end
275
+
276
+ if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Abstraction'
277
+ this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
278
+ supplier_xmi_id = xml_node.at('supplier')['idref']
279
+ client_xmi_id = xml_node.at('client')['idref']
280
+ this_thing.supplier.push element_hash[supplier_xmi_id]
281
+ this_thing.client.push element_hash[client_xmi_id]
282
+ end
283
+
284
+ if xml_node.name.to_s == 'Block'
285
+ this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
286
+ base_class_xmi_id = xml_node['base_Class']
287
+ this_thing.base_class = element_hash[base_class_xmi_id]
288
+ end
289
+
290
+ if xml_node.name.to_s == 'Template'
291
+ this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
292
+ base_class_xmi_id = xml_node['base_Class']
293
+ this_thing.base_class = element_hash[base_class_xmi_id]
294
+ this_thing.base_class.stereotype.push 'Template'
295
+ end
296
+
297
+ if xml_node.name.to_s == 'ConstraintBlock'
298
+ this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
299
+ base_class_xmi_id = xml_node['base_Class']
300
+ this_thing.base_class = element_hash[base_class_xmi_id]
301
+ end
302
+
303
+ if xml_node.name.to_s.index('Requirement') or xml_node.name.to_s == 'designConstraint'
304
+ if xml_node.name.to_s != 'RequirementRelated'
305
+ this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
306
+ base_class_xmi_id = xml_node['base_Class']
307
+ this_thing.base_class = element_hash[base_class_xmi_id]
308
+ this_thing.refined_by = element_hash[xml_node['RefinedBy']]
309
+ this_thing.derived_from = element_hash[xml_node['DerivedFrom']]
310
+ this_thing.traced_to = element_hash[xml_node['TracedTo']]
311
+ end
312
+ end
313
+
314
+ if xml_node.name.to_s == 'TestCase'
315
+ this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
316
+ this_thing.base_behavior = element_hash[xml_node['base_Behavior']]
317
+ this_thing.verifies = element_hash[xml_node['Verifies']]
318
+ end
319
+
320
+ if xml_node.name.to_s == 'BindingConnector'
321
+ this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
322
+ base_connector_xmi_id = xml_node['base_Connector']
323
+ this_thing.base_connector = element_hash[base_connector_xmi_id]
324
+ end
325
+
326
+ if xml_node.name.to_s == 'NestedConnectorEnd'
327
+ this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
328
+ base_connectorend_xmi_id = xml_node['base_ConnectorEnd']
329
+ this_thing.base_connectorend = element_hash[base_connectorend_xmi_id]
330
+ if xml_node['propertyPath'] != nil
331
+ this_thing.property_path.push element_hash[xml_node['propertyPath']]
332
+ else
333
+ for prop_path in xml_node.xpath('./propertyPath')
334
+ #to deal with href = '#xmi:id' i.e. local references
335
+ href_parts = prop_path['href'].split('#')
336
+ if href_parts[0].size == 0
337
+ prop = element_hash[href_parts[1]]
338
+ else
339
+ prop = element_hash[prop_path['href']]
340
+ end
341
+ this_thing.property_path.push prop
342
+ end
343
+ end
344
+ end
345
+
346
+ if xml_node.name.to_s == 'Satisfy'
347
+ this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
348
+ base_realization_xmi_id = xml_node['base_Realization']
349
+ this_thing.base_realization = element_hash[base_realization_xmi_id]
350
+ end
351
+
352
+ if ['DeriveReqt', 'refine', 'trace', 'Copy', 'Verify', 'Allocate', ''].include? xml_node.name.to_s
353
+ this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
354
+ base_abstraction_xmi_id = xml_node['base_Abstraction']
355
+ this_thing.base_abstraction = element_hash[base_abstraction_xmi_id]
356
+ end
357
+
358
+ if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Association'
359
+ this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
360
+ member_end_list = xml_node.xpath('./memberEnd')
361
+ for item in member_end_list
362
+ this_thing.member_end.push element_hash[item['idref']]
363
+ end
364
+ owned_end_list = xml_node.xpath('./ownedEnd')
365
+ for item in owned_end_list
366
+ this_thing.owned_end.push element_hash[item.attribute_with_ns('id',xmiNS.href).to_s]
367
+ end
368
+ end
369
+
370
+ if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Property' or xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Port'
371
+ if not ['definingFeature', 'partWithPort', 'propertyPath', 'role'].include? xml_node.name.to_s
372
+ this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
373
+ if xml_node['association'] != nil
374
+ this_thing.association = element_hash[xml_node['association']]
375
+ end
376
+ if xml_node['aggregation'] != nil
377
+ this_thing.aggregation = xml_node['aggregation']
378
+ end
379
+ if xml_node['visibility'] != nil
380
+ this_thing.visibility = xml_node['visibility']
381
+ end
382
+
383
+ if xml_node.at('lowerValue') != nil
384
+
385
+ if xml_node.at('lowerValue')['value'] != nil
386
+ this_thing.lowerValue = xml_node.at('lowerValue')['value']
387
+ else
388
+ this_thing.lowerValue = '0'
389
+ end
390
+ end
391
+ if xml_node.at('upperValue') != nil
392
+ this_thing.upperValue = xml_node.at('upperValue')['value']
393
+ end
394
+ end
395
+ end
396
+
397
+ if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Connector'
398
+ this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
399
+ connector_end_list = xml_node.xpath('./end')
400
+ for end_xml_node in connector_end_list
401
+ this_thing.connector_end.push element_hash[end_xml_node.attribute_with_ns('id',xmiNS.href).to_s]
402
+ end
403
+ end
404
+
405
+ if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:ConnectorEnd'
406
+ this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
407
+ this_thing.connector = element_hash[xml_node.parent.attribute_with_ns('id',xmiNS.href).to_s]
408
+ this_thing.role = element_hash[xml_node['role']]
409
+ if this_thing.role == nil
410
+ this_thing.role = element_hash[xml_node.at('role')['href']]
411
+ end
412
+ this_thing.part_with_port = element_hash[xml_node['part_with_port']]
413
+ end
414
+ end
415
+ end
416
+ end
417
+ end
@@ -0,0 +1,34 @@
1
+ require_relative 'lib/lutaml/sysml/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "lutaml-sysml"
5
+ spec.version = Lutaml::Sysml::VERSION
6
+ spec.authors = ["Ribose Inc."]
7
+ spec.email = ["open.source@ribose.com'"]
8
+
9
+ spec.summary = "SysML model module for LutaML."
10
+ spec.description = "SysML model module for LutaML."
11
+ spec.homepage = "https://github.com/lutaml/lutaml-sysml"
12
+ spec.license = "MIT"
13
+
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+ spec.metadata["source_code_uri"] = spec.homepage
16
+ spec.metadata["changelog_uri"] = "https://github.com/lutaml/lutaml-sysml/releases"
17
+
18
+ spec.files = `git ls-files`.split("\n")
19
+ spec.test_files = `git ls-files -- {spec}/*`.split("\n")
20
+
21
+ spec.bindir = "exe"
22
+ spec.require_paths = ["lib"]
23
+ spec.executables = %w[lutaml-sysml]
24
+
25
+ spec.add_runtime_dependency "thor", "~> 1.0"
26
+ spec.add_runtime_dependency "activesupport", "~> 5.0"
27
+ # spec.add_runtime_dependency "lutaml-uml"
28
+ spec.add_development_dependency "nokogiri", "~> 1.10"
29
+
30
+ spec.add_development_dependency "bundler", "~> 2.0"
31
+ spec.add_development_dependency "pry", "~> 0.12.2"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "rspec", "~> 3.0"
34
+ end
@@ -0,0 +1,9 @@
1
+ RSpec.describe Lutaml::Sysml do
2
+ it "has a version number" do
3
+ expect(Lutaml::Sysml::VERSION).not_to be nil
4
+ end
5
+
6
+ it "does something useful" do
7
+ expect(false).to eq(true)
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ require "bundler/setup"
2
+ require "lutaml/sysml"
3
+
4
+ RSpec.configure do |config|
5
+ # Enable flags like --only-failures and --next-failure
6
+ config.example_status_persistence_file_path = ".rspec_status"
7
+
8
+ # Disable RSpec exposing methods globally on `Module` and `main`
9
+ config.disable_monkey_patching!
10
+
11
+ config.expect_with :rspec do |c|
12
+ c.syntax = :expect
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,176 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lutaml-sysml
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ribose Inc.
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-06-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.12.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.12.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.0'
111
+ description: SysML model module for LutaML.
112
+ email:
113
+ - open.source@ribose.com'
114
+ executables:
115
+ - lutaml-sysml
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".travis.yml"
122
+ - CODE_OF_CONDUCT.md
123
+ - Gemfile
124
+ - README.md
125
+ - Rakefile
126
+ - bin/console
127
+ - bin/setup
128
+ - exe/lutaml-sysml
129
+ - lib/lutaml/sysml.rb
130
+ - lib/lutaml/sysml/allocate.rb
131
+ - lib/lutaml/sysml/allocated.rb
132
+ - lib/lutaml/sysml/binding_connector.rb
133
+ - lib/lutaml/sysml/block.rb
134
+ - lib/lutaml/sysml/constraint_block.rb
135
+ - lib/lutaml/sysml/copy.rb
136
+ - lib/lutaml/sysml/derive_requirement.rb
137
+ - lib/lutaml/sysml/nested_connector_end.rb
138
+ - lib/lutaml/sysml/refine.rb
139
+ - lib/lutaml/sysml/requirement.rb
140
+ - lib/lutaml/sysml/requirement_related.rb
141
+ - lib/lutaml/sysml/satisfy.rb
142
+ - lib/lutaml/sysml/test_case.rb
143
+ - lib/lutaml/sysml/trace.rb
144
+ - lib/lutaml/sysml/verify.rb
145
+ - lib/lutaml/sysml/version.rb
146
+ - lib/lutaml/sysml/xmi_file.rb
147
+ - lutaml-sysml.gemspec
148
+ - spec/lutaml/sysml_spec.rb
149
+ - spec/spec_helper.rb
150
+ homepage: https://github.com/lutaml/lutaml-sysml
151
+ licenses:
152
+ - MIT
153
+ metadata:
154
+ homepage_uri: https://github.com/lutaml/lutaml-sysml
155
+ source_code_uri: https://github.com/lutaml/lutaml-sysml
156
+ changelog_uri: https://github.com/lutaml/lutaml-sysml/releases
157
+ post_install_message:
158
+ rdoc_options: []
159
+ require_paths:
160
+ - lib
161
+ required_ruby_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ required_rubygems_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: '0'
171
+ requirements: []
172
+ rubygems_version: 3.0.3
173
+ signing_key:
174
+ specification_version: 4
175
+ summary: SysML model module for LutaML.
176
+ test_files: []