This commit is contained in:
Tom MacWright 2012-12-19 11:53:10 -05:00
parent 1c569ce39d
commit ec0699dd45
8 changed files with 26 additions and 32 deletions

View File

@ -1,13 +1,13 @@
var util = require('util');
var fs = require('fs');
var path = require('path');
var util = require('util'),
fs = require('fs'),
path = require('path');
function getVersion() {
if (parseInt(process.version.split('.')[1]) > 4) {
if (parseInt(process.version.split('.')[1], 10) > 4) {
return require('../../package.json').version.split('.');
} else {
// older node
var package_json = JSON.parse(fs.readFileSync(path.join(__dirname,'../../package.json')))
var package_json = JSON.parse(fs.readFileSync(path.join(__dirname,'../../package.json')));
return package_json.version.split('.');
}
}
@ -90,4 +90,3 @@ function stylize(str, style) {
return '\033[' + styles[style][0] + 'm' + str +
'\033[' + styles[style][1] + 'm';
}

View File

@ -204,7 +204,7 @@ carto.Parser = function Parser(env) {
this.env.inputs = this.env.inputs || {};
// The Parser
return parser = {
parser = {
imports: imports,
//
@ -245,7 +245,8 @@ carto.Parser = function Parser(env) {
if (!inString && c === '/') {
cc = input.charAt(i + 1);
if (cc === '/' || cc === '*') {
if (match = comment.exec(input)) {
match = comment.exec(input);
if (match) {
if (match.index === i) {
i += match[0].length - 1;
chunk.push(match[0]);
@ -383,7 +384,7 @@ carto.Parser = function Parser(env) {
while ((node = $(this.rule) || $(this.ruleset) ||
$(this.comment)) ||
$(/^[\s\n]+/) || (node = $(this.invalid))) {
node && root.push(node);
if (node) root.push(node);
}
return root;
},
@ -809,7 +810,6 @@ carto.Parser = function Parser(env) {
// Expressions either represent mathematical operations,
// or white-space delimited Entities.
//
// 1px solid black
// @var * 2
expression: function() {
var e, delim, entities = [], d;
@ -827,5 +827,6 @@ carto.Parser = function Parser(env) {
}
}
};
return parser;
};

View File

@ -3,12 +3,10 @@
// RGB Colors - #ff0014, #eee
//
tree.Color = function Color(rgb, a) {
//
// The end goal here, is to parse the arguments
// into an integer triplet, such as `128, 255, 0`
//
// This facilitates operations and conversions.
//
if (Array.isArray(rgb)) {
this.rgb = rgb;
} else if (rgb.length == 6) {
@ -25,7 +23,7 @@ tree.Color = function Color(rgb, a) {
tree.Color.prototype = {
is: 'color',
eval: function() { return this; },
'eval': function() { return this; },
// If we have some transparency, the only way to represent it
// is via `rgba`. Otherwise, we use the hex representation,
@ -87,5 +85,4 @@ tree.Color.prototype = {
}
};
})(require('../tree'));

View File

@ -9,7 +9,7 @@ tree.Comment.prototype = {
toString: function(env) {
return '<!--' + this.value + '-->';
},
eval: function() { return this; }
'eval': function() { return this; }
};
})(require('../tree'));

View File

@ -11,7 +11,7 @@ tree.Dimension = function Dimension(value, unit, index) {
tree.Dimension.prototype = {
is: 'float',
eval: function (env) {
'eval': function (env) {
if (this.unit && ['px', '%'].indexOf(this.unit) === -1) {
env.error({
message: "Invalid unit: '" + this.unit + "'",

View File

@ -39,10 +39,11 @@ var ops = {
};
tree.Filter.prototype.toXML = function(env) {
if (this.val.eval) this._val = this.val.eval(env);
if (this.key.eval) this._key = this.key.eval(env);
if (this._key) var key = this._key.toString(false);
if (this._val) var val = this._val.toString(this._val.is == 'string');
var val, key;
if (this.val['eval']) this._val = this.val['eval'](env);
if (this.key['eval']) this._key = this.key['eval'](env);
if (this._key) key = this._key.toString(false);
if (this._val) val = this._val.toString(this._val.is == 'string');
if (
(ops[this.op][1] == 'numeric' && isNaN(this.val)) ||

View File

@ -17,8 +17,8 @@ tree.Layer.prototype.toXML = function() {
}
var prop_string = '';
for (var i in this.properties) {
prop_string += ' ' + i + '="' + this.properties[i] + '"\n';
for (var prop in this.properties) {
prop_string += ' ' + prop + '="' + this.properties[prop] + '"\n';
}
return '<Layer' +

View File

@ -3,12 +3,10 @@
"version": "0.9.4",
"description": "Mapnik Stylesheet Compiler",
"url": "https://github.com/mapbox/carto",
"repositories": [
{
"type": "git",
"url": "http://github.com/mapbox/carto.git"
}
],
"repositories": [{
"type": "git",
"url": "http://github.com/mapbox/carto.git"
}],
"author": {
"name": "MapBox",
"url": "http://mapbox.com/",
@ -25,11 +23,9 @@
"Konstantin Käfer",
"Alexis Sellier <self@cloudhead.net>"
],
"licenses": [
{
"licenses": [{
"type": "Apache"
}
],
}],
"bin": {
"carto": "./bin/carto",
"mml2json.js": "./bin/mml2json.js"