RGen is a framework for Model Driven Software Development (MDSD) in Ruby. This means that it helps you build Metamodels, instantiate Models, modify and transform Models and finally generate arbitrary textual content from it.
RGen features include:
-
Supporting Ruby 2.6 to 4.0
-
Metamodel definition language (internal Ruby DSL)
-
ECore Meta-metamodel with an ECore instance available for every Metamodel
-
Generator creating the Ruby metamodel definition from an ECore instance
-
Transformer creating Ruby metamodel classes/modules from an ECore instance
-
Instantiation of Metamodels, i.e. creation of Models (e.g. from XML)
-
Model builder, internal Ruby DSL
-
Model fragmentation over several files and per-fragment caching
-
Model Transformation language (internal Ruby DSL)
-
Powerful template based generator language (internal Ruby DSL inside of ERB)
-
UML 1.3 metamodel and XMI 1.1 instantiator included
-
ECore XML support (XMI 2.0)
-
JSON instantiator and serializer, and ECore-to-JSON export
-
UML-to-ECore and ECore-to-UML transformation (UML class models)
-
Enterprise Architect support (UML1.3/XMI1.1)
Get the latest release from Github: github.com/mthiede/rgen
Install RGen as a Ruby gem:
gem install rgen
Reading XML needs the nokogiri gem, which RGen does not depend on:
gem install nokogiri
It is required by the three instantiators which read XML:
-
RGen::Instantiator::DefaultXMLInstantiator (and NodebasedXMLInstantiator, which it builds on)
-
XMI11Instantiator
-
ECoreXMLInstantiator
Everything else works without it, including the XMI and JSON serializers, the JSON instantiator, the metamodel builder, the transformer, the template language and the metamodel generator.
Run the test suite from the top of the working tree:
rake test
This puts ‘lib’ on the load path, so the tests exercise the working tree. Running test/rgen_test.rb directly without ‘-I lib’ loads an installed rgen gem instead.
RDoc documentation is available at Github: mthiede.github.io/rgen/
To build the documentation for the working tree, run ‘rake rdoc’; it is written to ‘doc’.
Find the main documentation parts for:
-
RGen::MetamodelBuilder
-
RGen::Transformer
-
RGen::TemplateLanguage
-
RGen::Fragment::FragmentedModel
There are several examples of using RGen within the framework itself.
Metamodel Definition:
lib/rgen/ecore/ecore.rb lib/metamodels/uml13_metamodel.rb
Instantiation:
lib/rgen/instantiator/xmi11_instantiator.rb lib/rgen/instantiator/ecore_xml_instantiator.rb
Transformations:
lib/rgen/ecore/ruby_to_ecore.rb lib/transformers/uml13_to_ecore.rb
Generators:
lib/mmgen/metamodel_generator.rb
RGen is released under the MIT license.