Skip to content

Commit

Permalink
Merge branch 'release/0.1.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
dcrockwell committed Jul 7, 2016
2 parents c7def0d + 8c4cede commit 95da7b6
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 8 deletions.
12 changes: 11 additions & 1 deletion es5/lib/chainLink/parameterCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,27 @@ var ParameterCollection = function () {

_.parentLink[parameterName] = function (valueCollection) {
if (valueCollection) {
for (var valueKey in valueCollection) {
var _loop = function _loop(valueKey) {
var value = valueCollection[valueKey];

_.filters.forEach(function (filter) {
value = filter(value);
});

parameterValues[valueKey] = value;
};

for (var valueKey in valueCollection) {
_loop(valueKey);
}
return _.parentLink;
} else {
return parameterValues;
}
};
});

return this;
}
}]);

Expand Down
23 changes: 22 additions & 1 deletion es5/spec/chainLink/chainLink.parameters.filter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ var Numbers = function (_ChainLink) {
this.returnValue = this.parameters("values").aggregate.filter(function (value) {
return parseInt(value);
});

this.parameters("memoryStore").mergeKeyValues.filter(function (value) {
var newValue = parseInt(value);
if (newValue) {
return newValue;
} else {
return value;
}
});
}
}]);

Expand All @@ -46,7 +55,19 @@ describe(".parameters.filter(filterFunction)", function () {
numbers.returnValue.should.eql(numbers.parameterCollections()[0]);
});

it("should transform values based upon the filter function return value", function () {
it("should transform raw values", function () {
numbers.values("1").values("2").values("3").values().should.have.members([1, 2, 3]);
});

it("should transform parameters with merged key values", function () {
numbers.memoryStore({
"1": "2",
"3": "4",
"bob": "belcher"
}).memoryStore().should.eql({
"1": 2,
"3": 4,
"bob": "belcher"
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var Person = function (_ChainLink) {
_createClass(Person, [{
key: "initialize",
value: function initialize() {
this.parameters("answers").mergeKeyValues;
this.returnValue = this.parameters("answers").mergeKeyValues;
}
}]);

Expand Down Expand Up @@ -56,7 +56,7 @@ describe(".parameters.mergeKeyValues", function () {
});

it("should return this to enable chaining after setting a value", function () {
person.answers(answersOne).should.equal(person);
person.returnValue.should.eql(person.parameterCollections()[0]);
});

it("should save aggregate the values of multiple calls", function () {
Expand Down
6 changes: 6 additions & 0 deletions es6/lib/chainLink/parameterCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ export default class ParameterCollection {
for (let valueKey in valueCollection) {
let value = valueCollection[valueKey];

_.filters.forEach(filter => {
value = filter(value);
});

parameterValues[valueKey] = value;
}
return _.parentLink;
Expand All @@ -132,5 +136,7 @@ export default class ParameterCollection {
}
};
});

return this;
}
}
28 changes: 27 additions & 1 deletion es6/spec/chainLink/chainLink.parameters.filter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ class Numbers extends ChainLink {
this.returnValue = this.parameters("values")
.aggregate
.filter(value => parseInt(value));

this.parameters("memoryStore")
.mergeKeyValues
.filter(value => {
const newValue = parseInt(value);
if (newValue) {
return newValue;
} else {
return value;
}
});
}
}

Expand All @@ -19,12 +30,27 @@ describe(".parameters.filter(filterFunction)", () => {
numbers.returnValue.should.eql(numbers.parameterCollections()[0]);
});

it("should transform values based upon the filter function return value", () => {
it("should transform raw values", () => {
numbers
.values("1")
.values("2")
.values("3")
.values()
.should.have.members([1, 2, 3]);
});

it("should transform parameters with merged key values", () => {
numbers
.memoryStore({
"1": "2",
"3": "4",
"bob": "belcher"
})
.memoryStore()
.should.eql({
"1": 2,
"3": 4,
"bob": "belcher"
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ChainLink from "../../lib/chainLink/chainLink.js";

class Person extends ChainLink {
initialize() {
this.parameters("answers").mergeKeyValues;
this.returnValue = this.parameters("answers").mergeKeyValues;
}
}

Expand All @@ -29,7 +29,7 @@ describe(".parameters.mergeKeyValues", () => {
});

it("should return this to enable chaining after setting a value", () => {
person.answers(answersOne).should.equal(person);
person.returnValue.should.eql(person.parameterCollections()[0]);
});

it("should save aggregate the values of multiple calls", () => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mrt",
"version": "0.1.8",
"version": "0.1.9",
"description": "Build complex interfaces with ease.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 95da7b6

Please sign in to comment.