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

View File

@ -204,7 +204,7 @@ carto.Parser = function Parser(env) {
this.env.inputs = this.env.inputs || {}; this.env.inputs = this.env.inputs || {};
// The Parser // The Parser
return parser = { parser = {
imports: imports, imports: imports,
// //
@ -245,7 +245,8 @@ carto.Parser = function Parser(env) {
if (!inString && c === '/') { if (!inString && c === '/') {
cc = input.charAt(i + 1); cc = input.charAt(i + 1);
if (cc === '/' || cc === '*') { if (cc === '/' || cc === '*') {
if (match = comment.exec(input)) { match = comment.exec(input);
if (match) {
if (match.index === i) { if (match.index === i) {
i += match[0].length - 1; i += match[0].length - 1;
chunk.push(match[0]); chunk.push(match[0]);
@ -383,7 +384,7 @@ carto.Parser = function Parser(env) {
while ((node = $(this.rule) || $(this.ruleset) || while ((node = $(this.rule) || $(this.ruleset) ||
$(this.comment)) || $(this.comment)) ||
$(/^[\s\n]+/) || (node = $(this.invalid))) { $(/^[\s\n]+/) || (node = $(this.invalid))) {
node && root.push(node); if (node) root.push(node);
} }
return root; return root;
}, },
@ -809,7 +810,6 @@ carto.Parser = function Parser(env) {
// Expressions either represent mathematical operations, // Expressions either represent mathematical operations,
// or white-space delimited Entities. // or white-space delimited Entities.
// //
// 1px solid black
// @var * 2 // @var * 2
expression: function() { expression: function() {
var e, delim, entities = [], d; 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 // RGB Colors - #ff0014, #eee
// //
tree.Color = function Color(rgb, a) { tree.Color = function Color(rgb, a) {
//
// The end goal here, is to parse the arguments // The end goal here, is to parse the arguments
// into an integer triplet, such as `128, 255, 0` // into an integer triplet, such as `128, 255, 0`
// //
// This facilitates operations and conversions. // This facilitates operations and conversions.
//
if (Array.isArray(rgb)) { if (Array.isArray(rgb)) {
this.rgb = rgb; this.rgb = rgb;
} else if (rgb.length == 6) { } else if (rgb.length == 6) {
@ -25,7 +23,7 @@ tree.Color = function Color(rgb, a) {
tree.Color.prototype = { tree.Color.prototype = {
is: 'color', is: 'color',
eval: function() { return this; }, 'eval': function() { return this; },
// If we have some transparency, the only way to represent it // If we have some transparency, the only way to represent it
// is via `rgba`. Otherwise, we use the hex representation, // is via `rgba`. Otherwise, we use the hex representation,
@ -87,5 +85,4 @@ tree.Color.prototype = {
} }
}; };
})(require('../tree')); })(require('../tree'));

View File

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

View File

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

View File

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

View File

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

View File

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