Permalink
Browse files

Changelog for 0.5.0. Adds second parameter to Render for specifying

Mapnik version. Handle unrecognized selectors slightly better for
backwards-and-forwards stylesheets.
  • Loading branch information...
1 parent c38cc9c commit 1645df71a44675c11327b1cd76d697f454c78e1e @tmcw tmcw committed Jun 18, 2012
Showing with 42 additions and 17 deletions.
  1. +5 −0 CHANGELOG.md
  2. +6 −2 lib/carto/renderer.js
  3. +8 −2 lib/carto/tree/reference.js
  4. +22 −12 lib/carto/tree/rule.js
  5. +1 −1 package.json
View
@@ -1,5 +1,10 @@
## Changelog
+### 0.5.0
+
+* Now uses the [mapnik-reference](https://github.com/mapnik/mapnik-reference) npm module
+ instead of copying `reference.json` when it's updated
+
### 0.4.10
* Updated reference.json
View
@@ -2,8 +2,10 @@ var _ = require('underscore');
var carto = require('./index');
var tree = require('./tree');
-carto.Renderer = function Renderer(env) {
+carto.Renderer = function Renderer(env, options) {
this.env = env || {};
+ this.options = options || {};
+ this.options.mapnik_version = this.options.mapnik_version || 'latest';
};
// Prepare a MML document (given as an object) into a
@@ -20,6 +22,8 @@ carto.Renderer.prototype.render = function render(m, callback) {
effects: []
});
+ tree.Reference.setVersion(this.options.mapnik_version);
+
var output = [];
// Transform stylesheets into rulesets.
@@ -33,7 +37,7 @@ carto.Renderer.prototype.render = function render(m, callback) {
var time = +new Date(),
root = (carto.Parser(env)).parse(s.data);
if (env.benchmark)
- console.warn('Parsing time: ' + ((new Date() - time)) + 'ms');
+ console.warn('Parsing time: ' + (new Date() - time) + 'ms');
return root.toList(env);
})
.flatten()
@@ -3,7 +3,11 @@
var mapnik_reference = require('mapnik-reference');
tree.Reference = {
- data: mapnik_reference.version['2.1.0']
+ data: mapnik_reference.version.latest
+};
+
+tree.Reference.setVersion = function(version) {
+ tree.Reference.data = mapnik_reference.version[version];
};
tree.Reference.required_prop_list_cache = {};
@@ -100,7 +104,9 @@ tree.Reference.validValue = function(env, selector, value) {
return tree.Reference.selector(selector).type == value[0].is;
} else {
// TODO: handle in reusable way
- if (value.value[0].is == 'keyword') {
+ if (!tree.Reference.selector(selector)) {
+ return false;
+ } else if (value.value[0].is == 'keyword') {
return tree.Reference
.selector(selector).type
.indexOf(value.value[0].value) !== -1;
View
@@ -47,18 +47,28 @@ tree.Rule.prototype.toXML = function(env, content) {
if ((this.value instanceof tree.Value) &&
!tree.Reference.validValue(env, this.name, this.value)) {
- return env.error({
- message: 'Invalid value for ' +
- this.name +
- ', a valid ' +
- (tree.Reference.selector(this.name).validate ||
- tree.Reference.selector(this.name).type) +
- ' is expected. ' + this.value +
- ' was given.',
- index: this.index,
- type: 'syntax',
- filename: this.filename
- });
+ if (!tree.Reference.selector(this.name)) {
+ return env.error({
+ message: 'Unrecognized property: ' +
+ this.name,
+ index: this.index,
+ type: 'syntax',
+ filename: this.filename
+ });
+ } else {
+ return env.error({
+ message: 'Invalid value for ' +
+ this.name +
+ ', a valid ' +
+ (tree.Reference.selector(this.name).validate ||
+ tree.Reference.selector(this.name).type) +
+ ' is expected. ' + this.value +
+ ' was given.',
+ index: this.index,
+ type: 'syntax',
+ filename: this.filename
+ });
+ }
}
if (this.variable) {
View
@@ -1,5 +1,6 @@
{
"name": "carto",
+ "version": "0.5.0",
"description": "Mapnik Stylesheet Compiler",
"url": "https://github.com/mapbox/carto",
"repositories": [{
@@ -22,7 +23,6 @@
"Konstantin Käfer",
"Alexis Sellier <self@cloudhead.net>"
],
- "version": "0.4.10",
"licenses": [{
"type": "Apache"
}],

0 comments on commit 1645df7

Please sign in to comment.