diff --git a/README.md b/README.md index 1b37b9e..567f570 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ meteor-node-csv [node-csv npm](http://www.adaltas.com/projects/node-csv/) wrapped for meteor -Add like so: `meteor add dsyko:meteor-node-csv`. This package exports the global `CSV`. +Add like so: `meteor add dsyko:node-csv-npm`. This package exports the global `CSV`. -Adding this mrt package is equivalent to: +Adding this meteor package is equivalent to: installing the node package ``` diff --git a/package.js b/package.js index 537e55f..b8321aa 100755 --- a/package.js +++ b/package.js @@ -1,20 +1,36 @@ Package.describe({ summary: "node-csv npm packaged for meteor.", - version: "0.3.7", + version: "0.4.5", git: "https://github.com/Dsyko/meteor-node-csv.git", name: "dsyko:node-csv-npm" }); -Package.on_use(function (api) { - if (api.versionsFrom) { - api.versionsFrom("METEOR@0.9.0"); - } +Npm.depends({"csv":"0.4.5"}); + +function configure(api) { + api.versionsFrom("1.0"); +} + +Package.onUse(function (api) { + configure(api); api.addFiles(["lib/node-csv.js"], "server"); - if (typeof api.export !== "undefined") { - api.export("CSV", "server"); - } + api.export("CSV", "server"); + }); -Npm.depends({"csv":"0.3.6"}); \ No newline at end of file + +Package.onTest(function (api) { + configure(api); + + api.use("tinytest@1.0.0"); + api.use("test-helpers@1.0.0"); + api.use("dsyko:node-csv-npm"); + + api.addFiles([ + "tests/callback.js", + "tests/stream.js", + "tests/pipe.js" + ], "server"); +}); diff --git a/tests/callback.js b/tests/callback.js new file mode 100644 index 0000000..d96353c --- /dev/null +++ b/tests/callback.js @@ -0,0 +1,17 @@ +Tinytest.add('NodeCSV - Callback test', function (test) { + + process.stdout.write('----------- Callback example ----------- \n'); + + CSV.generate({seed: 1, columns: 2, length: 20}, function(err, data){ + CSV.parse(data, function(err, data){ + CSV.transform(data, function(data){ + return data.map(function(value){return value.toUpperCase()}); + }, function(err, data){ + CSV.stringify(data, function(err, data){ + process.stdout.write(data); + }); + }); + }); + }); + +}); diff --git a/tests/pipe.js b/tests/pipe.js new file mode 100644 index 0000000..de79b8a --- /dev/null +++ b/tests/pipe.js @@ -0,0 +1,15 @@ +Tinytest.add('NodeCSV - Pipe test', function (test) { + + process.stdout.write('----------- Pipe example ----------- \n'); + + CSV.generate({seed: 1, columns: 2, length: 20}) + .pipe(CSV.parse()) + .pipe(CSV.transform(function(record){ + return record.map(function(value){ + return value.toUpperCase() + }); + })) + .pipe(CSV.stringify ()) + .pipe(process.stdout); + +}); diff --git a/tests/stream.js b/tests/stream.js new file mode 100644 index 0000000..b47abaa --- /dev/null +++ b/tests/stream.js @@ -0,0 +1,36 @@ +Tinytest.add('NodeCSV - Stream test', function (test) { + + process.stdout.write('----------- Stream example ----------- \n'); + + var generator = CSV.generate({seed: 1, columns: 2, length: 20}); + var parser = CSV.parse(); + var transformer = CSV.transform(function(data){ + return data.map(function(value){return value.toUpperCase()}); + }); + var stringifier = CSV.stringify(); + + generator.on('readable', function(){ + while(data = generator.read()){ + parser.write(data); + } + }); + + parser.on('readable', function(){ + while(data = parser.read()){ + transformer.write(data); + } + }); + + transformer.on('readable', function(){ + while(data = transformer.read()){ + stringifier.write(data); + } + }); + + stringifier.on('readable', function(){ + while(data = stringifier.read()){ + process.stdout.write(data); + } + }); + +}); diff --git a/versions.json b/versions.json deleted file mode 100644 index 2537c0d..0000000 --- a/versions.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "dependencies": [ - [ - "meteor", - "1.0.2" - ], - [ - "underscore", - "1.0.0" - ] - ], - "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.26", - "format": "1.0" -} \ No newline at end of file