rgen 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,50 @@
1
+ $:.unshift File.join(File.dirname(__FILE__),"..","lib")
2
+
3
+ require 'test/unit'
4
+ require 'rgen/metamodel_builder'
5
+ require 'rgen/instantiator/reference_resolver'
6
+
7
+ class ReferenceResolverTest < Test::Unit::TestCase
8
+
9
+ class TestNode < RGen::MetamodelBuilder::MMBase
10
+ has_attr 'name', String
11
+ has_one 'other', TestNode
12
+ has_many 'others', TestNode
13
+ end
14
+
15
+ class TestResolver
16
+ include RGen::Instantiator::ReferenceResolver
17
+ def initialize(nodeA, nodeB, nodeC)
18
+ @nodeA, @nodeB, @nodeC = nodeA, nodeB, nodeC
19
+ end
20
+ def resolveIdentifier(ident)
21
+ {:a => @nodeA, :b => @nodeB, :c => @nodeC}[ident]
22
+ end
23
+ end
24
+
25
+ def test_simple
26
+ nodeA = TestNode.new(:name => "NodeA")
27
+ nodeB = TestNode.new(:name => "NodeB")
28
+ nodeC = TestNode.new(:name => "NodeC")
29
+ bProxy = RGen::MetamodelBuilder::MMProxy.new(:b)
30
+ nodeA.other = bProxy
31
+ aProxy = RGen::MetamodelBuilder::MMProxy.new(:a)
32
+ cProxy = RGen::MetamodelBuilder::MMProxy.new(:c)
33
+ nodeB.others = [aProxy, cProxy]
34
+ unresolvedReferences = [
35
+ RGen::Instantiator::ReferenceResolver::UnresolvedReference.new(nodeA, "other", bProxy),
36
+ RGen::Instantiator::ReferenceResolver::UnresolvedReference.new(nodeB, "others", aProxy),
37
+ RGen::Instantiator::ReferenceResolver::UnresolvedReference.new(nodeB, "others", cProxy)
38
+ ]
39
+ resolver = TestResolver.new(nodeA, nodeB, nodeC)
40
+ resolver.resolveReferences(unresolvedReferences)
41
+ assert_equal nodeB, nodeA.other
42
+ assert_equal [], nodeA.others
43
+ assert_equal nil, nodeB.other
44
+ assert_equal [nodeA, nodeC], nodeB.others
45
+ assert_equal nil, nodeC.other
46
+ assert_equal [], nodeC.others
47
+ end
48
+
49
+ end
50
+
@@ -15,3 +15,7 @@ require 'xml_instantiator_test'
15
15
  require 'ea_serializer_test'
16
16
  require 'model_builder_test'
17
17
  require 'method_delegation_test'
18
+ require 'json_test'
19
+ require 'reference_resolver_test'
20
+ require 'qualified_name_resolver_test'
21
+
metadata CHANGED
@@ -1,12 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgen
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 5
8
- - 1
9
- version: 0.5.1
4
+ version: 0.5.2
10
5
  platform: ruby
11
6
  authors:
12
7
  - Martin Thiede
@@ -14,7 +9,7 @@ autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
11
 
17
- date: 2009-11-10 00:00:00 +01:00
12
+ date: 2010-06-13 00:00:00 +02:00
18
13
  default_executable:
19
14
  dependencies: []
20
15
 
@@ -55,7 +50,12 @@ files:
55
50
  - lib/rgen/instantiator/abstract_xml_instantiator.rb
56
51
  - lib/rgen/instantiator/default_xml_instantiator.rb
57
52
  - lib/rgen/instantiator/ecore_xml_instantiator.rb
53
+ - lib/rgen/instantiator/json_instantiator.rb
54
+ - lib/rgen/instantiator/json_parser.rb
55
+ - lib/rgen/instantiator/json_parser.y
58
56
  - lib/rgen/instantiator/nodebased_xml_instantiator.rb
57
+ - lib/rgen/instantiator/qualified_name_resolver.rb
58
+ - lib/rgen/instantiator/reference_resolver.rb
59
59
  - lib/rgen/instantiator/xmi11_instantiator.rb
60
60
  - lib/rgen/metamodel_builder/builder_extensions.rb
61
61
  - lib/rgen/metamodel_builder/builder_runtime.rb
@@ -74,6 +74,7 @@ files:
74
74
  - lib/rgen/model_comparator_base.rb
75
75
  - lib/rgen/model_dumper.rb
76
76
  - lib/rgen/name_helper.rb
77
+ - lib/rgen/serializer/json_serializer.rb
77
78
  - lib/rgen/serializer/xmi11_serializer.rb
78
79
  - lib/rgen/serializer/xmi20_serializer.rb
79
80
  - lib/rgen/serializer/xml_serializer.rb
@@ -90,12 +91,15 @@ files:
90
91
  - test/ea_serializer_test.rb
91
92
  - test/ecore_self_test.rb
92
93
  - test/environment_test.rb
94
+ - test/json_test.rb
93
95
  - test/metamodel_builder_test.rb
94
96
  - test/metamodel_roundtrip_test/houseMetamodel.ecore
95
97
  - test/metamodel_roundtrip_test/houseMetamodel_from_ecore.rb
96
98
  - test/metamodel_roundtrip_test/houseMetamodel_Regenerated.ecore
97
99
  - test/metamodel_roundtrip_test/TestModel.rb
98
100
  - test/metamodel_roundtrip_test/TestModel_Regenerated.rb
101
+ - test/metamodel_roundtrip_test/using_builtin_types.ecore
102
+ - test/metamodel_roundtrip_test/using_builtin_types_serialized.ecore
99
103
  - test/metamodel_roundtrip_test.rb
100
104
  - test/method_delegation_test.rb
101
105
  - test/model_builder/builder_context_test.rb
@@ -109,6 +113,8 @@ files:
109
113
  - test/model_builder/test_model/statemachine1.rb
110
114
  - test/model_builder_test.rb
111
115
  - test/output_handler_test.rb
116
+ - test/qualified_name_resolver_test.rb
117
+ - test/reference_resolver_test.rb
112
118
  - test/rgen_test.rb
113
119
  - test/template_language_test/expected_result1.txt
114
120
  - test/template_language_test/expected_result2.txt
@@ -228,25 +234,21 @@ rdoc_options:
228
234
  require_paths:
229
235
  - lib
230
236
  required_ruby_version: !ruby/object:Gem::Requirement
231
- none: false
232
237
  requirements:
233
238
  - - ">="
234
239
  - !ruby/object:Gem::Version
235
- segments:
236
- - 0
237
240
  version: "0"
241
+ version:
238
242
  required_rubygems_version: !ruby/object:Gem::Requirement
239
- none: false
240
243
  requirements:
241
244
  - - ">="
242
245
  - !ruby/object:Gem::Version
243
- segments:
244
- - 0
245
246
  version: "0"
247
+ version:
246
248
  requirements: []
247
249
 
248
250
  rubyforge_project: rgen
249
- rubygems_version: 1.3.7
251
+ rubygems_version: 1.3.5
250
252
  signing_key:
251
253
  specification_version: 3
252
254
  summary: Ruby Modelling and Generator Framework