diff --git a/lib/deps/attributs.js b/lib/deps/attributes.js similarity index 93% rename from lib/deps/attributs.js rename to lib/deps/attributes.js index 66a930c..f65e137 100644 --- a/lib/deps/attributs.js +++ b/lib/deps/attributes.js @@ -202,7 +202,7 @@ function quoteMe(attr, value) { } } -function validateAttribut(name, type) { +function validateAttribute(name, type) { if(attrs[name]) { return(attrs[name].usage.indexOf(type) > -1); } else { @@ -211,39 +211,39 @@ function validateAttribut(name, type) { } exports.isValid = function(name, type) { - return validateAttribut(name, type); + return validateAttribute(name, type); }; -var Attributs = exports.Attributs = function(t) { +var Attributes = exports.Attributes = function(t) { this._type = t; - this.attributs = new Hash(); + this.attributes = new Hash(); }; -Attributs.prototype.length = function() { - return(this.attributs.length); +Attributes.prototype.length = function() { + return(this.attributes.length); }; -Attributs.prototype.set = function(name, value) { - if(validateAttribut(name, this._type) === false) { - util.debug("Warning : Invalid attribut `" + name + "' for a " + gType[this._type]); - // throw "Invalid attribut `"+name+"' for a "+gType[this._type] +Attributes.prototype.set = function(name, value) { + if(validateAttribute(name, this._type) === false) { + util.debug("Warning : Invalid attribute `" + name + "' for a " + gType[this._type]); + // throw "Invalid attribute `"+name+"' for a "+gType[this._type] } - this.attributs.setItem(name, value); + this.attributes.setItem(name, value); }; -Attributs.prototype.get = function(name) { - return this.attributs.items[name]; +Attributes.prototype.get = function(name) { + return this.attributes.items[name]; }; -Attributs.prototype.to_dot = function(link) { +Attributes.prototype.to_dot = function(link) { var attrsOutput = "", sep = ""; - if(this.attributs.length > 0) { + if(this.attributes.length > 0) { attrsOutput = attrsOutput + " [ "; - for(var name in this.attributs.items) { - if (this.attributs.items.hasOwnProperty(name)) { - attrsOutput = attrsOutput + sep + name + " =" + quoteMe(name, this.attributs.items[name]); + for(var name in this.attributes.items) { + if (this.attributes.items.hasOwnProperty(name)) { + attrsOutput = attrsOutput + sep + name + " =" + quoteMe(name, this.attributes.items[name]); sep = ", "; } } diff --git a/lib/deps/edge.js b/lib/deps/edge.js index a93ea13..7cc8b6c 100644 --- a/lib/deps/edge.js +++ b/lib/deps/edge.js @@ -2,7 +2,7 @@ * Module dependencies */ var Hash = require('./core_ext/hash').Hash, - Attributs = require('./attributs').Attributs; + Attributes = require('./attributes').Attributes; /** * Create a new edge @@ -17,30 +17,30 @@ var Edge = exports.Edge = function(graph, nodeOne, nodeTwo) { this.relativeGraph = graph; this.nodeOne = nodeOne; this.nodeTwo = nodeTwo; - this.attributs = new Attributs("E"); + this.attributes = new Attributes("E"); }; /** - * Set an edge attribut + * Set an edge attribute * - * @param {String} name The attribut name - * @param {Void} value The attribut value + * @param {String} name The attribute name + * @param {Void} value The attribute value * @api public */ Edge.prototype.set = function(name, value) { - this.attributs.set(name, value); + this.attributes.set(name, value); return this; }; /** - * Get an edge attribut + * Get an edge attribute * - * @param {String} name The attribut name + * @param {String} name The attribute name * @return {Void} * @api public */ Edge.prototype.get = function(name) { - return this.attributs.get(name); + return this.attributes.get(name); }; /** @@ -53,6 +53,6 @@ Edge.prototype.to_dot = function() { } var edgeOutput = '"' + this.nodeOne.id + '"' + " " + edgeLink + " " + '"' + this.nodeTwo.id + '"'; - edgeOutput = edgeOutput + this.attributs.to_dot(); + edgeOutput = edgeOutput + this.attributes.to_dot(); return edgeOutput; }; diff --git a/lib/deps/graph.js b/lib/deps/graph.js index 362bc4c..f3184d5 100644 --- a/lib/deps/graph.js +++ b/lib/deps/graph.js @@ -4,8 +4,8 @@ var Hash = require( './core_ext/hash' ).Hash, Node = require( './node' ).Node, Edge = require( './edge' ).Edge, - gvattrs = require( './attributs' ), - Attributs = gvattrs.Attributs, + gvattrs = require( './attributes' ), + Attributes = gvattrs.Attributes, util = require('util'), path = require('path'), spawn = require('child_process').spawn; @@ -27,12 +27,12 @@ var Graph = exports.Graph = function(graph, id) { this.edges = new Array(); this.clusters = new Hash(); if( this.relativeGraph == null ) { - this.graphAttributs = new Attributs("G"); + this.graphAttributes = new Attributes("G"); } else { - this.graphAttributs = new Attributs("C"); + this.graphAttributes = new Attributes("C"); } - this.nodesAttributs = new Attributs("N"); - this.edgesAttributs = new Attributs("E"); + this.nodesAttributes = new Attributes("N"); + this.edgesAttributes = new Attributes("E"); this.use = 'dot'; }; @@ -40,7 +40,7 @@ var Graph = exports.Graph = function(graph, id) { * Create a new node * * @param {String} id The node ID - * @param {Object} attrs Node attributs + * @param {Object} attrs Node attributes * @return {Node} * @api public */ @@ -88,7 +88,7 @@ Graph.prototype.nodeCount = function() { * * @param {String|Node} nodeOne * @param {String|Node} nodeTwo - * @param {Object} attrs Node attributs + * @param {Object} attrs Node attributes * @return {Edge} * @api public */ @@ -165,69 +165,69 @@ Graph.prototype.clusterCount = function() { } /** - * Set a graph attribut + * Set a graph attribute * - * @param {String} name The attribut name - * @param {Void} value The attribut value + * @param {String} name The attribute name + * @param {Void} value The attribute value * @api public */ Graph.prototype.set = function(name, value) { - this.graphAttributs.set(name, value); + this.graphAttributes.set(name, value); } /** - * Get a graph attribut + * Get a graph attribute * - * @param {String} name The attribut name + * @param {String} name The attribute name * @return {Void} * @api public */ Graph.prototype.get = function(name) { - return this.graphAttributs.get(name); + return this.graphAttributes.get(name); } /** - * Set a global node attribut + * Set a global node attribute * - * @param {String} name The attribut name - * @param {Void} value The attribut value + * @param {String} name The attribute name + * @param {Void} value The attribute value * @api public */ -Graph.prototype.setNodeAttribut = function(name, value) { - this.nodesAttributs.set(name, value); +Graph.prototype.setNodeAttribute = function(name, value) { + this.nodesAttributes.set(name, value); } /** - * Get a global node attribut + * Get a global node attribute * - * @param {String} name The attribut name + * @param {String} name The attribute name * @return {Void} * @api public */ -Graph.prototype.getNodeAttribut = function(name) { - return this.nodesAttributs.get(name); +Graph.prototype.getNodeAttribute = function(name) { + return this.nodesAttributes.get(name); } /** - * Set a global edge attribut + * Set a global edge attribute * - * @param {String} name The attribut name - * @param {Void} value The attribut value + * @param {String} name The attribute name + * @param {Void} value The attribute value * @api public */ -Graph.prototype.setEdgeAttribut = function(name, value) { - this.edgesAttributs.set(name, value); +Graph.prototype.setEdgeAttribute = function(name, value) { + this.edgesAttributes.set(name, value); } /** - * Get a global edge attribut + * Get a global edge attribute * - * @param {String} name The attribut name + * @param {String} name The attribute name * @return {Void} * @api public */ -Graph.prototype.getEdgeAttribut = function(name) { - return this.edgesAttributs.get(name); +Graph.prototype.getEdgeAttribute = function(name) { + return this.edgesAttributes.get(name); } /** @@ -244,19 +244,19 @@ Graph.prototype.to_dot = function() { dotScript = 'subgraph ' + this.id + ' {\n' } - // Graph attributs - if( this.graphAttributs.length() > 0 ) { - dotScript = dotScript + " graph" + this.graphAttributs.to_dot() + ";\n"; + // Graph attributes + if( this.graphAttributes.length() > 0 ) { + dotScript = dotScript + " graph" + this.graphAttributes.to_dot() + ";\n"; } - // Nodes attributs - if( this.nodesAttributs.length() > 0 ) { - dotScript = dotScript + " node" + this.nodesAttributs.to_dot() + ";\n"; + // Nodes attributes + if( this.nodesAttributes.length() > 0 ) { + dotScript = dotScript + " node" + this.nodesAttributes.to_dot() + ";\n"; } - // Edges attributs - if( this.edgesAttributs.length() > 0 ) { - dotScript = dotScript + " edge" + this.edgesAttributs.to_dot() + ";\n"; + // Edges attributes + if( this.edgesAttributes.length() > 0 ) { + dotScript = dotScript + " edge" + this.edgesAttributes.to_dot() + ";\n"; } // Each clusters @@ -319,7 +319,7 @@ Graph.prototype.render = function(type_or_options, name_or_callback, errback) { if( type_or_options.G != undefined ) { for( attr in type_or_options.G ) { if( gvattrs.isValid( attr, "G" ) == false ) { - util.debug( "Warning : Invalid attribut `"+attr+"' for a graph" ); + util.debug( "Warning : Invalid attribute `"+attr+"' for a graph" ); } parameters.push( "-G"+attr+"="+type_or_options.G[attr] ) } @@ -328,7 +328,7 @@ Graph.prototype.render = function(type_or_options, name_or_callback, errback) { if( type_or_options.N != undefined ) { for( attr in type_or_options.N ) { if( gvattrs.isValid( attr, "N" ) == false ) { - util.debug( "Warning : Invalid attribut `"+attr+"' for a node" ); + util.debug( "Warning : Invalid attribute `"+attr+"' for a node" ); } parameters.push( "-N"+attr+"="+type_or_options.N[attr] ) } @@ -337,7 +337,7 @@ Graph.prototype.render = function(type_or_options, name_or_callback, errback) { if( type_or_options.E != undefined ) { for( attr in type_or_options.E ) { if( gvattrs.isValid( attr, "E" ) == false ) { - util.debug( "Warning : Invalid attribut `"+attr+"' for an edge" ); + util.debug( "Warning : Invalid attribute `"+attr+"' for an edge" ); } parameters.push( "-E"+attr+"="+type_or_options.E[attr] ) } diff --git a/lib/deps/node.js b/lib/deps/node.js index 1aa0424..8e5fbec 100644 --- a/lib/deps/node.js +++ b/lib/deps/node.js @@ -2,7 +2,7 @@ * Module dependencies */ var Hash = require('./core_ext/hash').Hash, - Attributs = require('./attributs').Attributs; + Attributes = require('./attributes').Attributes; /** * Create a new node @@ -15,7 +15,7 @@ var Hash = require('./core_ext/hash').Hash, var Node = exports.Node = function(graph, id) { this.relativeGraph = graph; this.id = id; - this.attributs = new Attributs("N"); + this.attributes = new Attributes("N"); }; /** @@ -27,32 +27,32 @@ Node.prototype.to = function(id, attrs) { }; /** - * Set a node attribut + * Set a node attribute * - * @param {String} name The attribut name - * @param {Void} value The attribut value + * @param {String} name The attribute name + * @param {Void} value The attribute value * @api public */ Node.prototype.set = function(name, value) { - this.attributs.set(name, value); + this.attributes.set(name, value); return this; }; /** - * Get a node attribut + * Get a node attribute * - * @param {String} name The attribut name + * @param {String} name The attribute name * @return {Void} * @api public */ Node.prototype.get = function(name) { - return this.attributs.get(name); + return this.attributes.get(name); }; /** * @api private */ Node.prototype.to_dot = function() { - var nodeOutput = '"' + this.id + '"' + this.attributs.to_dot(); + var nodeOutput = '"' + this.id + '"' + this.attributes.to_dot(); return nodeOutput; }; diff --git a/tests/cluster.js b/tests/cluster.js index 727f196..48b8624 100644 --- a/tests/cluster.js +++ b/tests/cluster.js @@ -10,8 +10,8 @@ cluster_0.set( "style", "filled" ); // color=lightgrey; cluster_0.set( "color", "lightgrey" ); // node [style=filled,color=white]; -cluster_0.setNodeAttribut( "style", "filled" ) -cluster_0.setNodeAttribut( "color", "white" ) +cluster_0.setNodeAttribute( "style", "filled" ) +cluster_0.setNodeAttribute( "color", "white" ) // a0 -> a1 -> a2 -> a3; cluster_0.addEdge( "a0", "a1" ); @@ -24,7 +24,7 @@ cluster_0.set( "label", "process #1" ) // subgraph cluster_1 { var cluster_1 = g.addCluster("cluster_1"); // node [style=filled]; -cluster_1.setNodeAttribut( "style", "filled" ) +cluster_1.setNodeAttribute( "style", "filled" ) // b0 -> b1 -> b2 -> b3; cluster_1.addEdge( "b0", "b1" );