Permalink
Browse files

added support for events.moved interfaces into config.

  • Loading branch information...
AnalogJ committed Jul 27, 2014
1 parent ecd360a commit 63254d41048e72b6a87c1ac386eb349db611bcc6
View
@@ -43,15 +43,21 @@ FileFog.prototype.init = function() {
FileFog.prototype.use = function(name, provider_definition,config) {
if(!provider_definition || !provider_definition.provider || !provider_definition.transform || !provider_definition.client || !provider_definition.config){
throw new Error("Could not register provider, it is invalid.")
var message = ""
if(!provider_definition) {message+=" Provider Definition is null or undefined."}
if(!provider_definition.provider) {message+=" Provider is null or undefined."}
if(!provider_definition.transform) {message+=" Transform is null or undefined."}
if(!provider_definition.client) {message+=" Client is null or undefined."}
if(!provider_definition.config) {message+=" Config is null or undefined."}
throw new Error("Could not register provider, it is invalid." + message)
}
else if(!name){
throw new Error("Provider name is missing")
}
config = extend(true, {interfaces:provider_definition.provider.prototype.interfaces },provider_definition.config, config);
config = extend(true,provider_definition.config, config);
delete provider_definition.config;
delete provider_definition.provider.prototype.interfaces;
this._provider_definitions[name] = {
classes:provider_definition,
@@ -240,5 +240,17 @@ module.exports = function(name,base_client,transform, provider_config, credentia
}
if(provider_config.interfaces.indexOf("events") != -1) {
ClientWrapper.prototype.events = function (cursor,provider_options,filefog_options) {
filefog_options = extend(true, {}, this.filefog_options, filefog_options|| {});
return this._methodWrapper("events",arguments,filefog_options);
}
}
return new ClientWrapper(name,transform,provider_config, credentials, filefog_options)
}
View
@@ -2,7 +2,7 @@
"author": "Jason Kulatunga",
"name": "filefog",
"description": "Cloud Storage API Wrapper supporting Box, Dropbox, Skydrive, Google Drive",
"version": "0.0.17",
"version": "0.0.18",
"repository": {
"url": "https://github.com/filefog/filefog.git"
},
View
@@ -69,24 +69,22 @@ describe('#use()', function () {
describe("#provider()",function(){
var provider
var Provider = function(){};
Provider.prototype.interfaces = [];
before(function(){
var definition = {
/**
* Description
* @method provider
* @return
*/
provider : Provider,
provider : function(){},
transform: {},
/**
* Description
* @method client
* @return
*/
client: function(){},
config: {}
config: {interfaces: []}
}
provider = FileFog.use("empty",definition,{})
});
@@ -3,24 +3,22 @@ var FileFog = require('../../lib/main.js');
describe("ClientWrapper",function(){
var clientPromise;
var Provider = function(){};
Provider.prototype.interfaces = [];
before(function(){
var base_classes = {
/**
* Description
* @method provider
* @return
*/
provider : Provider,
provider : function(){},
transform: {},
/**
* Description
* @method client
* @return
*/
client: function(){},
config: {}
config: {interfaces:[]}
}
FileFog.use("empty",base_classes);
clientPromise = FileFog.client("empty");
@@ -3,24 +3,22 @@ var FileFog = require('../../lib/main.js');
describe("ProviderWrapper",function(){
var provider;
var Provider = function(){};
Provider.prototype.interfaces = [];
before(function(){
var base_classes = {
/**
* Description
* @method provider
* @return
*/
provider : Provider,
provider : function(){},
transform: {},
/**
* Description
* @method client
* @return
*/
client: function(){},
config: {}
config: {interfaces:[]}
}
FileFog.use("empty",base_classes);
provider = FileFog.provider("empty");

0 comments on commit 63254d4

Please sign in to comment.