瀏覽代碼

Turn libmt into module.

Bentley James Oakes 7 年之前
父節點
當前提交
acb5cd12ba
共有 3 個文件被更改,包括 22 次插入15 次删除
  1. 1 1
      __worker.js
  2. 18 14
      libmt.js
  3. 3 0
      mmmk.js

+ 1 - 1
__worker.js

@@ -505,7 +505,7 @@ process.on('message',
 			}
 			_mmmk   = require('./mmmk');
 
-            _mt  	  = eval('('+_fs.readFileSync('./libmt.js', 'utf8')+')');
+            _mt  	  = require('./libmt');
 
 			_plugins = {};
 			_fs.readdirSync('./plugins').forEach(

+ 18 - 14
libmt.js

@@ -1,9 +1,13 @@
+
 /* This file is part of AToMPM - A Tool for Multi-Paradigm Modelling
 *  Copyright 2011 by the AToMPM team and licensed under the LGPL
 *  See COPYING.lesser and README.md in the root of this project for full details
 */
 
-{
+const _utils = require('./utils');
+
+/* eslint-disable no-inner-declarations */
+module.exports = {
 	/* apply transformation T to specified model 
 
 		TBI:: this method only supports transforming class diagrams to ER diagrams
@@ -51,8 +55,8 @@
                                         new_model.nodes[parent_id]['attributes']['value'].filter(
                                             function(attr) {
                                                 return !new_model.nodes[child_id]['attributes']['value'].find(
-                                                    function(el) {return el['name'] == attr['name']}
-                                                )
+                                                    function(el) {return el['name'] == attr['name'];}
+                                                );
                                             }
                                         )
                                     );
@@ -61,8 +65,8 @@
                                         new_model.nodes[parent_id]['constraints']['value'].filter(
                                             function(constr) {
                                                 return !new_model.nodes[child_id]['constraints']['value'].find(
-                                                    function(el) {return el['name'] == constr['name']}
-                                                )
+                                                    function(el) {return el['name'] == constr['name'];}
+                                                );
                                             }
                                         )
                                     );
@@ -71,8 +75,8 @@
                                         new_model.nodes[parent_id]['actions']['value'].filter(
                                             function(act) {
                                                 return !new_model.nodes[child_id]['actions']['value'].find(
-                                                    function(el) {return el['name'] == act['name']}
-                                                )
+                                                    function(el) {return el['name'] == act['name'];}
+                                                );
                                             }
                                         )
                                     );
@@ -81,8 +85,8 @@
                                         new_model.nodes[parent_id]['cardinalities']['value'].filter(
                                             function(card) {
                                                 return !new_model.nodes[child_id]['cardinalities']['value'].find(
-                                                    function(el) {return el['dir'] == card['dir'] && el['type'] == card['type']}
-                                                )
+                                                    function(el) {return el['dir'] == card['dir'] && el['type'] == card['type'];}
+                                                );
                                             }
                                         )
                                     );
@@ -182,7 +186,7 @@
 							new_model.nodes[id]['constraints']['value'].push(
 									{'name':'noAbstractInstances',
 									 'event':'pre-create',
-									 'code':'false'})
+									 'code':'false'});
 						}
 					}
 					else if( new_model.nodes[id]['$type'] == SCD+'/Association' )
@@ -197,7 +201,7 @@
 							a) remove all edges pertaining to it
 							b) remove it */
 						new_model.edges = new_model.edges.filter(
-								function(edge)	{return edge['src'] != id && edge['dest'] != id});
+								function(edge)	{return edge['src'] != id && edge['dest'] != id;});
 						delete new_model.nodes[id];
 					}
 				}
@@ -211,11 +215,11 @@
 					var type = new_model.nodes[id]['name']['value'];
 					if( types2parentTypes[type] == undefined ) 
 					{
-						types2parentTypes[type] = []
+						types2parentTypes[type] = [];
 						ids2ancestors[id].forEach(
 								function(a)
 								{
-									types2parentTypes[type].push(new_model.nodes[a]['name']['value'])
+									types2parentTypes[type].push(new_model.nodes[a]['name']['value']);
 								});
 					}
 				}
@@ -471,5 +475,5 @@
 
 			return {'asmm':asmm,'csmms':csmms};
 		}
-}
+};
 

+ 3 - 0
mmmk.js

@@ -12,6 +12,9 @@
 		clients can 'call') and thus, we do no support 'save' events... */
 
 const _utils = require('./utils');
+const _util = require("util");
+const _mt = require("./libmt");
+
 module.exports = {
 	/********************************* GLOBALS *********************************/
 	'metamodels':{},