rgen 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. data/CHANGELOG +6 -0
  2. data/lib/mmgen/metamodel_generator.rb +2 -1
  3. data/lib/mmgen/mm_ext/{ecore_ext.rb → ecore_mmgen_ext.rb} +3 -7
  4. data/lib/mmgen/templates/metamodel_generator.tpl +10 -8
  5. data/lib/rgen/ecore/ecore_ext.rb +69 -0
  6. data/lib/rgen/ecore/ecore_transformer.rb +1 -1
  7. data/lib/rgen/metamodel_builder/builder_extensions.rb +10 -2
  8. data/lib/rgen/serializer/xmi11_serializer.rb +101 -0
  9. data/lib/rgen/serializer/xmi20_serializer.rb +7 -7
  10. data/lib/rgen/serializer/xml_serializer.rb +47 -14
  11. data/test/ea_serializer_test.rb +29 -0
  12. data/test/ea_serializer_test/ea_testmodel_regenerated.xml +821 -0
  13. data/test/metamodel_roundtrip_test.rb +1 -2
  14. data/test/metamodel_roundtrip_test/TestModel.rb +1 -0
  15. data/test/metamodel_roundtrip_test/TestModel_Regenerated.rb +34 -35
  16. data/test/metamodel_roundtrip_test/houseMetamodel_Regenerated.ecore +128 -236
  17. data/test/rgen_test.rb +1 -0
  18. metadata +93 -95
  19. data/lib/rgen/metamodel_builder.rb.bak +0 -196
  20. data/lib/rgen/metamodel_builder/builder_extensions.rb.bak +0 -437
  21. data/lib/rgen/metamodel_builder/builder_runtime.rb.bak +0 -73
  22. data/lib/rgen/name_helper.rb.bak +0 -37
  23. data/lib/rgen/template_language.rb.bak +0 -289
  24. data/lib/rgen/template_language/directory_template_container.rb.bak +0 -69
  25. data/lib/rgen/template_language/output_handler.rb.bak +0 -88
  26. data/lib/rgen/template_language/template_container.rb.bak +0 -196
  27. data/lib/rgen/transformer.rb.bak +0 -381
  28. data/test/environment_test.rb.bak +0 -52
  29. data/test/metamodel_builder_test.rb.bak +0 -443
  30. data/test/output_handler_test.rb.bak +0 -50
  31. data/test/template_language_test.rb.bak +0 -72
  32. data/test/transformer_test.rb.bak +0 -223
data/test/rgen_test.rb CHANGED
@@ -12,3 +12,4 @@ require 'output_handler_test'
12
12
  require 'template_language_test'
13
13
  require 'transformer_test'
14
14
  require 'xml_instantiator_test'
15
+ require 'ea_serializer_test'
metadata CHANGED
@@ -1,138 +1,121 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
3
- specification_version: 1
4
2
  name: rgen
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.4.3
7
- date: 2008-08-12 00:00:00 +02:00
8
- summary: Ruby Modelling and Generator Framework
9
- require_paths:
10
- - lib
11
- email:
12
- homepage:
13
- rubyforge_project: rgen
14
- description: RGen is a framework supporting Model Driven Software Development (MDSD). This means that it helps you build Metamodels, instantiate Models, modify and transform Models and finally generate arbitrary textual content from it.
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 0.4.4
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Martin Thiede
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-09-10 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: RGen is a framework supporting Model Driven Software Development (MDSD). This means that it helps you build Metamodels, instantiate Models, modify and transform Models and finally generate arbitrary textual content from it.
17
+ email: martin dot thiede at gmx de
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - CHANGELOG
25
+ - MIT-LICENSE
31
26
  files:
32
27
  - lib/instantiators
33
- - lib/metamodels
34
- - lib/mmgen
35
- - lib/rgen
36
- - lib/transformers
37
28
  - lib/instantiators/ea_instantiator.rb
29
+ - lib/metamodels
38
30
  - lib/metamodels/uml13_metamodel.rb
39
31
  - lib/metamodels/uml13_metamodel_ext.rb
32
+ - lib/mmgen
40
33
  - lib/mmgen/metamodel_generator.rb
41
34
  - lib/mmgen/mmgen.rb
42
35
  - lib/mmgen/mm_ext
36
+ - lib/mmgen/mm_ext/ecore_mmgen_ext.rb
43
37
  - lib/mmgen/templates
44
- - lib/mmgen/mm_ext/ecore_ext.rb
45
38
  - lib/mmgen/templates/annotations.tpl
46
39
  - lib/mmgen/templates/metamodel_generator.tpl
40
+ - lib/rgen
47
41
  - lib/rgen/array_extensions.rb
48
42
  - lib/rgen/auto_class_creator.rb
49
43
  - lib/rgen/ecore
50
- - lib/rgen/environment.rb
51
- - lib/rgen/instantiator
52
- - lib/rgen/metamodel_builder
53
- - lib/rgen/metamodel_builder.rb
54
- - lib/rgen/metamodel_builder.rb.bak
55
- - lib/rgen/model_comparator.rb
56
- - lib/rgen/model_dumper.rb
57
- - lib/rgen/name_helper.rb
58
- - lib/rgen/name_helper.rb.bak
59
- - lib/rgen/serializer
60
- - lib/rgen/template_language
61
- - lib/rgen/template_language.rb
62
- - lib/rgen/template_language.rb.bak
63
- - lib/rgen/transformer.rb
64
- - lib/rgen/transformer.rb.bak
65
44
  - lib/rgen/ecore/ecore.rb
45
+ - lib/rgen/ecore/ecore_ext.rb
66
46
  - lib/rgen/ecore/ecore_instantiator.rb
67
47
  - lib/rgen/ecore/ecore_transformer.rb
48
+ - lib/rgen/environment.rb
49
+ - lib/rgen/instantiator
68
50
  - lib/rgen/instantiator/abstract_instantiator.rb
69
51
  - lib/rgen/instantiator/abstract_xml_instantiator.rb
70
52
  - lib/rgen/instantiator/default_xml_instantiator.rb
71
53
  - lib/rgen/instantiator/ecore_xml_instantiator.rb
72
54
  - lib/rgen/instantiator/nodebased_xml_instantiator.rb
73
55
  - lib/rgen/instantiator/xmi11_instantiator.rb
56
+ - lib/rgen/metamodel_builder
74
57
  - lib/rgen/metamodel_builder/builder_extensions.rb
75
- - lib/rgen/metamodel_builder/builder_extensions.rb.bak
76
58
  - lib/rgen/metamodel_builder/builder_runtime.rb
77
- - lib/rgen/metamodel_builder/builder_runtime.rb.bak
78
59
  - lib/rgen/metamodel_builder/data_types.rb
79
60
  - lib/rgen/metamodel_builder/intermediate
61
+ - lib/rgen/metamodel_builder/intermediate/annotation.rb
80
62
  - lib/rgen/metamodel_builder/metamodel_description.rb
81
63
  - lib/rgen/metamodel_builder/mm_multiple.rb
82
64
  - lib/rgen/metamodel_builder/module_extension.rb
83
- - lib/rgen/metamodel_builder/intermediate/annotation.rb
65
+ - lib/rgen/metamodel_builder.rb
66
+ - lib/rgen/model_comparator.rb
67
+ - lib/rgen/model_dumper.rb
68
+ - lib/rgen/name_helper.rb
69
+ - lib/rgen/serializer
70
+ - lib/rgen/serializer/xmi11_serializer.rb
84
71
  - lib/rgen/serializer/xmi20_serializer.rb
85
72
  - lib/rgen/serializer/xml_serializer.rb
73
+ - lib/rgen/template_language
86
74
  - lib/rgen/template_language/directory_template_container.rb
87
- - lib/rgen/template_language/directory_template_container.rb.bak
88
75
  - lib/rgen/template_language/output_handler.rb
89
- - lib/rgen/template_language/output_handler.rb.bak
90
76
  - lib/rgen/template_language/template_container.rb
91
- - lib/rgen/template_language/template_container.rb.bak
92
77
  - lib/rgen/template_language/template_helper.rb
78
+ - lib/rgen/template_language.rb
79
+ - lib/rgen/transformer.rb
80
+ - lib/transformers
93
81
  - lib/transformers/uml13_to_ecore.rb
94
82
  - test/array_extensions_test.rb
95
83
  - test/ea_instantiator_test.rb
84
+ - test/ea_serializer_test
85
+ - test/ea_serializer_test/ea_testmodel_regenerated.xml
86
+ - test/ea_serializer_test.rb
96
87
  - test/ecore_self_test.rb
97
88
  - test/environment_test.rb
98
- - test/environment_test.rb.bak
99
89
  - test/metamodel_builder_test.rb
100
- - test/metamodel_builder_test.rb.bak
101
90
  - test/metamodel_roundtrip_test
102
- - test/metamodel_roundtrip_test.rb
103
- - test/output_handler_test.rb
104
- - test/output_handler_test.rb.bak
105
- - test/rgen_test.rb
106
- - test/template_language_test
107
- - test/template_language_test.rb
108
- - test/template_language_test.rb.bak
109
- - test/testmodel
110
- - test/transformer_test.rb
111
- - test/transformer_test.rb.bak
112
- - test/xml_instantiator_test
113
- - test/xml_instantiator_test.rb
114
91
  - test/metamodel_roundtrip_test/houseMetamodel.ecore
115
92
  - test/metamodel_roundtrip_test/houseMetamodel_from_ecore.rb
116
93
  - test/metamodel_roundtrip_test/houseMetamodel_Regenerated.ecore
117
94
  - test/metamodel_roundtrip_test/TestModel.rb
118
95
  - test/metamodel_roundtrip_test/TestModel_Regenerated.rb
96
+ - test/metamodel_roundtrip_test.rb
97
+ - test/output_handler_test.rb
98
+ - test/rgen_test.rb
99
+ - test/template_language_test
119
100
  - test/template_language_test/expected_result.txt
120
101
  - test/template_language_test/indentStringTestDefaultIndent.out
121
102
  - test/template_language_test/indentStringTestTabIndent.out
122
103
  - test/template_language_test/templates
123
- - test/template_language_test/testout.txt
124
104
  - test/template_language_test/templates/code
125
- - test/template_language_test/templates/content
126
- - test/template_language_test/templates/indent_string_test.tpl
127
- - test/template_language_test/templates/index
128
- - test/template_language_test/templates/null_context_test.tpl
129
- - test/template_language_test/templates/root.tpl
130
105
  - test/template_language_test/templates/code/array.tpl
106
+ - test/template_language_test/templates/content
131
107
  - test/template_language_test/templates/content/author.tpl
132
108
  - test/template_language_test/templates/content/chapter.tpl
109
+ - test/template_language_test/templates/indent_string_test.tpl
110
+ - test/template_language_test/templates/index
133
111
  - test/template_language_test/templates/index/c
134
- - test/template_language_test/templates/index/chapter.tpl
135
112
  - test/template_language_test/templates/index/c/cmod.tpl
113
+ - test/template_language_test/templates/index/chapter.tpl
114
+ - test/template_language_test/templates/null_context_test.tpl
115
+ - test/template_language_test/templates/root.tpl
116
+ - test/template_language_test/testout.txt
117
+ - test/template_language_test.rb
118
+ - test/testmodel
136
119
  - test/testmodel/class_model_checker.rb
137
120
  - test/testmodel/ea_testmodel.eap
138
121
  - test/testmodel/ea_testmodel.xml
@@ -140,38 +123,35 @@ files:
140
123
  - test/testmodel/ecore_model_checker.rb
141
124
  - test/testmodel/manual_testmodel.xml
142
125
  - test/testmodel/object_model_checker.rb
126
+ - test/transformer_test.rb
127
+ - test/xml_instantiator_test
143
128
  - test/xml_instantiator_test/simple_ecore_model_checker.rb
144
129
  - test/xml_instantiator_test/simple_xmi_ecore_instantiator.rb
145
130
  - test/xml_instantiator_test/simple_xmi_metamodel.rb
146
131
  - test/xml_instantiator_test/simple_xmi_to_ecore.rb
132
+ - test/xml_instantiator_test.rb
147
133
  - redist/xmlscan
148
134
  - redist/xmlscan/ChangeLog
149
135
  - redist/xmlscan/doc
150
- - redist/xmlscan/install.rb
151
- - redist/xmlscan/lib
152
- - redist/xmlscan/memo
153
- - redist/xmlscan/README
154
- - redist/xmlscan/samples
155
- - redist/xmlscan/test.rb
156
- - redist/xmlscan/tests
157
- - redist/xmlscan/THANKS
158
136
  - redist/xmlscan/doc/changes.html
159
137
  - redist/xmlscan/doc/changes.rd
160
138
  - redist/xmlscan/doc/en
161
- - redist/xmlscan/doc/ja
162
- - redist/xmlscan/doc/src
163
139
  - redist/xmlscan/doc/en/conformance.html
164
140
  - redist/xmlscan/doc/en/conformance.rd
165
141
  - redist/xmlscan/doc/en/manual.html
166
142
  - redist/xmlscan/doc/en/manual.rd
143
+ - redist/xmlscan/doc/ja
167
144
  - redist/xmlscan/doc/ja/conformance.ja.html
168
145
  - redist/xmlscan/doc/ja/conformance.ja.rd
169
146
  - redist/xmlscan/doc/ja/manual.ja.html
170
147
  - redist/xmlscan/doc/ja/manual.ja.rd
148
+ - redist/xmlscan/doc/src
171
149
  - redist/xmlscan/doc/src/conformance.rd.src
172
150
  - redist/xmlscan/doc/src/langsplit.rb
173
151
  - redist/xmlscan/doc/src/Makefile
174
152
  - redist/xmlscan/doc/src/manual.rd.src
153
+ - redist/xmlscan/install.rb
154
+ - redist/xmlscan/lib
175
155
  - redist/xmlscan/lib/xmlscan
176
156
  - redist/xmlscan/lib/xmlscan/encoding.rb
177
157
  - redist/xmlscan/lib/xmlscan/htmlscan.rb
@@ -181,17 +161,17 @@ files:
181
161
  - redist/xmlscan/lib/xmlscan/version.rb
182
162
  - redist/xmlscan/lib/xmlscan/visitor.rb
183
163
  - redist/xmlscan/lib/xmlscan/xmlchar.rb
164
+ - redist/xmlscan/memo
184
165
  - redist/xmlscan/memo/CONFORMANCE
185
166
  - redist/xmlscan/memo/contentspec.ry
186
167
  - redist/xmlscan/memo/PRODUCTIONS
168
+ - redist/xmlscan/README
169
+ - redist/xmlscan/samples
187
170
  - redist/xmlscan/samples/chibixml.rb
188
171
  - redist/xmlscan/samples/getxmlchar.rb
189
172
  - redist/xmlscan/samples/rexml.rb
190
173
  - redist/xmlscan/samples/xmlbench
191
- - redist/xmlscan/samples/xmlbench.rb
192
- - redist/xmlscan/samples/xmlconftest.rb
193
174
  - redist/xmlscan/samples/xmlbench/parser
194
- - redist/xmlscan/samples/xmlbench/xmlbench-lib.rb
195
175
  - redist/xmlscan/samples/xmlbench/parser/chibixml.rb
196
176
  - redist/xmlscan/samples/xmlbench/parser/nqxml.rb
197
177
  - redist/xmlscan/samples/xmlbench/parser/rexml.rb
@@ -200,6 +180,11 @@ files:
200
180
  - redist/xmlscan/samples/xmlbench/parser/xmlscan-chibixml.rb
201
181
  - redist/xmlscan/samples/xmlbench/parser/xmlscan-rexml.rb
202
182
  - redist/xmlscan/samples/xmlbench/parser/xmlscan.rb
183
+ - redist/xmlscan/samples/xmlbench/xmlbench-lib.rb
184
+ - redist/xmlscan/samples/xmlbench.rb
185
+ - redist/xmlscan/samples/xmlconftest.rb
186
+ - redist/xmlscan/test.rb
187
+ - redist/xmlscan/tests
203
188
  - redist/xmlscan/tests/deftestcase.rb
204
189
  - redist/xmlscan/tests/runtest.rb
205
190
  - redist/xmlscan/tests/testall.rb
@@ -210,11 +195,13 @@ files:
210
195
  - redist/xmlscan/tests/testscanner.rb
211
196
  - redist/xmlscan/tests/testxmlchar.rb
212
197
  - redist/xmlscan/tests/visitor.rb
198
+ - redist/xmlscan/THANKS
213
199
  - README
214
200
  - CHANGELOG
215
201
  - MIT-LICENSE
216
- test_files: []
217
-
202
+ has_rdoc: true
203
+ homepage: ruby-gen.org
204
+ post_install_message:
218
205
  rdoc_options:
219
206
  - --main
220
207
  - README
@@ -224,15 +211,26 @@ rdoc_options:
224
211
  - test
225
212
  - -x
226
213
  - metamodels
227
- extra_rdoc_files:
228
- - README
229
- - CHANGELOG
230
- - MIT-LICENSE
231
- executables: []
232
-
233
- extensions: []
234
-
214
+ require_paths:
215
+ - lib
216
+ required_ruby_version: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - ">="
219
+ - !ruby/object:Gem::Version
220
+ version: "0"
221
+ version:
222
+ required_rubygems_version: !ruby/object:Gem::Requirement
223
+ requirements:
224
+ - - ">="
225
+ - !ruby/object:Gem::Version
226
+ version: "0"
227
+ version:
235
228
  requirements: []
236
229
 
237
- dependencies: []
230
+ rubyforge_project: rgen
231
+ rubygems_version: 1.1.1
232
+ signing_key:
233
+ specification_version: 2
234
+ summary: Ruby Modelling and Generator Framework
235
+ test_files: []
238
236
 
@@ -1,196 +0,0 @@
1
- # RGen Framework
2
- # (c) Martin Thiede, 2006
3
-
4
- require 'rgen/metamodel_builder/builder_runtime'
5
- require 'rgen/metamodel_builder/builder_extensions'
6
- require 'rgen/metamodel_builder/module_extension'
7
- require 'rgen/metamodel_builder/data_types'
8
- require 'rgen/metamodel_builder/mm_multiple'
9
- require 'rgen/ecore/ecore_instantiator'
10
-
11
- module RGen
12
-
13
- # MetamodelBuilder can be used to create a metamodel, i.e. Ruby classes which
14
- # act as metamodel elements.
15
- #
16
- # To create a new metamodel element, create a Ruby class which inherits from
17
- # MetamodelBuilder::MMBase
18
- #
19
- # class Person < RGen::MetamodelBuilder::MMBase
20
- # end
21
- #
22
- # This way a couple of class methods are made available to the new class.
23
- # These methods can be used to:
24
- # * add attributes to the class
25
- # * add associations with other classes
26
- #
27
- # Here is an example:
28
- #
29
- # class Person < RGen::MetamodelBuilder::MMBase
30
- # has_attr 'name', String
31
- # has_attr 'age', Integer
32
- # end
33
- #
34
- # class House < RGen::MetamodelBuilder::MMBase
35
- # has_attr 'address' # String is default
36
- # end
37
- #
38
- # Person.many_to_many 'homes', House, 'inhabitants'
39
- #
40
- # See BuilderExtensions for details about the available class methods.
41
- #
42
- # =Attributes
43
- #
44
- # The example above creates two classes 'Person' and 'House'. Person has the attributes
45
- # 'name' and 'age', House has the attribute 'address'. The attributes can be
46
- # accessed on instances of the classes in the following way:
47
- #
48
- # p = Person.new
49
- # p.name = "MyName"
50
- # p.age = 22
51
- # p.name # => "MyName"
52
- # p.age # => 22
53
- #
54
- # Note that the class Person takes care of the type of its attributes. As
55
- # declared above, a 'name' can only be a String, an 'age' must be an Integer.
56
- # So the following would return an exception:
57
- #
58
- # p.name = :myName # => exception: can not put a Symbol where a String is expected
59
- #
60
- # If the type of an attribute should be left undefined, use Object as type.
61
- #
62
- # =Associations
63
- #
64
- # As well as attributes show up as instance methods, associations bring their own
65
- # accessor methods. For the Person-to-House association this would be:
66
- #
67
- # h1 = House.new
68
- # h1.address = "Street1"
69
- # h2 = House.new
70
- # h2.address = "Street2"
71
- # p.addHomes(h1)
72
- # p.addHomes(h2)
73
- # p.removeHomes(h1)
74
- # p.homes # => [ h2 ]
75
- #
76
- # The Person-to-House association is _bidirectional_. This means that with the
77
- # addition of a House to a Person, the Person is also added to the House. Thus:
78
- #
79
- # h1.inhabitants # => []
80
- # h2.inhabitants # => [ p ]
81
- #
82
- # Note that the association is defined between two specific classes, instances of
83
- # different classes can not be added. Thus, the following would result in an
84
- # exception:
85
- #
86
- # p.addHomes(:justASymbol) # => exception: can not put a Symbol where a House is expected
87
- #
88
- # =ECore Metamodel description
89
- #
90
- # The class methods described above are used to create a Ruby representation of the metamodel
91
- # we have in mind in a very simple and easy way. We don't have to care about all the details
92
- # of a metamodel at this point (e.g. multiplicities, changeability, etc).
93
- #
94
- # At the same time however, an instance of the ECore metametamodel (i.e. a ECore based
95
- # description of our metamodel) is provided for all the Ruby classes and modules we create.
96
- # Since we did not provide the nitty-gritty details of the metamodel, defaults are used to
97
- # fully complete the ECore metamodel description.
98
- #
99
- # In order to access the ECore metamodel description, just call the +ecore+ method on a
100
- # Ruby class or module object belonging to your metamodel.
101
- #
102
- # Here is the example continued from above:
103
- #
104
- # Person.ecore.eAttributes.name # => ["name", "age"]
105
- # h2pRef = House.ecore.eReferences.first
106
- # h2pRef.eType # => Person
107
- # h2pRef.eOpposite.eType # => House
108
- # h2pRef.lowerBound # => 0
109
- # h2pRef.upperBound # => -1
110
- # h2pRef.many # => true
111
- # h2pRef.containment # => false
112
- #
113
- # Note that the use of array_extensions.rb is assumed here to make model navigation convenient.
114
- #
115
- # The following metamodel builder methods are supported, see individual method description
116
- # for details:
117
- #
118
- # Attributes:
119
- # * BuilderExtensions#has_attr
120
- #
121
- # Unidirectional references:
122
- # * BuilderExtensions#has_one
123
- # * BuilderExtensions#has_many
124
- # * BuilderExtensions#contains_one_uni
125
- # * BuilderExtensions#contains_many_uni
126
- #
127
- # Bidirectional references:
128
- # * BuilderExtensions#one_to_one
129
- # * BuilderExtensions#one_to_many
130
- # * BuilderExtensions#many_to_one
131
- # * BuilderExtensions#many_to_many
132
- # * BuilderExtensions#contains_one
133
- # * BuilderExtensions#contains_many
134
- #
135
- # Every builder command can optionally take a specification of further ECore properties.
136
- # Additional properties for Attributes and References are (with defaults in brackets):
137
- # * :ordered (true),
138
- # * :unique (true),
139
- # * :changeable (true),
140
- # * :volatile (false),
141
- # * :transient (false),
142
- # * :unsettable (false),
143
- # * :derived (false),
144
- # * :lowerBound (0),
145
- # * :resolveProxies (true) <i>references only</i>,
146
- #
147
- # Using these additional properties, the above example can be refined as follows:
148
- #
149
- # class Person < RGen::MetamodelBuilder::MMBase
150
- # has_attr 'name', String, :lowerBound => 1
151
- # has_attr 'yearOfBirth', Integer,
152
- # has_attr 'age', Integer, :derived => true
153
- # def age_derived
154
- # Time.now.year - yearOfBirth
155
- # end
156
- # end
157
- #
158
- # Person.many_to_many 'homes', House, 'inhabitants', :upperBound => 5
159
- #
160
- # Person.ecore.eReferences.find{|r| r.name == 'homes'}.upperBound # => 5
161
- #
162
- # This way we state that there must be a name for each person, we introduce a new attribute
163
- # 'yearOfBirth' and make 'age' a derived attribute. We also say that a person can
164
- # have at most 5 houses in our metamodel.
165
- #
166
- # ==Derived attributes and references
167
- #
168
- # If the attribute 'derived' of an attribute or reference is set to true, a method +attributeName_derived+
169
- # has to be provided. This method is called whenever the original attribute is accessed. The
170
- # original attribute can not be written if it is derived.
171
- #
172
- #
173
- module MetamodelBuilder
174
-
175
- # Use this class as a start for new metamodel elements (i.e. Ruby classes)
176
- # by inheriting for it.
177
- #
178
- # See MetamodelBuilder for an example.
179
- class MMBase
180
- include BuilderRuntime
181
- include DataTypes
182
- extend BuilderExtensions
183
- extend ModuleExtension
184
- extend RGen::ECore::ECoreInstantiator
185
-
186
- def initialize(arg=nil)
187
- arg.each_pair { |k,v| setGeneric(k, v) } if arg.is_a?(Hash)
188
- end
189
- def self.method_added(m)
190
- raise "Do not add methods to model classes directly, add them to the ClassModule instead"
191
- end
192
- end
193
-
194
- end
195
-
196
- end