rgen 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/CHANGELOG +7 -0
  2. data/lib/rgen/metamodel_builder.rb +5 -4
  3. data/lib/rgen/metamodel_builder.rb.bak +196 -0
  4. data/lib/rgen/metamodel_builder/builder_extensions.rb +51 -38
  5. data/lib/rgen/metamodel_builder/builder_extensions.rb.bak +437 -0
  6. data/lib/rgen/metamodel_builder/builder_runtime.rb +2 -20
  7. data/lib/rgen/metamodel_builder/builder_runtime.rb.bak +73 -0
  8. data/lib/rgen/name_helper.rb.bak +37 -0
  9. data/lib/rgen/template_language.rb +8 -0
  10. data/lib/rgen/template_language.rb.bak +289 -0
  11. data/lib/rgen/template_language/directory_template_container.rb +11 -0
  12. data/lib/rgen/template_language/directory_template_container.rb.bak +69 -0
  13. data/lib/rgen/template_language/output_handler.rb +3 -2
  14. data/lib/rgen/template_language/output_handler.rb.bak +88 -0
  15. data/lib/rgen/template_language/template_container.rb +5 -4
  16. data/lib/rgen/template_language/template_container.rb.bak +196 -0
  17. data/lib/rgen/transformer.rb.bak +381 -0
  18. data/test/environment_test.rb.bak +52 -0
  19. data/test/metamodel_builder_test.rb +6 -0
  20. data/test/metamodel_builder_test.rb.bak +443 -0
  21. data/test/metamodel_roundtrip_test/TestModel_Regenerated.rb +34 -32
  22. data/test/metamodel_roundtrip_test/houseMetamodel_Regenerated.ecore +58 -58
  23. data/test/output_handler_test.rb +8 -0
  24. data/test/output_handler_test.rb.bak +50 -0
  25. data/test/template_language_test.rb +23 -0
  26. data/test/template_language_test.rb.bak +72 -0
  27. data/test/template_language_test/indentStringTestDefaultIndent.out +1 -0
  28. data/test/template_language_test/indentStringTestTabIndent.out +1 -0
  29. data/test/template_language_test/templates/indent_string_test.tpl +12 -0
  30. data/test/template_language_test/templates/null_context_test.tpl +12 -0
  31. data/test/transformer_test.rb.bak +223 -0
  32. metadata +65 -48
  33. data/lib/rgen/environment.rb.bak +0 -42
@@ -6,52 +6,54 @@ module HouseMetamodel
6
6
 
7
7
  SexEnum = Enum.new(:name => 'SexEnum', :literals =>[ :male, :female ])
8
8
 
9
- module Rooms
10
- extend RGen::MetamodelBuilder::ModuleExtension
11
- include RGen::MetamodelBuilder::DataTypes
9
+ class MeetingPlace < RGen::MetamodelBuilder::MMBase
10
+ annotation :source => "testmodel", :details => {'complexity' => '1', 'date_created' => '2006-07-12 08:40:46', 'date_modified' => '2006-07-12 08:44:02', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_A1B83D59_CAE1_422c_BA5F_D3624D7156AD', 'package_name' => 'HouseMetamodel', 'phase' => '1.0', 'status' => 'Proposed', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'}
11
+ end
12
12
 
13
+ class House < RGen::MetamodelBuilder::MMBase
14
+ annotation 'complexity' => '1', 'date_created' => '2005-09-16 19:52:18', 'date_modified' => '2006-02-28 08:29:19', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_A1B83D59_CAE1_422c_BA5F_D3624D7156AD', 'package_name' => 'HouseMetamodel', 'phase' => '1.0', 'status' => 'Proposed', 'stereotype' => 'dummy', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'
15
+ has_attr 'size', Integer
16
+ has_attr 'module', String
17
+ has_attr 'address', String, :changeable => false do
18
+ annotation 'collection' => 'false', 'containment' => 'Not Specified', 'derived' => '0', 'duplicates' => '0', 'ea_guid' => '{A8DF581B-9AC6-4f75-AB48-8FAEDFC6E068}', 'lowerBound' => '1', 'ordered' => '0', 'position' => '0', 'styleex' => 'volatile=0;', 'type' => 'String', 'upperBound' => '1'
19
+ end
13
20
  end
14
21
 
15
- module DependingOnRooms
22
+ class Person < RGen::MetamodelBuilder::MMBase
23
+ annotation 'complexity' => '1', 'date_created' => '2006-06-27 08:34:23', 'date_modified' => '2006-06-27 08:34:26', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_A1B83D59_CAE1_422c_BA5F_D3624D7156AD', 'package_name' => 'HouseMetamodel', 'phase' => '1.0', 'status' => 'Proposed', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'
24
+ has_attr 'sex', HouseMetamodel::SexEnum
25
+ end
26
+
27
+
28
+ module Rooms
16
29
  extend RGen::MetamodelBuilder::ModuleExtension
17
30
  include RGen::MetamodelBuilder::DataTypes
18
31
 
19
- end
20
- end
21
32
 
22
- class HouseMetamodel::House < RGen::MetamodelBuilder::MMBase
23
- annotation 'complexity' => '1', 'date_created' => '2005-09-16 19:52:18', 'date_modified' => '2006-02-28 08:29:19', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_A1B83D59_CAE1_422c_BA5F_D3624D7156AD', 'package_name' => 'HouseMetamodel', 'phase' => '1.0', 'status' => 'Proposed', 'stereotype' => 'dummy', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'
24
- has_attr 'size', Integer
25
- has_attr 'module', String
26
- has_attr 'address', String, :changeable => false do
27
- annotation 'collection' => 'false', 'containment' => 'Not Specified', 'derived' => '0', 'duplicates' => '0', 'ea_guid' => '{A8DF581B-9AC6-4f75-AB48-8FAEDFC6E068}', 'lowerBound' => '1', 'ordered' => '0', 'position' => '0', 'styleex' => 'volatile=0;', 'type' => 'String', 'upperBound' => '1'
28
- end
29
- end
33
+ class Room < RGen::MetamodelBuilder::MMBase
34
+ annotation 'complexity' => '1', 'date_created' => '2005-09-16 19:52:28', 'date_modified' => '2006-06-22 21:15:25', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_F9D8C6E3_4DAD_4aa2_AD47_D0ABA4E93E08', 'package_name' => 'Rooms', 'phase' => '1.0', 'status' => 'Proposed', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'
35
+ end
30
36
 
31
- class HouseMetamodel::Person < RGen::MetamodelBuilder::MMBase
32
- annotation 'complexity' => '1', 'date_created' => '2006-06-27 08:34:23', 'date_modified' => '2006-06-27 08:34:26', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_A1B83D59_CAE1_422c_BA5F_D3624D7156AD', 'package_name' => 'HouseMetamodel', 'phase' => '1.0', 'status' => 'Proposed', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'
33
- has_attr 'sex', HouseMetamodel::SexEnum
34
- end
37
+ class Kitchen < RGen::MetamodelBuilder::MMMultiple(HouseMetamodel::MeetingPlace, Room)
38
+ annotation 'complexity' => '1', 'date_created' => '2005-11-30 19:26:13', 'date_modified' => '2006-06-22 21:15:34', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_F9D8C6E3_4DAD_4aa2_AD47_D0ABA4E93E08', 'package_name' => 'Rooms', 'phase' => '1.0', 'status' => 'Proposed', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'
39
+ end
35
40
 
36
- class HouseMetamodel::MeetingPlace < RGen::MetamodelBuilder::MMBase
37
- annotation :source => "testmodel", :details => {'complexity' => '1', 'date_created' => '2006-07-12 08:40:46', 'date_modified' => '2006-07-12 08:44:02', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_A1B83D59_CAE1_422c_BA5F_D3624D7156AD', 'package_name' => 'HouseMetamodel', 'phase' => '1.0', 'status' => 'Proposed', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'}
38
- end
41
+ class Bathroom < Room
42
+ annotation 'complexity' => '1', 'date_created' => '2006-06-27 08:32:25', 'date_modified' => '2006-06-27 08:34:23', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_F9D8C6E3_4DAD_4aa2_AD47_D0ABA4E93E08', 'package_name' => 'Rooms', 'phase' => '1.0', 'status' => 'Proposed', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'
43
+ end
39
44
 
40
- class HouseMetamodel::Rooms::Room < RGen::MetamodelBuilder::MMBase
41
- annotation 'complexity' => '1', 'date_created' => '2005-09-16 19:52:28', 'date_modified' => '2006-06-22 21:15:25', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_F9D8C6E3_4DAD_4aa2_AD47_D0ABA4E93E08', 'package_name' => 'Rooms', 'phase' => '1.0', 'status' => 'Proposed', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'
42
- end
45
+ end
43
46
 
44
- class HouseMetamodel::Rooms::Bathroom < HouseMetamodel::Rooms::Room
45
- annotation 'complexity' => '1', 'date_created' => '2006-06-27 08:32:25', 'date_modified' => '2006-06-27 08:34:23', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_F9D8C6E3_4DAD_4aa2_AD47_D0ABA4E93E08', 'package_name' => 'Rooms', 'phase' => '1.0', 'status' => 'Proposed', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'
46
- end
47
+ module DependingOnRooms
48
+ extend RGen::MetamodelBuilder::ModuleExtension
49
+ include RGen::MetamodelBuilder::DataTypes
47
50
 
48
- class HouseMetamodel::Rooms::Kitchen < RGen::MetamodelBuilder::MMMultiple(HouseMetamodel::MeetingPlace, HouseMetamodel::Rooms::Room)
49
- annotation 'complexity' => '1', 'date_created' => '2005-11-30 19:26:13', 'date_modified' => '2006-06-22 21:15:34', 'ea_ntype' => '0', 'ea_stype' => 'Class', 'gentype' => 'Java', 'isSpecification' => 'false', 'package' => 'EAPK_F9D8C6E3_4DAD_4aa2_AD47_D0ABA4E93E08', 'package_name' => 'Rooms', 'phase' => '1.0', 'status' => 'Proposed', 'style' => 'BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;', 'tagged' => '0', 'version' => '1.0'
50
- end
51
51
 
52
- class HouseMetamodel::DependingOnRooms::RoomSub < HouseMetamodel::Rooms::Room
53
- end
52
+ class RoomSub < HouseMetamodel::Rooms::Room
53
+ end
54
54
 
55
+ end
56
+ end
55
57
 
56
58
  HouseMetamodel::House.has_one 'bathroom', HouseMetamodel::Rooms::Bathroom, :transient => true, :lowerBound => 1
57
59
  HouseMetamodel::House.one_to_one 'kitchen', HouseMetamodel::Rooms::Kitchen, 'house', :lowerBound => 1, :opposite_lowerBound => 1 do
@@ -1,4 +1,42 @@
1
1
  <ecore:EPackage xmi:version="2.0" name="HouseMetamodel" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
2
+ <eClassifiers name="SexEnum" instanceClassName="HouseMetamodel::SexEnum" ePackage="#/" xsi:type="ecore:EEnum">
3
+ <eLiterals name="male" xsi:type="ecore:EEnumLiteral" eEnum="#//SexEnum">
4
+ </eLiterals>
5
+ <eLiterals name="female" xsi:type="ecore:EEnumLiteral" eEnum="#//SexEnum">
6
+ </eLiterals>
7
+ </eClassifiers>
8
+ <eClassifiers name="MeetingPlace" abstract="false" instanceClassName="HouseMetamodel::MeetingPlace" interface="false" ePackage="#/" xsi:type="ecore:EClass">
9
+ <eAnnotations eModelElement="#//MeetingPlace" xsi:type="ecore:EAnnotation" source="testmodel">
10
+ <details xsi:type="ecore:EStringToStringMapEntry" value="Proposed" key="status">
11
+ </details>
12
+ <details xsi:type="ecore:EStringToStringMapEntry" value="2006-07-12 08:40:46" key="date_created">
13
+ </details>
14
+ <details xsi:type="ecore:EStringToStringMapEntry" value="Class" key="ea_stype">
15
+ </details>
16
+ <details xsi:type="ecore:EStringToStringMapEntry" value="2006-07-12 08:44:02" key="date_modified">
17
+ </details>
18
+ <details xsi:type="ecore:EStringToStringMapEntry" value="0" key="tagged">
19
+ </details>
20
+ <details xsi:type="ecore:EStringToStringMapEntry" value="0" key="ea_ntype">
21
+ </details>
22
+ <details xsi:type="ecore:EStringToStringMapEntry" value="1.0" key="version">
23
+ </details>
24
+ <details xsi:type="ecore:EStringToStringMapEntry" value="EAPK_A1B83D59_CAE1_422c_BA5F_D3624D7156AD" key="package">
25
+ </details>
26
+ <details xsi:type="ecore:EStringToStringMapEntry" value="false" key="isSpecification">
27
+ </details>
28
+ <details xsi:type="ecore:EStringToStringMapEntry" value="HouseMetamodel" key="package_name">
29
+ </details>
30
+ <details xsi:type="ecore:EStringToStringMapEntry" value="1" key="complexity">
31
+ </details>
32
+ <details xsi:type="ecore:EStringToStringMapEntry" value="1.0" key="phase">
33
+ </details>
34
+ <details xsi:type="ecore:EStringToStringMapEntry" value="BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;" key="style">
35
+ </details>
36
+ <details xsi:type="ecore:EStringToStringMapEntry" value="Java" key="gentype">
37
+ </details>
38
+ </eAnnotations>
39
+ </eClassifiers>
2
40
  <eClassifiers name="House" abstract="false" instanceClassName="HouseMetamodel::House" interface="false" ePackage="#/" xsi:type="ecore:EClass">
3
41
  <eStructuralFeatures name="size" derived="false" transient="false" changeable="true" eContainingClass="#//House" unsettable="false" iD="false" xsi:type="ecore:EAttribute" upperBound="1" ordered="true" volatile="false" lowerBound="0" unique="true">
4
42
  </eStructuralFeatures>
@@ -113,54 +151,22 @@
113
151
  </details>
114
152
  </eAnnotations>
115
153
  </eClassifiers>
116
- <eClassifiers name="SexEnum" instanceClassName="HouseMetamodel::SexEnum" ePackage="#/" xsi:type="ecore:EEnum">
117
- <eLiterals name="male" xsi:type="ecore:EEnumLiteral" eEnum="#//SexEnum">
118
- </eLiterals>
119
- <eLiterals name="female" xsi:type="ecore:EEnumLiteral" eEnum="#//SexEnum">
120
- </eLiterals>
121
- </eClassifiers>
122
- <eClassifiers name="MeetingPlace" abstract="false" instanceClassName="HouseMetamodel::MeetingPlace" interface="false" ePackage="#/" xsi:type="ecore:EClass">
123
- <eAnnotations eModelElement="#//MeetingPlace" xsi:type="ecore:EAnnotation" source="testmodel">
124
- <details xsi:type="ecore:EStringToStringMapEntry" value="Proposed" key="status">
125
- </details>
126
- <details xsi:type="ecore:EStringToStringMapEntry" value="2006-07-12 08:40:46" key="date_created">
127
- </details>
128
- <details xsi:type="ecore:EStringToStringMapEntry" value="Class" key="ea_stype">
129
- </details>
130
- <details xsi:type="ecore:EStringToStringMapEntry" value="2006-07-12 08:44:02" key="date_modified">
131
- </details>
132
- <details xsi:type="ecore:EStringToStringMapEntry" value="0" key="tagged">
133
- </details>
134
- <details xsi:type="ecore:EStringToStringMapEntry" value="0" key="ea_ntype">
135
- </details>
136
- <details xsi:type="ecore:EStringToStringMapEntry" value="1.0" key="version">
137
- </details>
138
- <details xsi:type="ecore:EStringToStringMapEntry" value="EAPK_A1B83D59_CAE1_422c_BA5F_D3624D7156AD" key="package">
139
- </details>
140
- <details xsi:type="ecore:EStringToStringMapEntry" value="false" key="isSpecification">
141
- </details>
142
- <details xsi:type="ecore:EStringToStringMapEntry" value="HouseMetamodel" key="package_name">
143
- </details>
144
- <details xsi:type="ecore:EStringToStringMapEntry" value="1" key="complexity">
145
- </details>
146
- <details xsi:type="ecore:EStringToStringMapEntry" value="1.0" key="phase">
147
- </details>
148
- <details xsi:type="ecore:EStringToStringMapEntry" value="BackColor=-1;BorderColor=-1;BorderWidth=-1;FontColor=-1;VSwimLanes=0;HSwimLanes=0;BorderStyle=0;" key="style">
149
- </details>
150
- <details xsi:type="ecore:EStringToStringMapEntry" value="Java" key="gentype">
151
- </details>
152
- </eAnnotations>
153
- </eClassifiers>
154
154
  <eSubpackages name="Rooms" xsi:type="ecore:EPackage" eSuperPackage="#/">
155
- <eClassifiers name="Bathroom" abstract="false" instanceClassName="HouseMetamodel::Rooms::Bathroom" interface="false" ePackage="#//Rooms" xsi:type="ecore:EClass" eSuperTypes="#//Rooms/Room">
156
- <eAnnotations eModelElement="#//Rooms/Bathroom" xsi:type="ecore:EAnnotation">
155
+ <eClassifiers name="Room" abstract="false" instanceClassName="HouseMetamodel::Rooms::Room" interface="false" ePackage="#//Rooms" xsi:type="ecore:EClass">
156
+ <eStructuralFeatures name="house" derived="false" containment="false" transient="false" changeable="true" resolveProxies="true" eContainingClass="#//Rooms/Room" eOpposite="#//House/room" unsettable="false" xsi:type="ecore:EReference" upperBound="1" ordered="true" volatile="false" lowerBound="0" eType="#//House" unique="true">
157
+ <eAnnotations eModelElement="#//Rooms/Room/house" xsi:type="ecore:EAnnotation">
158
+ <details xsi:type="ecore:EStringToStringMapEntry" value="Unspecified" key="containment">
159
+ </details>
160
+ </eAnnotations>
161
+ </eStructuralFeatures>
162
+ <eAnnotations eModelElement="#//Rooms/Room" xsi:type="ecore:EAnnotation">
157
163
  <details xsi:type="ecore:EStringToStringMapEntry" value="Proposed" key="status">
158
164
  </details>
159
- <details xsi:type="ecore:EStringToStringMapEntry" value="2006-06-27 08:32:25" key="date_created">
165
+ <details xsi:type="ecore:EStringToStringMapEntry" value="2005-09-16 19:52:28" key="date_created">
160
166
  </details>
161
167
  <details xsi:type="ecore:EStringToStringMapEntry" value="Class" key="ea_stype">
162
168
  </details>
163
- <details xsi:type="ecore:EStringToStringMapEntry" value="2006-06-27 08:34:23" key="date_modified">
169
+ <details xsi:type="ecore:EStringToStringMapEntry" value="2006-06-22 21:15:25" key="date_modified">
164
170
  </details>
165
171
  <details xsi:type="ecore:EStringToStringMapEntry" value="0" key="tagged">
166
172
  </details>
@@ -184,21 +190,21 @@
184
190
  </details>
185
191
  </eAnnotations>
186
192
  </eClassifiers>
187
- <eClassifiers name="Room" abstract="false" instanceClassName="HouseMetamodel::Rooms::Room" interface="false" ePackage="#//Rooms" xsi:type="ecore:EClass">
188
- <eStructuralFeatures name="house" derived="false" containment="false" transient="false" changeable="true" resolveProxies="true" eContainingClass="#//Rooms/Room" eOpposite="#//House/room" unsettable="false" xsi:type="ecore:EReference" upperBound="1" ordered="true" volatile="false" lowerBound="0" eType="#//House" unique="true">
189
- <eAnnotations eModelElement="#//Rooms/Room/house" xsi:type="ecore:EAnnotation">
193
+ <eClassifiers name="Kitchen" abstract="false" instanceClassName="HouseMetamodel::Rooms::Kitchen" interface="false" ePackage="#//Rooms" xsi:type="ecore:EClass" eSuperTypes="#//MeetingPlace #//Rooms/Room">
194
+ <eStructuralFeatures name="house" derived="false" containment="false" transient="false" changeable="true" resolveProxies="true" eContainingClass="#//Rooms/Kitchen" eOpposite="#//House/kitchen" unsettable="false" xsi:type="ecore:EReference" upperBound="1" ordered="true" volatile="false" lowerBound="1" eType="#//House" unique="true">
195
+ <eAnnotations eModelElement="#//Rooms/Kitchen/house" xsi:type="ecore:EAnnotation">
190
196
  <details xsi:type="ecore:EStringToStringMapEntry" value="Unspecified" key="containment">
191
197
  </details>
192
198
  </eAnnotations>
193
199
  </eStructuralFeatures>
194
- <eAnnotations eModelElement="#//Rooms/Room" xsi:type="ecore:EAnnotation">
200
+ <eAnnotations eModelElement="#//Rooms/Kitchen" xsi:type="ecore:EAnnotation">
195
201
  <details xsi:type="ecore:EStringToStringMapEntry" value="Proposed" key="status">
196
202
  </details>
197
- <details xsi:type="ecore:EStringToStringMapEntry" value="2005-09-16 19:52:28" key="date_created">
203
+ <details xsi:type="ecore:EStringToStringMapEntry" value="2005-11-30 19:26:13" key="date_created">
198
204
  </details>
199
205
  <details xsi:type="ecore:EStringToStringMapEntry" value="Class" key="ea_stype">
200
206
  </details>
201
- <details xsi:type="ecore:EStringToStringMapEntry" value="2006-06-22 21:15:25" key="date_modified">
207
+ <details xsi:type="ecore:EStringToStringMapEntry" value="2006-06-22 21:15:34" key="date_modified">
202
208
  </details>
203
209
  <details xsi:type="ecore:EStringToStringMapEntry" value="0" key="tagged">
204
210
  </details>
@@ -222,21 +228,15 @@
222
228
  </details>
223
229
  </eAnnotations>
224
230
  </eClassifiers>
225
- <eClassifiers name="Kitchen" abstract="false" instanceClassName="HouseMetamodel::Rooms::Kitchen" interface="false" ePackage="#//Rooms" xsi:type="ecore:EClass" eSuperTypes="#//MeetingPlace #//Rooms/Room">
226
- <eStructuralFeatures name="house" derived="false" containment="false" transient="false" changeable="true" resolveProxies="true" eContainingClass="#//Rooms/Kitchen" eOpposite="#//House/kitchen" unsettable="false" xsi:type="ecore:EReference" upperBound="1" ordered="true" volatile="false" lowerBound="1" eType="#//House" unique="true">
227
- <eAnnotations eModelElement="#//Rooms/Kitchen/house" xsi:type="ecore:EAnnotation">
228
- <details xsi:type="ecore:EStringToStringMapEntry" value="Unspecified" key="containment">
229
- </details>
230
- </eAnnotations>
231
- </eStructuralFeatures>
232
- <eAnnotations eModelElement="#//Rooms/Kitchen" xsi:type="ecore:EAnnotation">
231
+ <eClassifiers name="Bathroom" abstract="false" instanceClassName="HouseMetamodel::Rooms::Bathroom" interface="false" ePackage="#//Rooms" xsi:type="ecore:EClass" eSuperTypes="#//Rooms/Room">
232
+ <eAnnotations eModelElement="#//Rooms/Bathroom" xsi:type="ecore:EAnnotation">
233
233
  <details xsi:type="ecore:EStringToStringMapEntry" value="Proposed" key="status">
234
234
  </details>
235
- <details xsi:type="ecore:EStringToStringMapEntry" value="2005-11-30 19:26:13" key="date_created">
235
+ <details xsi:type="ecore:EStringToStringMapEntry" value="2006-06-27 08:32:25" key="date_created">
236
236
  </details>
237
237
  <details xsi:type="ecore:EStringToStringMapEntry" value="Class" key="ea_stype">
238
238
  </details>
239
- <details xsi:type="ecore:EStringToStringMapEntry" value="2006-06-22 21:15:34" key="date_modified">
239
+ <details xsi:type="ecore:EStringToStringMapEntry" value="2006-06-27 08:34:23" key="date_modified">
240
240
  </details>
241
241
  <details xsi:type="ecore:EStringToStringMapEntry" value="0" key="tagged">
242
242
  </details>
@@ -47,4 +47,12 @@ class MetamodelBuilderTest < Test::Unit::TestCase
47
47
  h << line
48
48
  end
49
49
  end
50
+ def test_indent_string
51
+ h = RGen::TemplateLanguage::OutputHandler.new(1, "\t", :explicit)
52
+ h << "Start"
53
+ h << " \n "
54
+ h << "Test"
55
+ h << " \n \n Content"
56
+ assert_equal "\tStart\n\tTest\n\tContent", h.to_s
57
+ end
50
58
  end
@@ -0,0 +1,50 @@
1
+ $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
+
3
+ require 'test/unit'
4
+ require 'rgen/template_language/output_handler'
5
+
6
+ class MetamodelBuilderTest < Test::Unit::TestCase
7
+ def test_direct_nl
8
+ h = RGen::TemplateLanguage::OutputHandler.new
9
+ h.mode = :direct
10
+ h << "Test"
11
+ h.ignoreNextNL
12
+ h << "\nContent"
13
+ assert_equal "TestContent", h.to_s
14
+ end
15
+ def test_direct_ws
16
+ h = RGen::TemplateLanguage::OutputHandler.new
17
+ h.mode = :direct
18
+ h << "Test"
19
+ h.ignoreNextWS
20
+ h << " \n Content"
21
+ assert_equal "TestContent", h.to_s
22
+ end
23
+ def test_explicit_indent
24
+ h = RGen::TemplateLanguage::OutputHandler.new
25
+ h.mode = :explicit
26
+ h.indent = 1
27
+ h << "Start"
28
+ h << " \n "
29
+ h << "Test"
30
+ h << " \n \n Content"
31
+ assert_equal " Start\n Test\n Content", h.to_s
32
+ end
33
+ def test_explicit_endswithws
34
+ h = RGen::TemplateLanguage::OutputHandler.new
35
+ h.mode = :explicit
36
+ h.indent = 1
37
+ h << "Start \n\n"
38
+ assert_equal " Start\n", h.to_s
39
+ end
40
+ def test_performance
41
+ h = RGen::TemplateLanguage::OutputHandler.new
42
+ h.mode = :explicit
43
+ h.indent = 1
44
+ line = (1..50).collect{|w| "someword"}.join(" ")+"\n"
45
+ # repeat more often to make performance differences visible
46
+ 20.times do
47
+ h << line
48
+ end
49
+ end
50
+ end
@@ -69,4 +69,27 @@ class TemplateContainerTest < Test::Unit::TestCase
69
69
  assert_equal expected, result
70
70
  end
71
71
 
72
+ def test_indent_string
73
+ tc = RGen::TemplateLanguage::DirectoryTemplateContainer.new([MyMM, CCodeMM], OUTPUT_DIR)
74
+ tc.load(TEMPLATES_DIR)
75
+ tc.indentString = " " # 2 spaces instead of 3 (default)
76
+ tc.expand('indent_string_test::IndentStringTest', :for => :dummy)
77
+ File.open(OUTPUT_DIR+"/indentStringTestDefaultIndent.out") do |f|
78
+ assert_equal " <- your default here\n", f.read
79
+ end
80
+ File.open(OUTPUT_DIR+"/indentStringTestTabIndent.out") do |f|
81
+ assert_equal "\t<- tab\n", f.read
82
+ end
83
+ end
84
+
85
+ def test_null_context
86
+ tc = RGen::TemplateLanguage::DirectoryTemplateContainer.new([MyMM, CCodeMM], OUTPUT_DIR)
87
+ tc.load(TEMPLATES_DIR)
88
+ assert_raise StandardError do
89
+ tc.expand('null_context_test::NullContextTestBad', :for => :dummy)
90
+ end
91
+ assert_nothing_raised do
92
+ tc.expand('null_context_test::NullContextTestOk', :for => :dummy)
93
+ end
94
+ end
72
95
  end
@@ -0,0 +1,72 @@
1
+ $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
+
3
+ require 'test/unit'
4
+ require 'rgen/template_language'
5
+ require 'rgen/metamodel_builder'
6
+
7
+ class TemplateContainerTest < Test::Unit::TestCase
8
+
9
+ TEMPLATES_DIR = File.dirname(__FILE__)+"/template_language_test/templates"
10
+ OUTPUT_DIR = File.dirname(__FILE__)+"/template_language_test"
11
+
12
+ module MyMM
13
+
14
+ class Chapter
15
+ attr_reader :title
16
+ def initialize(title)
17
+ @title = title
18
+ end
19
+ end
20
+
21
+ class Document
22
+ attr_reader :title, :authors, :chapters
23
+ attr_accessor :sampleArray
24
+ def initialize(title)
25
+ @title = title
26
+ @chapters = []
27
+ @authors = []
28
+ end
29
+ end
30
+
31
+ class Author
32
+ attr_reader :name, :email
33
+ def initialize(name, email)
34
+ @name, @email = name, email
35
+ end
36
+ end
37
+
38
+ end
39
+
40
+ module CCodeMM
41
+ class CArray < RGen::MetamodelBuilder::MMBase
42
+ has_attr 'name'
43
+ has_attr 'size', Integer
44
+ has_attr 'type'
45
+ end
46
+ class PrimitiveInitValue < RGen::MetamodelBuilder::MMBase
47
+ has_attr 'value', Integer
48
+ end
49
+ CArray.has_many 'initvalue', PrimitiveInitValue
50
+ end
51
+
52
+ TEST_MODEL = MyMM::Document.new("SomeDocument")
53
+ TEST_MODEL.authors << MyMM::Author.new("Martin", "martin@somewhe.re")
54
+ TEST_MODEL.authors << MyMM::Author.new("Otherguy", "other@somewhereel.se")
55
+ TEST_MODEL.chapters << MyMM::Chapter.new("Intro")
56
+ TEST_MODEL.chapters << MyMM::Chapter.new("MainPart")
57
+ TEST_MODEL.chapters << MyMM::Chapter.new("Summary")
58
+ TEST_MODEL.sampleArray = CCodeMM::CArray.new(:name => "myArray", :type => "int", :size => 5,
59
+ :initvalue => (1..5).collect { |v| CCodeMM::PrimitiveInitValue.new(:value => v) })
60
+
61
+ def test_with_model
62
+ tc = RGen::TemplateLanguage::DirectoryTemplateContainer.new([MyMM, CCodeMM], OUTPUT_DIR)
63
+ tc.load(TEMPLATES_DIR)
64
+ File.delete(OUTPUT_DIR+"/testout.txt") if File.exists? OUTPUT_DIR+"/testout.txt"
65
+ tc.expand('root::Root', :for => TEST_MODEL, :indent => 1)
66
+ result = expected = ""
67
+ File.open(OUTPUT_DIR+"/testout.txt") {|f| result = f.read}
68
+ File.open(OUTPUT_DIR+"/expected_result.txt") {|f| expected = f.read}
69
+ assert_equal expected, result
70
+ end
71
+
72
+ end
@@ -0,0 +1 @@
1
+ <- your default here
@@ -0,0 +1,12 @@
1
+ <% define 'IndentStringTest', :for => Object do %>
2
+ <% file 'indentStringTestDefaultIndent.out' do %>
3
+ <%iinc%>
4
+ <- your default here
5
+ <%idec%>
6
+ <% end %>
7
+ <% file 'indentStringTestTabIndent.out', "\t" do %>
8
+ <%iinc%>
9
+ <- tab
10
+ <%idec%>
11
+ <% end %>
12
+ <% end %>
@@ -0,0 +1,12 @@
1
+ <% define 'NullContextTestBad', :for => Object do %>
2
+ <%# this must raise an exception %>
3
+ <% expand 'Callee', :for => nil %>
4
+ <% end %>
5
+
6
+ <% define 'NullContextTestOk', :for => Object do %>
7
+ <%# however this is ok %>
8
+ <% expand 'Callee' %>
9
+ <% end %>
10
+
11
+ <% define 'Callee', :for => Object do %>
12
+ <% end %>