init: function(){ arguments.callee.base.apply(this,arguments); // depending on version we make a different selection of frameworks var v = this.version? this.version.split("."): this.get('defaultVersion').split("."); var isOldSC = parseInt(v[1],10) <= 4; // under 1.5.0 if(!this.combineScripts){ tools.log('WARNING: Sproutcore has combineScripts set to false. Be aware of side effects, the Test Application will not be able to run.'); } if(!this.frameworkNames){ if(isOldSC){ this.frameworkNames = "bootstrap jquery runtime foundation datastore desktop animation testing".split(" ") .map(function(fn){ return "frameworks/" + fn; }); } else this.frameworkNames = this.defaultFrameworkNames; } if(this.theme === 'sc-theme' || this.theme === 'ace' || this.theme === 'iphone'){ if(this.theme === "sc-theme"){ if(isOldSC) this.frameworkNames.push("themes/empty_theme","themes/standard_theme"); else this.frameworkNames.push("themes/empty_theme","themes/legacy_theme"); } if(this.theme === 'ace'){ this.frameworkNames.push("themes/empty_theme","themes/ace"); } if(this.theme === 'iphone'){ this.frameworkNames.push('themes/empty_theme','themes/iphone_theme'); } if(parseInt(v[1],10) >= 5){ // above 1.5.0) this.frameworkNames.push('frameworks/yuireset'); } } //tools.log('garconlibdir: ' + tools.lib_dir); if(!this.pathsToExclude){ this.pathsToExclude = [/fixtures\//]; } else { if(SC.typeOf(this.pathsToExclude) === 'array'){ this.pathsToExclude.push(new RegExp(/fixtures\//)); } else if(SC.typeOf(this.pathsToExclude) === 'regexp'){ this.pathsToExclude = [this.pathsToExclude]; } } },
Async.exec = function(){ var args = SC.A(arguments); //util.log('args of Async.exec: ' + util.inspect(args)); if(SC.typeOf(args[0]) !== 'function'){ throw new Error("Async.exec expects a function as first parameter"); } return Async.create({ fn: args[0], args: args.slice(1) // the rest of the arguments }); };
readFile: function(path, opts, callback){ if(!callback && opts && SC.typeOf(opts) === 'function'){ callback = opts; opts = undefined; } this.queue({ method: '_readFile', path: path, opts: opts, callback: callback }); },
notify: function(){ var args = SC.A(arguments); var newargs; var target = args[0]; var method = args[1]; if(SC.typeOf(target) === SC.T_FUNCTION){ // there is no target, just a function, so method = args[0]; target = {}; // empty object, or should we do SC as target? newargs = args.slice(1); } else { newargs = args.slice(2); } this.args.push(this._createCallback(target,method,newargs)); this.fn.apply(target,this.args); },
return function(err,result){ SC.RunLoop.begin(); var ret = SC.Object.create({ error: err, isError: err? true: false, result: result }); if(SC.typeOf(method) === SC.T_FUNCTION){ args.unshift(ret); // add the result as first parameter method.apply(target,args); } else { if(SC.instanceOf(target, SC.Statechart)){ target.sendEvent(method,ret,args); } else{ args.unshift(ret); // add the result as first parameter target[method].apply(target,args); } } SC.RunLoop.end(); };