10
__coverage__['build/datasource-local/datasource-local.js'] = {"path":"build/datasource-local/datasource-local.js","s":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0},"b":{"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0],"7":[0,0],"8":[0,0],"9":[0,0],"10":[0,0],"11":[0,0],"12":[0,0]},"f":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":47}}},"2":{"name":"(anonymous_2)","line":28,"loc":{"start":{"line":28,"column":10},"end":{"line":28,"column":21}}},"3":{"name":"(anonymous_3)","line":95,"loc":{"start":{"line":95,"column":19},"end":{"line":95,"column":40}}},"4":{"name":"(anonymous_4)","line":122,"loc":{"start":{"line":122,"column":17},"end":{"line":122,"column":34}}},"5":{"name":"(anonymous_5)","line":131,"loc":{"start":{"line":131,"column":17},"end":{"line":131,"column":28}}},"6":{"name":"(anonymous_6)","line":265,"loc":{"start":{"line":265,"column":19},"end":{"line":265,"column":31}}},"7":{"name":"(anonymous_7)","line":300,"loc":{"start":{"line":300,"column":16},"end":{"line":300,"column":28}}},"8":{"name":"(anonymous_8)","line":342,"loc":{"start":{"line":342,"column":20},"end":{"line":342,"column":32}}},"9":{"name":"(anonymous_9)","line":374,"loc":{"start":{"line":374,"column":17},"end":{"line":374,"column":35}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":398,"column":37}},"2":{"start":{"line":26,"column":0},"end":{"line":30,"column":2}},"3":{"start":{"line":29,"column":4},"end":{"line":29,"column":58}},"4":{"start":{"line":37,"column":0},"end":{"line":112,"column":3}},"5":{"start":{"line":96,"column":8},"end":{"line":98,"column":35}},"6":{"start":{"line":100,"column":8},"end":{"line":100,"column":54}},"7":{"start":{"line":102,"column":8},"end":{"line":105,"column":9}},"8":{"start":{"line":103,"column":12},"end":{"line":103,"column":42}},"9":{"start":{"line":104,"column":12},"end":{"line":104,"column":54}},"10":{"start":{"line":107,"column":8},"end":{"line":110,"column":9}},"11":{"start":{"line":109,"column":12},"end":{"line":109,"column":30}},"12":{"start":{"line":114,"column":0},"end":{"line":393,"column":3}},"13":{"start":{"line":123,"column":8},"end":{"line":123,"column":27}},"14":{"start":{"line":148,"column":8},"end":{"line":148,"column":91}},"15":{"start":{"line":172,"column":8},"end":{"line":172,"column":85}},"16":{"start":{"line":206,"column":9},"end":{"line":206,"column":94}},"17":{"start":{"line":266,"column":8},"end":{"line":267,"column":35}},"18":{"start":{"line":270,"column":8},"end":{"line":272,"column":9}},"19":{"start":{"line":271,"column":12},"end":{"line":271,"column":64}},"20":{"start":{"line":274,"column":8},"end":{"line":274,"column":28}},"21":{"start":{"line":275,"column":8},"end":{"line":275,"column":35}},"22":{"start":{"line":301,"column":8},"end":{"line":307,"column":35}},"23":{"start":{"line":309,"column":8},"end":{"line":309,"column":36}},"24":{"start":{"line":310,"column":8},"end":{"line":310,"column":39}},"25":{"start":{"line":344,"column":8},"end":{"line":344,"column":39}},"26":{"start":{"line":375,"column":8},"end":{"line":376,"column":22}},"27":{"start":{"line":378,"column":8},"end":{"line":378,"column":32}},"28":{"start":{"line":380,"column":8},"end":{"line":380,"column":51}},"29":{"start":{"line":382,"column":8},"end":{"line":388,"column":11}},"30":{"start":{"line":391,"column":8},"end":{"line":391,"column":19}},"31":{"start":{"line":395,"column":0},"end":{"line":395,"column":42}}},"branchMap":{"1":{"line":96,"type":"binary-expr","locations":[{"start":{"line":96,"column":24},"end":{"line":96,"column":28}},{"start":{"line":96,"column":32},"end":{"line":96,"column":42}}]},"2":{"line":97,"type":"binary-expr","locations":[{"start":{"line":97,"column":23},"end":{"line":97,"column":32}},{"start":{"line":97,"column":36},"end":{"line":97,"column":53}}]},"3":{"line":100,"type":"binary-expr","locations":[{"start":{"line":100,"column":25},"end":{"line":100,"column":32}},{"start":{"line":100,"column":36},"end":{"line":100,"column":52}}]},"4":{"line":102,"type":"if","locations":[{"start":{"line":102,"column":8},"end":{"line":102,"column":8}},{"start":{"line":102,"column":8},"end":{"line":102,"column":8}}]},"5":{"line":104,"type":"binary-expr","locations":[{"start":{"line":104,"column":23},"end":{"line":104,"column":32}},{"start":{"line":104,"column":36},"end":{"line":104,"column":53}}]},"6":{"line":107,"type":"if","locations":[{"start":{"line":107,"column":8},"end":{"line":107,"column":8}},{"start":{"line":107,"column":8},"end":{"line":107,"column":8}}]},"7":{"line":270,"type":"if","locations":[{"start":{"line":270,"column":8},"end":{"line":270,"column":8}},{"start":{"line":270,"column":8},"end":{"line":270,"column":8}}]},"8":{"line":304,"type":"cond-expr","locations":[{"start":{"line":304,"column":48},"end":{"line":304,"column":52}},{"start":{"line":304,"column":55},"end":{"line":304,"column":61}}]},"9":{"line":305,"type":"cond-expr","locations":[{"start":{"line":305,"column":31},"end":{"line":305,"column":35}},{"start":{"line":305,"column":38},"end":{"line":305,"column":40}}]},"10":{"line":378,"type":"binary-expr","locations":[{"start":{"line":378,"column":18},"end":{"line":378,"column":25}},{"start":{"line":378,"column":29},"end":{"line":378,"column":31}}]},"11":{"line":380,"type":"binary-expr","locations":[{"start":{"line":380,"column":20},"end":{"line":380,"column":30}},{"start":{"line":380,"column":34},"end":{"line":380,"column":50}}]},"12":{"line":387,"type":"binary-expr","locations":[{"start":{"line":387,"column":17},"end":{"line":387,"column":28}},{"start":{"line":387,"column":32},"end":{"line":387,"column":34}}]}},"code":["(function () { YUI.add('datasource-local', function (Y, NAME) {","","/**"," * The DataSource utility provides a common configurable interface for widgets to"," * access a variety of data, from JavaScript arrays to online database servers."," *"," * @module datasource"," * @main datasource"," */","","/**"," * Provides the base DataSource implementation, which can be extended to"," * create DataSources for specific data protocols, such as the IO Utility, the"," * Get Utility, or custom functions."," *"," * @module datasource"," * @submodule datasource-local"," */","","/**"," * Base class for the DataSource Utility."," * @class DataSource.Local"," * @extends Base"," * @constructor"," */","var LANG = Y.Lang,","","DSLocal = function() {"," DSLocal.superclass.constructor.apply(this, arguments);","};",""," /////////////////////////////////////////////////////////////////////////////"," //"," // DataSource static properties"," //"," /////////////////////////////////////////////////////////////////////////////","Y.mix(DSLocal, {"," /**"," * Class name."," *"," * @property NAME"," * @type String"," * @static"," * @final"," * @value \"dataSourceLocal\""," */"," NAME: \"dataSourceLocal\",",""," /////////////////////////////////////////////////////////////////////////////"," //"," // DataSource Attributes"," //"," /////////////////////////////////////////////////////////////////////////////",""," ATTRS: {"," /**"," * @attribute source"," * @description Pointer to live data."," * @type MIXED"," * @default null"," */"," source: {"," value: null"," }"," },",""," /**"," * Global transaction counter."," *"," * @property _tId"," * @type Number"," * @static"," * @private"," * @default 0"," */"," _tId: 0,",""," /**"," * Global in-progress transaction objects."," *"," * @property transactions"," * @type Object"," * @static"," */"," transactions: {},",""," /**"," * Returns data to callback."," *"," * @method issueCallback"," * @param e {EventFacade} Event Facade."," * @param caller {DataSource} Calling DataSource instance."," * @static"," */"," issueCallback: function (e, caller) {"," var callbacks = e.on || e.callback,"," callback = callbacks && callbacks.success,"," payload = e.details[0];",""," payload.error = (e.error || e.response.error);",""," if (payload.error) {"," caller.fire(\"error\", payload);"," callback = callbacks && callbacks.failure;"," }",""," if (callback) {"," //TODO: this should be executed from a specific context"," callback(payload);"," }"," }","});","","Y.extend(DSLocal, Y.Base, {"," /**"," * Internal init() handler."," *"," * @method initializer"," * @param config {Object} Config object."," * @private"," */"," initializer: function(config) {"," this._initEvents();"," },",""," /**"," * This method creates all the events for this module."," * @method _initEvents"," * @private"," */"," _initEvents: function() {"," /**"," * Fired when a data request is received."," *"," * @event request"," * @param e {Event.Facade} Event Facade with the following properties:"," * <dl>"," * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>"," * <dt>request (Object)</dt> <dd>The request.</dd>"," * <dt>callback (Object)</dt> <dd>The callback object"," * (deprecated, refer to <strong>on</strong></dd>"," * <dt>on (Object)</dt> <dd>The map of configured callback"," * functions.</dd>"," * <dt>cfg (Object)</dt> <dd>Configuration object.</dd>"," * </dl>"," * @preventable _defRequestFn"," */"," this.publish(\"request\", {defaultFn: Y.bind(\"_defRequestFn\", this), queuable:true});",""," /**"," * Fired when raw data is received."," *"," * @event data"," * @param e {Event.Facade} Event Facade with the following properties:"," * <dl>"," * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>"," * <dt>request (Object)</dt> <dd>The request.</dd>"," * <dt>callback (Object)</dt> <dd>Deprecated alias for the"," * <strong>on</strong> property</dd>"," * <dt>on (Object)</dt> <dd>The map of configured transaction"," * callbacks. An object with the following properties:"," * <dl>"," * <dt>success (Function)</dt> <dd>Success handler.</dd>"," * <dt>failure (Function)</dt> <dd>Failure handler.</dd>"," * </dl>"," * </dd>"," * <dt>cfg (Object)</dt> <dd>Configuration object.</dd>"," * <dt>data (Object)</dt> <dd>Raw data.</dd>"," * </dl>"," * @preventable _defDataFn"," */"," this.publish(\"data\", {defaultFn: Y.bind(\"_defDataFn\", this), queuable:true});",""," /**"," * Fired when response is returned."," *"," * @event response"," * @param e {Event.Facade} Event Facade with the following properties:"," * <dl>"," * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>"," * <dt>request (Object)</dt> <dd>The request.</dd>"," * <dt>callback (Object)</dt> <dd>Deprecated alias for the"," * <strong>on</strong> property</dd>"," * <dt>on (Object)</dt> <dd>The map of configured transaction"," * callbacks. An object with the following properties:"," * <dl>"," * <dt>success (Function)</dt> <dd>Success handler.</dd>"," * <dt>failure (Function)</dt> <dd>Failure handler.</dd>"," * </dl>"," * </dd>"," * <dt>cfg (Object)</dt> <dd>Configuration object.</dd>"," * <dt>data (Object)</dt> <dd>Raw data.</dd>"," * <dt>response (Object)</dt>"," * <dd>Normalized response object with the following properties:"," * <dl>"," * <dt>results (Object)</dt> <dd>Parsed results.</dd>"," * <dt>meta (Object)</dt> <dd>Parsed meta data.</dd>"," * <dt>error (Boolean)</dt> <dd>Error flag.</dd>"," * </dl>"," * </dd>"," * <dt>error</dt>"," * <dd>Any error that occurred along the transaction lifecycle.</dd>"," * </dl>"," * @preventable _defResponseFn"," */"," this.publish(\"response\", {defaultFn: Y.bind(\"_defResponseFn\", this), queuable:true});",""," /**"," * Fired when an error is encountered."," *"," * @event error"," * @param e {Event.Facade} Event Facade with the following properties:"," * <dl>"," * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>"," * <dt>request (Object)</dt> <dd>The request.</dd>"," * <dt>callback (Object)</dt> <dd>Deprecated alias for the"," * <strong>on</strong> property</dd>"," * <dt>on (Object)</dt> <dd>The map of configured transaction"," * callbacks. An object with the following properties:"," * <dl>"," * <dt>success (Function)</dt> <dd>Success handler.</dd>"," * <dt>failure (Function)</dt> <dd>Failure handler.</dd>"," * </dl>"," * </dd>"," * <dt>cfg (Object)</dt> <dd>Configuration object.</dd>"," * <dt>data (Object)</dt> <dd>Raw data.</dd>"," * <dt>response (Object)</dt>"," * <dd>Normalized response object with the following properties:"," * <dl>"," * <dt>results (Object)</dt> <dd>Parsed results.</dd>"," * <dt>meta (Object)</dt> <dd>Parsed meta data.</dd>"," * <dt>error (Object)</dt> <dd>Error object.</dd>"," * </dl>"," * </dd>"," * <dt>error</dt>"," * <dd>Any error that occurred along the transaction lifecycle.</dd>"," * </dl>"," */",""," },",""," /**"," * Manages request/response transaction. Must fire <code>response</code>"," * event when response is received. This method should be implemented by"," * subclasses to achieve more complex behavior such as accessing remote data."," *"," * @method _defRequestFn"," * @param e {Event.Facade} Event Facadewith the following properties:"," * <dl>"," * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>"," * <dt>request (Object)</dt> <dd>The request.</dd>"," * <dt>callback (Object)</dt> <dd>Deprecated alias for the"," * <strong>on</strong> property</dd>"," * <dt>on (Object)</dt> <dd>The map of configured transaction"," * callbacks. An object with the following properties:"," * <dl>"," * <dt>success (Function)</dt> <dd>Success handler.</dd>"," * <dt>failure (Function)</dt> <dd>Failure handler.</dd>"," * </dl>"," * </dd>"," * <dt>cfg (Object)</dt> <dd>Configuration object.</dd>"," * </dl>"," * @protected"," */"," _defRequestFn: function(e) {"," var data = this.get(\"source\"),"," payload = e.details[0];",""," // Problematic data"," if(LANG.isUndefined(data)) {"," payload.error = new Error(\"Local source undefined\");"," }",""," payload.data = data;"," this.fire(\"data\", payload);"," },",""," /**"," * Normalizes raw data into a response that includes results and meta properties."," *"," * @method _defDataFn"," * @param e {Event.Facade} Event Facade with the following properties:"," * <dl>"," * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>"," * <dt>request (Object)</dt> <dd>The request.</dd>"," * <dt>callback (Object)</dt> <dd>Deprecated alias for the"," * <strong>on</strong> property</dd>"," * <dt>on (Object)</dt> <dd>The map of configured transaction"," * callbacks. An object with the following properties:"," * <dl>"," * <dt>success (Function)</dt> <dd>Success handler.</dd>"," * <dt>failure (Function)</dt> <dd>Failure handler.</dd>"," * </dl>"," * </dd>"," * <dt>cfg (Object)</dt> <dd>Configuration object.</dd>"," * <dt>data (Object)</dt> <dd>Raw data.</dd>"," * </dl>"," * @protected"," */"," _defDataFn: function(e) {"," var data = e.data,"," meta = e.meta,"," response = {"," results: (LANG.isArray(data)) ? data : [data],"," meta: (meta) ? meta : {}"," },"," payload = e.details[0];",""," payload.response = response;"," this.fire(\"response\", payload);"," },",""," /**"," * Sends data as a normalized response to callback."," *"," * @method _defResponseFn"," * @param e {Event.Facade} Event Facade with the following properties:"," * <dl>"," * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>"," * <dt>request (Object)</dt> <dd>The request.</dd>"," * <dt>callback (Object)</dt> <dd>Deprecated alias for the"," * <strong>on</strong> property</dd>"," * <dt>on (Object)</dt> <dd>The map of configured transaction"," * callbacks. An object with the following properties:"," * <dl>"," * <dt>success (Function)</dt> <dd>Success handler.</dd>"," * <dt>failure (Function)</dt> <dd>Failure handler.</dd>"," * </dl>"," * </dd>"," * <dt>cfg (Object)</dt> <dd>Configuration object.</dd>"," * <dt>data (Object)</dt> <dd>Raw data.</dd>"," * <dt>response (Object)</dt> <dd>Normalized response object with the following properties:"," * <dl>"," * <dt>results (Object)</dt> <dd>Parsed results.</dd>"," * <dt>meta (Object)</dt> <dd>Parsed meta data.</dd>"," * <dt>error (Boolean)</dt> <dd>Error flag.</dd>"," * </dl>"," * </dd>"," * </dl>"," * @protected"," */"," _defResponseFn: function(e) {"," // Send the response back to the callback"," DSLocal.issueCallback(e, this);"," },",""," /**"," * Generates a unique transaction ID and fires <code>request</code> event."," * <strong>Note</strong>: the property <code>callback</code> is a"," * deprecated alias for the <code>on</code> transaction configuration"," * property described below."," *"," * @method sendRequest"," * @param [request] {Object} An object literal with the following properties:"," * <dl>"," * <dt><code>request</code></dt>"," * <dd>The request to send to the live data source, if any.</dd>"," * <dt><code>on</code></dt>"," * <dd>An object literal with the following properties:"," * <dl>"," * <dt><code>success</code></dt>"," * <dd>The function to call when the data is ready.</dd>"," * <dt><code>failure</code></dt>"," * <dd>The function to call upon a response failure condition.</dd>"," * <dt><code>argument</code></dt>"," * <dd>Arbitrary data payload that will be passed back to the success and failure handlers.</dd>"," * </dl>"," * </dd>"," * <dt><code>cfg</code></dt>"," * <dd>Configuration object, if any.</dd>"," * </dl>"," * @return {Number} Transaction ID."," */"," sendRequest: function(request) {"," var tId = DSLocal._tId++,"," callbacks;",""," request = request || {};",""," callbacks = request.on || request.callback;",""," this.fire(\"request\", {"," tId: tId,"," request: request.request,"," on: callbacks,"," callback: callbacks,"," cfg: request.cfg || {}"," });","",""," return tId;"," }","});","","Y.namespace(\"DataSource\").Local = DSLocal;","","","}, '3.13.0', {\"requires\": [\"base\"]});","","}());"]};