rgen 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +10 -0
- data/README.rdoc +78 -0
- data/Rakefile +13 -17
- data/lib/rgen/fragment/model_fragment.rb +1 -0
- data/lib/rgen/metamodel_builder.rb +3 -0
- data/lib/rgen/metamodel_builder/builder_extensions.rb +41 -12
- data/lib/rgen/metamodel_builder/builder_runtime.rb +26 -0
- data/lib/rgen/util/file_cache_map.rb +18 -3
- data/lib/transformers/ecore_to_uml13.rb +16 -3
- data/test/metamodel_builder_test.rb +278 -3
- data/test/model_builder/ecore_internal.rb +8 -8
- data/test/model_fragment_test.rb +30 -0
- data/test/rgen_test.rb +1 -0
- data/test/testmodel/ea_testmodel_regenerated.xml +583 -583
- data/test/util/file_cache_map_test.rb +12 -4
- data/test/util/pattern_matcher_test.rb +97 -0
- data/test/util_test.rb +1 -0
- metadata +9 -7
- data/README +0 -76
@@ -16,7 +16,9 @@ class FileCacheMapTest < Test::Unit::TestCase
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_nocache
|
19
|
-
|
19
|
+
reasons = []
|
20
|
+
assert_equal(:invalid, @cm.load_data(TestDir+"/fileA", :invalidation_reasons => reasons))
|
21
|
+
assert_equal [:no_cachefile], reasons
|
20
22
|
end
|
21
23
|
|
22
24
|
def test_storeload
|
@@ -57,7 +59,9 @@ class FileCacheMapTest < Test::Unit::TestCase
|
|
57
59
|
File.open(keyFile, "w") {|f| f.write("somedata")}
|
58
60
|
@cm.store_data(keyFile, "valuedata")
|
59
61
|
File.open(TestDir+"/.cache/fileA.test","a") {|f| f.write("more data")}
|
60
|
-
|
62
|
+
reasons = []
|
63
|
+
assert_equal(:invalid, @cm.load_data(keyFile, :invalidation_reasons => reasons))
|
64
|
+
assert_equal [:cachefile_corrupted], reasons
|
61
65
|
end
|
62
66
|
|
63
67
|
def test_changedcontent
|
@@ -65,7 +69,9 @@ class FileCacheMapTest < Test::Unit::TestCase
|
|
65
69
|
File.open(keyFile, "w") {|f| f.write("somedata")}
|
66
70
|
@cm.store_data(keyFile, "valuedata")
|
67
71
|
File.open(keyFile, "a") {|f| f.write("more data")}
|
68
|
-
|
72
|
+
reasons = []
|
73
|
+
assert_equal(:invalid, @cm.load_data(keyFile, :invalidation_reasons => reasons))
|
74
|
+
assert_equal [:keyfile_changed], reasons
|
69
75
|
end
|
70
76
|
|
71
77
|
def test_versioninfo
|
@@ -83,7 +89,9 @@ class FileCacheMapTest < Test::Unit::TestCase
|
|
83
89
|
@cm.version_info = "123"
|
84
90
|
@cm.store_data(keyFile, "valuedata")
|
85
91
|
@cm.version_info = "456"
|
86
|
-
|
92
|
+
reasons = []
|
93
|
+
assert_equal(:invalid, @cm.load_data(keyFile, :invalidation_reasons => reasons))
|
94
|
+
assert_equal [:keyfile_changed], reasons
|
87
95
|
end
|
88
96
|
|
89
97
|
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)+"/../../lib")
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rgen/environment'
|
5
|
+
require 'rgen/metamodel_builder'
|
6
|
+
require 'rgen/model_builder'
|
7
|
+
require 'rgen/util/pattern_matcher'
|
8
|
+
|
9
|
+
class PatternMatcherTest < Test::Unit::TestCase
|
10
|
+
|
11
|
+
module TestMM
|
12
|
+
extend RGen::MetamodelBuilder::ModuleExtension
|
13
|
+
|
14
|
+
class Node < RGen::MetamodelBuilder::MMBase
|
15
|
+
has_attr 'name', String
|
16
|
+
contains_many 'children', Node, 'parent'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def modelA
|
21
|
+
env = RGen::Environment.new
|
22
|
+
RGen::ModelBuilder.build(TestMM, env) do
|
23
|
+
node "A" do
|
24
|
+
node "AA"
|
25
|
+
end
|
26
|
+
node "B" do
|
27
|
+
node "B1"
|
28
|
+
node "B2"
|
29
|
+
node "B3"
|
30
|
+
end
|
31
|
+
node "C" do
|
32
|
+
node "C1"
|
33
|
+
node "C2"
|
34
|
+
end
|
35
|
+
node "D" do
|
36
|
+
node "DD"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
env
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_simple
|
43
|
+
matcher = RGen::Util::PatternMatcher.new
|
44
|
+
matcher.add_pattern("simple") do |env, c|
|
45
|
+
TestMM::Node.new(:name => "A", :children => [
|
46
|
+
TestMM::Node.new(:name => "AA")])
|
47
|
+
end
|
48
|
+
matcher.add_pattern("bad") do |env, c|
|
49
|
+
TestMM::Node.new(:name => "X")
|
50
|
+
end
|
51
|
+
env = modelA
|
52
|
+
|
53
|
+
match = matcher.find_pattern(env, "simple")
|
54
|
+
assert_not_nil match
|
55
|
+
assert_equal "A", match.root.name
|
56
|
+
assert_equal env.find(:class => TestMM::Node, :name => "A").first.object_id, match.root.object_id
|
57
|
+
assert_equal 2, match.elements.size
|
58
|
+
assert_equal [nil], match.bound_values
|
59
|
+
|
60
|
+
assert_nil matcher.find_pattern(env, "bad")
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_value_binding
|
64
|
+
matcher = RGen::Util::PatternMatcher.new
|
65
|
+
matcher.add_pattern("single_child") do |env, name, child|
|
66
|
+
TestMM::Node.new(:name => name, :children => [ child ])
|
67
|
+
end
|
68
|
+
matcher.add_pattern("double_child") do |env, name, child1, child2|
|
69
|
+
TestMM::Node.new(:name => name, :children => [ child1, child2 ])
|
70
|
+
end
|
71
|
+
matcher.add_pattern("child_pattern") do |env, child_name|
|
72
|
+
TestMM::Node.new(:name => "A", :children => [
|
73
|
+
TestMM::Node.new(:name => child_name)])
|
74
|
+
end
|
75
|
+
env = modelA
|
76
|
+
|
77
|
+
match = matcher.find_pattern(env, "single_child")
|
78
|
+
assert_not_nil match
|
79
|
+
assert_equal "A", match.root.name
|
80
|
+
assert_equal "AA", match.bound_values[1].name
|
81
|
+
|
82
|
+
match = matcher.find_pattern(env, "single_child", "D")
|
83
|
+
assert_not_nil match
|
84
|
+
assert_equal "D", match.root.name
|
85
|
+
assert_equal "DD", match.bound_values[0].name
|
86
|
+
|
87
|
+
match = matcher.find_pattern(env, "double_child")
|
88
|
+
assert_not_nil match
|
89
|
+
assert_equal "C", match.root.name
|
90
|
+
|
91
|
+
match = matcher.find_pattern(env, "child_pattern")
|
92
|
+
assert_not_nil match
|
93
|
+
assert_equal ["AA"], match.bound_values
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
data/test/util_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rgen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,16 +9,16 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-03 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description: RGen is a framework
|
14
|
+
description: RGen is a framework for Model Driven Software Development (MDSD) in Ruby.
|
15
15
|
This means that it helps you build Metamodels, instantiate Models, modify and transform
|
16
16
|
Models and finally generate arbitrary textual content from it.
|
17
17
|
email: martin dot thiede at gmx de
|
18
18
|
executables: []
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files:
|
21
|
-
- README
|
21
|
+
- README.rdoc
|
22
22
|
- CHANGELOG
|
23
23
|
- MIT-LICENSE
|
24
24
|
files:
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- test/model_builder/statemachine_metamodel.rb
|
124
124
|
- test/model_builder/test_model/statemachine1.rb
|
125
125
|
- test/model_builder_test.rb
|
126
|
+
- test/model_fragment_test.rb
|
126
127
|
- test/output_handler_test.rb
|
127
128
|
- test/qualified_name_resolver_test.rb
|
128
129
|
- test/reference_resolver_test.rb
|
@@ -167,13 +168,14 @@ files:
|
|
167
168
|
- test/transformer_test.rb
|
168
169
|
- test/util/file_cache_map_test/testdir/fileA
|
169
170
|
- test/util/file_cache_map_test.rb
|
171
|
+
- test/util/pattern_matcher_test.rb
|
170
172
|
- test/util_test.rb
|
171
173
|
- test/xml_instantiator_test/simple_ecore_model_checker.rb
|
172
174
|
- test/xml_instantiator_test/simple_xmi_ecore_instantiator.rb
|
173
175
|
- test/xml_instantiator_test/simple_xmi_metamodel.rb
|
174
176
|
- test/xml_instantiator_test/simple_xmi_to_ecore.rb
|
175
177
|
- test/xml_instantiator_test.rb
|
176
|
-
- README
|
178
|
+
- README.rdoc
|
177
179
|
- CHANGELOG
|
178
180
|
- MIT-LICENSE
|
179
181
|
- Rakefile
|
@@ -182,7 +184,7 @@ licenses: []
|
|
182
184
|
post_install_message:
|
183
185
|
rdoc_options:
|
184
186
|
- --main
|
185
|
-
- README
|
187
|
+
- README.rdoc
|
186
188
|
- -x
|
187
189
|
- test
|
188
190
|
- -x
|
@@ -205,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
205
207
|
version: '0'
|
206
208
|
requirements: []
|
207
209
|
rubyforge_project: rgen
|
208
|
-
rubygems_version: 1.
|
210
|
+
rubygems_version: 1.8.23
|
209
211
|
signing_key:
|
210
212
|
specification_version: 3
|
211
213
|
summary: Ruby Modelling and Generator Framework
|
data/README
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
== RGen - Ruby Modelling and Generator Framework
|
2
|
-
|
3
|
-
RGen is a framework supporting Model Driven Software Development (MDSD).
|
4
|
-
This means that it helps you build Metamodels, instantiate Models, modify
|
5
|
-
and transform Models and finally generate arbitrary textual content from it.
|
6
|
-
|
7
|
-
RGen features include:
|
8
|
-
* Programmatic definition of Metamodels
|
9
|
-
* ECore as Metametamodel with an ECore instance available for every Metamodel
|
10
|
-
* Generator for programmatic Metamodel from ECore instance
|
11
|
-
* Instantiation of Metamodels, i.e. creation of Models (e.g. from XML)
|
12
|
-
* Model Transformations
|
13
|
-
* Powerful template based generator language
|
14
|
-
* A growing set of included Metamodels, Transformations, Generators:
|
15
|
-
* UML 1.3 Metamodel
|
16
|
-
* XMI 1.1 Instantiator
|
17
|
-
* XMI 2.0 Instantiator, currently use to read ECore instances only
|
18
|
-
|
19
|
-
|
20
|
-
= Download
|
21
|
-
|
22
|
-
Get the latest release from Rubyforge:
|
23
|
-
|
24
|
-
http://rubyforge.org/frs/?group_id=1988
|
25
|
-
|
26
|
-
|
27
|
-
= Installation
|
28
|
-
|
29
|
-
Unpack the release package somewhere to your filesystem.
|
30
|
-
Make sure the 'lib' folder is included in the search path (-I) when you run your own scripts.
|
31
|
-
|
32
|
-
As of version 0.2.0 RGen is also available as a gem.
|
33
|
-
|
34
|
-
|
35
|
-
= Getting started
|
36
|
-
|
37
|
-
Change to the 'test' folder and run the test suite:
|
38
|
-
|
39
|
-
test> ruby rgen_test.rb
|
40
|
-
|
41
|
-
|
42
|
-
= Documentation
|
43
|
-
|
44
|
-
RGen is being documented using rdoc.
|
45
|
-
Point your browser to 'doc/index.html' to view the documentation.
|
46
|
-
|
47
|
-
These are the main parts already documented:
|
48
|
-
* RGen::MetamodelBuilder
|
49
|
-
* RGen::Transformer
|
50
|
-
* RGen::TemplateLanguage
|
51
|
-
|
52
|
-
|
53
|
-
= Examples
|
54
|
-
|
55
|
-
There are several examples of using RGen within the framework itself.
|
56
|
-
|
57
|
-
Metamodel Definition:
|
58
|
-
lib/rgen/ecore/ecore.rb
|
59
|
-
lib/metamodels/uml13_metamodel.rb
|
60
|
-
|
61
|
-
Instantiation:
|
62
|
-
lib/rgen/instantiator/xmi11_instantiator.rb
|
63
|
-
lib/rgen/instantiator/ecore_xml_instantiator.rb
|
64
|
-
lib/instantiators/ea_instantiator.rb
|
65
|
-
|
66
|
-
Transformations:
|
67
|
-
lib/rgen/ecore/ecore_transformer.rb
|
68
|
-
lib/transformers/uml13_to_ecore.rb
|
69
|
-
|
70
|
-
Generators:
|
71
|
-
lib/mmgen/metamodel_generator.rb
|
72
|
-
|
73
|
-
|
74
|
-
= License
|
75
|
-
|
76
|
-
RGen is released under the MIT license.
|