Skip to content

Commit

Permalink
Merged
Browse files Browse the repository at this point in the history
  • Loading branch information
KoryNunn committed Jan 21, 2015
2 parents 692741d + d7a4f4c commit 5aab214
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 32 deletions.
18 changes: 0 additions & 18 deletions foo

This file was deleted.

35 changes: 23 additions & 12 deletions gel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function fastEach(items, callback) {
}

function quickIndexOf(array, value){
var length = array.length
var length = array.length;
for(var i = 0; i < length && array[i] !== value;i++) {}
return i < length ? i : -1;
}
Expand Down Expand Up @@ -94,10 +94,10 @@ StringToken.tokenise = function (substring) {
index + escapes + 1
);
}
}
};
StringToken.prototype.evaluate = function () {
this.result = this.original.slice(1,-1);
}
};

function String2Token(){}
String2Token = createSpec(String2Token, StringToken);
Expand All @@ -117,7 +117,7 @@ ParenthesesToken.tokenise = function(substring) {
if(substring.charAt(0) === '('){
return new ParenthesesToken(substring.charAt(0), 1);
}
}
};
var parenthesisParser = createNestingParser(ParenthesesEndToken);
ParenthesesToken.prototype.parse = function(tokens, index, parse){
parenthesisParser.apply(this, arguments);
Expand Down Expand Up @@ -217,13 +217,19 @@ NumberToken.prototype.evaluate = function(scope){

function ValueToken(value, sourcePathInfo, key){
this.original = 'Value';
this.length = this.original.length,
this.length = this.original.length;
this.result = value;

if(sourcePathInfo){
this.sourcePathInfo = new SourcePathInfo();
this.sourcePathInfo.path = sourcePathInfo.path;
this.sourcePathInfo.subPaths = sourcePathInfo.subPaths && sourcePathInfo.subPaths.slice();
if(sourcePathInfo.subPaths){
this.sourcePathInfo.subPaths = new sourcePathInfo.subPaths.constructor();

for(var subPathKey in sourcePathInfo.subPaths){
this.sourcePathInfo.subPaths[subPathKey] = sourcePathInfo.subPaths[subPathKey];
}
}
}

if(key != null){
Expand Down Expand Up @@ -345,7 +351,7 @@ PeriodToken.prototype.evaluate = function(scope){
var targetPath;

if(this.targetToken.sourcePathInfo){
targetPath = this.targetToken.sourcePathInfo.path
targetPath = this.targetToken.sourcePathInfo.path;
}

if(targetPath){
Expand Down Expand Up @@ -436,8 +442,8 @@ FillToken.tokenise = function(substring){
};
FillToken.prototype.parse = function(tokens){
if(tokens._hasFill){
throw "A function call may only have one fill token"
};
throw "A function call may only have one fill token";
}
tokens._hasFill = true;
};
FillToken.prototype.evaluate = function(){
Expand Down Expand Up @@ -535,7 +541,7 @@ BraceToken.prototype.evaluate = function(scope){
if(token.valueToken.sourcePathInfo){
this.sourcePathInfo.subPaths[key] = token.valueToken.sourcePathInfo.path;
}
};
}

return;
}
Expand Down Expand Up @@ -644,6 +650,11 @@ SourcePathInfo.prototype.mapSubPaths = function(object){
}
};
SourcePathInfo.prototype.drillTo = function(key){
if(key == null){
this.subPaths = null;
this.path = null;
return;
}
if(this.subPaths){
this.path = this.subPaths[key];
}else if(this.path){
Expand Down Expand Up @@ -1061,7 +1072,7 @@ var tokenConverters = [
var nullPaths = [];
for(var i = 0; i < argToken.result.length; i++) {
nullPaths.push(null);
};
}
sourcePaths = sourcePaths.concat(nullPaths);
}
};
Expand Down Expand Up @@ -1539,7 +1550,7 @@ Gel = function(){

for (var i = 0; i < tokenConverters.length; i++) {
Gel[tokenConverters[i].prototype.name] = tokenConverters[i];
};
}

Gel.Token = Token;
Gel.Scope = Scope;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"name": "gel-js",
"description": "'Gaffa expression language' is an extensible expression language that lets you safely input epxressions into an application",
"version": "1.11.3",
"version": "1.11.5",
"repository": {
"type": "git",
"url": "https://github.com/gaffa-tape/gel.git"
Expand All @@ -30,7 +30,7 @@
"gedi-paths": "^1.0.0",
"lang-js": "^2.0.0",
"merge": "^1.2.0",
"spec-js": "0.0.x"
"spec-js": "^1.0.0"
},
"keywords": [
"gel",
Expand Down
8 changes: 8 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1088,3 +1088,11 @@ test('(merge {"x":{"y":3.5}} {"x":{"wing":"meh"} "y":{"s":"club7"}})', function(
{"x":{"y":3.5,"wing":"meh"},"y":{"s":"club7"}}
);
});
test('(fold (array {"foo" : {"stuff" : (array 1 2 3)}} {"bar" : {"thing" : "stuff"}}) {} {result item (merge result item)})', function (t) {
t.plan(1);
t.deepEqual(
gel.evaluate(t.name, context),
{'bar':{'thing':'stuff'}, 'foo': {'stuff':[1,2,3]}}
);
t.end();
});

0 comments on commit 5aab214

Please sign in to comment.