if (1 == 2) { // it ('should allow logging to action.', function (allDone) { // /* // tm.will.run ('some simple action', function () { // }) // .now (); // // tm.will.have (player).run ('some simple action', function () { // }) // ira a fulton // // player.will.run.action ('some action 1', {...}) // .then.run.action ('some action 2', {...}) // .then.run.action ('some action 3', {...}) // .then.run.action ('some action 4', {...}) // // tm.will.have ('test.Logging').run.action ('test log 1', {...}) // .then.run ('finish', function (action) { // ... // action.will.have (player).run.action ('some action 1', {...}) // .then.run.action ('some action 2', {...}) // .then.run.action ('some action 2', {...}) // .then.run.action ('some action 3', {...}) // .then.run ('some action 3', {...}) // }) // .begin () // .start () // // */ // // // a.action = tm.will.have ('test.Logging', 'test log 1') // // .then ('finish', function () { // // tm.log ('*** here ***'); // // }) // // // // expect (a.action.getInfo ('type')).to.equal ('trg.tm.chirp.SimpleAction'); // // // tm.log ('type:', a.action.getInfo ('type')); // // a.action = tm.will.have ('test.Logging', 'test log 1') // // .then ('finish', function (action) { // // var data; // // // // data = action.getData (); // // expect (data.testLog1Run).to.equal (true); // // allDone (); // // }); // }); // it ('should allow running simple actions.', function (allDone) { // a = {}; // // a.action = tm.will.have ('test.Logging', 'test simple action') // .then ('finish', function (action) { // tm.log ('***** what here? *****') // allDone (); // }) // }) // it ('should allow logging of child actions with the "then" keyword.', function (allDone) { // a = {}; // // a.action = tm.will.have ('test.Logging', 'test action log') // .then ('finish test.', function (action) { // allDone (); // }) // }) // .will.have ('test.Logging') // .run.action ('test log 1') // action.will.have ('test.Logging').run.action ('test log 1') // .then.run (function () { // // }) // a.action = tm.will.have ({ // type: 'test.Logging', // config: { // name: 'Bob Test Log Object' // } // }, // 'test log 1', { // data: { // name: 'bob', // age: 32 // } // }) // .then ('Here we go again', function () { // tm.log ('here we are again...') // }) // // a.action.then ('Did bobby do something?', function () { // tm.log ('bobby no...') // }) // if (1 == 2) { // tm.will.have ({type: 'test.Logging', config: {name: 'Bob is a person'}}, 'test log 1', function (action) {}); // tm.will.have ('test.Logging', 'test log 1', function (action) {}); // // action.will.have (player, 'test log 1', function (action) { // // ... // }) // .then.will ('test log 2', function () { // // ... // }) // .then.will.have (user, 'test log 3', function () { // // ... // }) // .then.will ('test log 4', function () { // // ... // }) // // tm.will.have ('test.Logging', 'test log 1', function (action) { // // ... // }) // .then.will.have ('@target', 'test log 2', function () { // // ... // }) // .then.will ('test log 3', function () {}) // .then.will ('test log 4', function () {}) // } // tm.emit (tm, 'new', {value: 1, age: 32, name: 'cool man'}) // tm.emit (tm, 'new', {value: 1, age: 32, name: 'cool man'}) // tm.emit (bob, 'attack', {value: 1, age: 32, name: 'cool man'}) } // NOTE: ------------------------------------------ // NOTE: ------------------------------------------ // NOTE: ------------------------------------------ 'use strict'; tm.add ('trg.tm.chirp.ActionOld2', ['trg.tm.chirp.BaseAction'], function (o, p, d) { p.nextParentListener = function (parent) { var index, list; if (parent && parent.extendsFrom ('trg.tm.chirp.Listener')) { // No child listeners, move onto the next sibling. list = parent.getChildList (); index = list.indexOf (d.current.listener); if (index < (list.length - 1)) { d.current.routeIndex = 0; d.current.listener = list [index + 1]; o.next (); } else { p.nextParentListener (parent.getParent ()); } } else { p.allDone (); } } p.concatDoneList = function () { } o.setup = function (config) { var logger, parent; if (!config.data) { config.data = {}; } d.child.index = 0; d.target = config.target; d.sync = config.sync; d.listener = tm.new ('trg.tm.chirp.Listener'); d.listener.add ('root', config.target.getListener ()); d.current = {} if (config.listen) { o.addListener (config.listen); } // o.add ('processing action', tm.new ('trg.tm.chirp.SimpleAction', {logger: d.logger})); o.add ('post action', tm.new ('trg.tm.chirp.SimpleAction', {logger: d.logger})); } o.addListener = function (data) { var item, key, list, listener; list = data; for (key in list) { item = list [key]; listener = tm.new ('trg.tm.chirp.Listener'); listener.listen (key, item); d.listener.add (listener); } } o.done = function () { d.current.routeIndex++; o.next (); } o.getRouteIndex = function () { return d.current.routeIndex; } o.getListener = function () { return d.listener; } o.getTarget = function () { return d.target; } o.next = function () { d.current.listener.next (o); } o.nextListener = function () { var list, parent; // Check if the current listener has child listeners. list = d.current.listener.getChildList (); if (list.length) { d.current.listener = list [0]; d.current.routeIndex = 0; o.next (); } else { p.nextParentListener (d.current.listener.getParent ()); } } o.reset = function () { d.current.listener = d.listener; d.current.routeIndex = 0; } o.run = function () { o.reset (); o.next (); } o.then = function (name, func) { o.log ('*** here was the end ***'); tm.log ('*** then action simple') return o; } }); 'use strict'; tm.add ('trg.tm.chirp.action.Stack2', ['trg.tm.Object'], function (o, p, d) { p.next = function () { } o.setup = function (config) { // Add logger. if (config.logger) { d.logger = config.logger; } else { d.logger = tm.new ('trg.tm.logger.Log', { name: d.name, }); } } o.run = function () { d.loop = tm.new ('trg.tm.Iterator', { list: d.child.list, process: function (item, done) { p.next (item, done); }, done: function () { var parent; // Kill the stack and it's objects. // o._kill (); // Call the parent stack object. parent = o.getParent (); if (parent.extendsFrom ('trg.tm.chirp.action.Stack')) { // Have parent run the next item. } } }); } }); 'use strict'; tm.add ('trg.tm.chirp.BaseAction', ['trg.tm.Object'], function (o, p, d) { // p.allDone = function () { // if (d.child.list.length) { // o.loop (d.child.list, function (item, done) { // d.child.index++; // item.run (done); // // tm.log ('*** hmmm:', item.getName ()) // }) // } // } p.allDone = function () { var item; o.log ('*** here was the end ***'); tm.log ('*** then action simple'); item = d.child.list [d.child.index]; if (item) { item.run (function () { o.log ('****** blam:', item.getInfo ('id')); }); // if (d.child.list.length) { // o.loop (d.child.list, function (item, done) { // d.child.index++; // item.run (done); // // tm.log ('*** hmmm:', item.getName ()) // }) // } } } o.setup = function (config) { if (!config.data) { config.data = {}; } d.data = config.data; // Add logger. d.child.index = 0; if (config.logger) { d.logger = config.logger; } else { d.logger = tm.new ('trg.tm.logger.Log', { name: d.name, }); } } o.getData = function () { return d.data; } o.log = function () { var list; list = Array.prototype.slice.call (arguments); d.logger.log (list); } // o.then = function (name, func) { // if (tm.getType (name) == 'Function') { // func = name; // name = ''; // } // // o.add (tm.new ('trg.tm.chirp.SimpleAction', { // name: name, // func: func, // logger: d.logger, // data: d.data, // })) // // // tm.log ('name:', name); // // tm.log ('index:', d.child.index); // // tm.log ('length:', d.child.list.length); // // if (d.child.index <= d.child.list.length) { // p.allDone (); // } // return o; // } o.will = function (name, func) { if (tm.getType (name) == 'Function') { func = name; name = ''; } o.add (tm.new ('trg.tm.chirp.SimpleAction', { name: name, func: func, logger: d.logger, data: d.data, })) // tm.log ('name:', name); // tm.log ('index:', d.child.index); tm.log ('length:', d.child.list.length); // if (d.child.index <= d.child.list.length) { // p.allDone (); // } return o; } }); 'use strict'; tm.add ('trg.tm.chirp.SimpleAction2', ['trg.tm.chirp.BaseAction'], function (o, p, d) { o.setup = function (config) { if (!config.name) { d.name = d.name + 'anonymous action'; } d.func = config.func; } o.run = function (done) { var list, name, parent; list = tm.getFuncParams (d.func); name = d.name; if (name == 'anonymous action') { parent = o.getParent (); name = parent.getName () + ', ' + name; } o.log ('then:', name); o.log ('func param:', list.length); o.log ('*** here was the end ***'); if (d.func) { // if (list.length > 1) { // o.log ('here....'); // d.func (o, done); // } // else { // d.func (o); // done (); // } } else { o.log ('children total:', d.child.list.length) // p.allDone (); } } o.then = function (name, func) { if (tm.getType (name) == 'Function') { func = name; name = ''; } o.add (tm.new ('trg.tm.chirp.SimpleAction', { name: name, func: func, logger: d.logger, data: d.data, })) // tm.log ('name:', name); // tm.log ('index:', d.child.index); // tm.log ('length:', d.child.list.length); // if (d.child.index <= d.child.list.length) { // p.allDone (); // } return o; } }); 'use strict'; tm.add ('trg.tm.chirp.Action', ['trg.tm.chirp.BaseAction'], function (o, p, d) { p.nextParentListener = function (parent) { var index, list; if (parent && parent.extendsFrom ('trg.tm.chirp.Listener')) { // No child listeners, move onto the next sibling. list = parent.getChildList (); index = list.indexOf (d.current.listener); if (index < (list.length - 1)) { d.current.routeIndex = 0; d.current.listener = list [index + 1]; o.next (); } else { p.nextParentListener (parent.getParent ()); } } else { p.allDone (); } } p.concatDoneList = function () { } o.setup = function (config) { var logger, parent; if (!config.data) { config.data = {}; } d.child.index = 0; d.target = config.target; d.sync = config.sync; d.listener = tm.new ('trg.tm.chirp.Listener'); d.listener.add ('root', config.target.getListener ()); d.current = {} if (config.listen) { o.addListener (config.listen); } // o.add ('processing action', tm.new ('trg.tm.chirp.SimpleAction', {logger: d.logger})); o.add ('post action', tm.new ('trg.tm.chirp.SimpleAction', {logger: d.logger})); } o.addListener = function (data) { var item, key, list, listener; list = data; for (key in list) { item = list [key]; listener = tm.new ('trg.tm.chirp.Listener'); listener.listen (key, item); d.listener.add (listener); } } o.done = function () { d.current.routeIndex++; o.next (); } o.getRouteIndex = function () { return d.current.routeIndex; } o.getListener = function () { return d.listener; } o.getTarget = function () { return d.target; } o.next = function () { d.current.listener.next (o); } o.nextListener = function () { var list, parent; // Check if the current listener has child listeners. list = d.current.listener.getChildList (); if (list.length) { d.current.listener = list [0]; d.current.routeIndex = 0; o.next (); } else { p.nextParentListener (d.current.listener.getParent ()); } } o.reset = function () { d.current.listener = d.listener; d.current.routeIndex = 0; } o.run = function () { o.reset (); o.next (); } o.then = function (name, func) { o.log ('*** here was the end ***'); tm.log ('*** then action simple') return o; } }) 'use strict'; tm.add ('trg.tm.chirp.Listener', ['trg.tm.Object'], function (o, p, d) { p.addRouteFromList = function (name, list) { var end, i, item, key, list; end = list.length; for (i = 0; i < end; i++) { item = list [i]; d.router.addRoute (name, item); } } o.setup = function (config) { // p.addDataKey ('router'); // d.root = config.root; // Will have a set of child routes tied to an alias // d.child.alias ['click'] = [RouteList]; d.router = tm.new ('trg.tm.chirp.Router'); } o.getRouter = function () { return d.router; } o.listen = function (name, config) { var type; type = tm.getType (config); switch (type) { case 'Function': case 'Object': d.router.addRoute (name, config); break; case 'Array': p.addRouteFromList (name, config); break; } } o.next = function (action) { d.router.next (action); } }) 'use strict'; tm.add ('trg.tm.chirp.Route', ['trg.tm.Object'], function (o, p, d) { o.setup = function (config) { var list; d.method = config.method; list = tm.getFuncParams (d.method); if (list.length > 1) { d.async = true; } } o.isAsync = function () { if (d.async) { return true; } return false; } o.run = function (action) { if (!d.async) { d.method.apply (o, [action]); action.done (); } else { d.method.apply (o, [action, function () { action.done (); }]); } } }) 'use strict'; tm.add ('trg.tm.chirp.RouteList', ['trg.tm.Object'], function (o, p, d) { o.setup = function (config) { d.index = 0; } o.next = function (action) { var item; item = d.child.list [action.getRouteIndex ()]; if (item) { item.run (action); } else { action.nextListener (); } } }) 'use strict'; tm.add ('trg.tm.chirp.Router', ['trg.tm.Object'], function (o, p, d) { o.setup = function (config) { } o.addRoute = function (name, config) { var routeList; // Ensure a route list exists. if (name && config) { routeList = o.getChild (name); if (!routeList) { routeList = o.add (name, tm.new ('trg.tm.chirp.RouteList')); } if (tm.getType (config) == 'Function') { routeList.add (tm.new ('trg.tm.chirp.Route', {method: config})); } else { routeList.add (tm.new ('trg.tm.chirp.Route', config)); } } } o.next = function (action) { var name, routeList; name = action.getName (); routeList = o.getChild (name); if (routeList) { routeList.next (action); } else { action.nextListener (); } } }) // if (d.stack.list.length) { // tm.new ('trg.tm.Iterator', { // index: d.stack.index, // list: d.stack.list, // process: function (item, done) { // var name, list; // // // Increment where in the done stack we are at. // d.stack.index++; // // list = tm.getFuncParams (item.method); // // name = d.name + ', [No named action]'; // if (item.name) { // name = item.name; // } // o.log ('then:', name); // // o.log ('func param:', list.length); // // if (list.length > 1) { // item.method (o, done); // } // else { // item.method (o); // done (); // } // }, // done: function () { // // o._kill (); // } // }); // } // p.allDone = function () { // // if (d.done) { // // d.done.apply (o, [o]); // // } // // // console.log ('*** werwd?:', d.doneList); // if (d.doneList.length) { // tm.new ('trg.tm.Iterator', { // index: d.doneIndex, // list: d.doneList, // process: function (item, done) { // var name, list; // // // Increment where in the done stack we are at. // d.doneIndex++; // // list = tm.getFuncParams (item.method); // // name = '[No named action]'; // if (item.name) { // name = item.name; // } // o.log ('then:', name); // // o.log ('func param:', list.length); // // if (list.length > 1) { // item.method (o, done); // } // else { // item.method (o); // done (); // } // }, // done: function () { // // o._kill (); // } // }); // } // } 'use strict'; tm.add ('trg.tm.chirp.ActionOld', ['trg.tm.chirp.BaseAction'], function (o, p, d) { p.nextParentListener = function (parent) { var index, list; if (parent && parent.extendsFrom ('trg.tm.chirp.Listener')) { // No child listeners, move onto the next sibling. list = parent.getChildList (); index = list.indexOf (d.current.listener); if (index < (list.length - 1)) { d.current.routeIndex = 0; d.current.listener = list [index + 1]; o.next (); } else { p.nextParentListener (parent.getParent ()); } } else { p.allDone (); } } p.concatDoneList = function () { } o.setup = function (config) { var logger, parent; if (!config.data) { config.data = {}; } d.child.index = 0; d.target = config.target; d.sync = config.sync; d.listener = tm.new ('trg.tm.chirp.Listener'); d.listener.add ('root', config.target.getListener ()); d.current = {} if (config.listen) { o.addListener (config.listen); } // o.add ('processing action', tm.new ('trg.tm.chirp.SimpleAction', {logger: d.logger})); o.add ('post action', tm.new ('trg.tm.chirp.SimpleAction', {logger: d.logger})); } o.addListener = function (data) { var item, key, list, listener; list = data; for (key in list) { item = list [key]; listener = tm.new ('trg.tm.chirp.Listener'); listener.listen (key, item); d.listener.add (listener); } } o.done = function () { d.current.routeIndex++; o.next (); } o.getRouteIndex = function () { return d.current.routeIndex; } o.getListener = function () { return d.listener; } o.getTarget = function () { return d.target; } o.next = function () { d.current.listener.next (o); } o.nextListener = function () { var list, parent; // Check if the current listener has child listeners. list = d.current.listener.getChildList (); if (list.length) { d.current.listener = list [0]; d.current.routeIndex = 0; o.next (); } else { p.nextParentListener (d.current.listener.getParent ()); } } o.reset = function () { d.current.listener = d.listener; d.current.routeIndex = 0; } o.run = function () { o.reset (); o.next (); } o.then = function (name, func) { o.log ('*** here was the end ***'); tm.log ('*** then action simple') return o; } }) 'use strict'; tm.add ('trg.tm.chirp.CallStack', function (o, p, d) { p.allDone = function () { if (d.stack.list.length) { tm.new ('trg.tm.Iterator', { index: d.stack.index, list: d.stack.list, process: function (item, done) { var name, list; // Increment where in the done stack we are at. d.stack.index++; list = tm.getFuncParams (item.method); name = d.name + ', [No named action]'; if (item.name) { name = item.name; } o.log ('then:', name); // o.log ('func param:', list.length); if (list.length > 1) { item.method (o, done); } else { item.method (o); done (); } }, done: function () { // o._kill (); } }); } } o.setup = function (config) { var logger, parent, type; d.stack = { index: 0, list: [], } d.stack.index = 0; d.stack.list = []; // // Add the final callback. // if (config.done) { // type = tm.getType (config.done); // if (type == 'Array') { // d.stack.list.concat (config.done); // } // else if (type == 'Function') { // o.will ('"' + d.name + '" action all done.', config.done); // } // } // Add logger. d.logger = tm.new ('trg.tm.logger.Log', { name: d.name, }); } o.then = function (name, done) { if (tm.getType (name) == 'Function') { done = name; name = ''; } d.stack.list.push ({name: name, method: done}); // if (d.stack.list.length >= d.stack.index) { if (d.stack.index <= d.stack.list.length) { p.allDone (); } return o; } o.will = o.then; // o.will = function (name, done) { // if (tm.getType (name) == 'Function') { // done = name; // name = ''; // } // // d.stack.list.push ({name: name, method: done}); // // o.log ('*** length:', d.doneList.length); // // o.log ('*** index:', d.doneIndex); // // if (d.doneList.length >= d.doneIndex) { // if (d.stack.index >= d.stack.list.length) { // p.allDone (); // } // return o; // }; }); // p.setKeyword = function (keyword, func) { // var end, i, item, key, list; // // // Add semantic command sequence keywords. // list = keyword.split (' '); // end = list.length; // keyword = {}; // // for (i = 0; i < end; i++) { // item = list [i]; // keyword [item] = func; // } // // tm.merge ({ // source: keyword, // target: o, // }); // // tm.merge ({ // source: keyword, // target: func, // }); // } // p.setKeyword ('action have run then will', function (name, func) { // var action; // // action = tm.new ('trg.tm.chirp.action.Action', { // name: name, // func: func, // }); // // if (o.extendsFrom ('trg.tm.chirp.action.Action')) { // o.add (action); // } // return action; // }); // o.setup = function () { // // o.setKeyword () // } // will.have = function (data) { // } // tm.setPlugin ('addSequenceCommands', addSequenceCommands); // will = function (name, config) { // } // // will.have = function (target, name, config) { // var action, type; // // type = tm.getType (target); // switch (type) { // case 'String': // target = tm.new (target); // break; // // case 'Object': // if (!target.getType) { // target = tm.new (target.type, target.config); // } // break; // default: // throw new Error ('Tamed event emitter must have a target or type string specified.'); // return; // } // action = tm.emit (target, name, config); // return action.getChild ('post action'); // } // o.now = function (allDone) { // d.logger.start (); // o.loop (d.child.list, function (item, done) { // var list, type; // // // type = tm.getType (item); // switch (type) { // case 'Function': // list = tm.getFuncParams (item); // // if (list.length > 1) { // item (o, done); // } // else { // item (o); // done (); // } // break; // // default: // if (item.now) { // item.now (done); // } // } // }, function () { // p.log ({type: 'log', label: 'done:', value: d.name}); // if (allDone) { allDone (); } // // // Unload this object. // // o._kill (); // }) // }