File: mmgen.rb

package info (click to toggle)
ruby-rgen 0.10.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,428 kB
  • sloc: ruby: 11,344; xml: 1,368; yacc: 72; makefile: 10
file content (28 lines) | stat: -rw-r--r-- 742 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$:.unshift File.join(File.dirname(__FILE__),"..")

require 'ea/xmi_ecore_instantiator'
require 'mmgen/metamodel_generator'

include MMGen::MetamodelGenerator

unless ARGV.length >= 2
	puts "Usage: mmgen.rb <xmi_class_model_file> <root package> (<module>)*"
	exit
else
	file_name = ARGV.shift
	root_package_name = ARGV.shift
	modules = ARGV
	out_file = file_name.gsub(/\.\w+$/,'.rb')
	puts out_file
end

env = RGen::Environment.new
File.open(file_name) { |f|
    puts "instantiating ..."
	XMIECoreInstantiator.new.instantiateECoreModel(env, f.read)
}

rootPackage = env.find(:class => RGen::ECore::EPackage, :name => root_package_name).first

puts "generating ..."
generateMetamodel(rootPackage, out_file, modules)