You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/02/11 19:20:41 UTC
[2/5] git commit: removed Storable and references
removed Storable and references
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/6b03eed1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/6b03eed1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/6b03eed1
Branch: refs/pull/51/head
Commit: 6b03eed15e8a7176d0ccb5ebda31c42731cf1c0d
Parents: a0a585b
Author: ryan bridges <rb...@apigee.com>
Authored: Tue Feb 11 13:06:25 2014 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Tue Feb 11 13:06:25 2014 -0500
----------------------------------------------------------------------
sdks/html5-javascript/Gruntfile.js | 1 -
sdks/html5-javascript/lib/Usergrid.js | 1 -
.../lib/modules/util/Storable.js | 88 ------------------
sdks/html5-javascript/tests/mocha/test.js | 1 +
sdks/html5-javascript/usergrid.js | 97 --------------------
sdks/html5-javascript/usergrid.min.js | 4 +-
6 files changed, 3 insertions(+), 189 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6b03eed1/sdks/html5-javascript/Gruntfile.js
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/Gruntfile.js b/sdks/html5-javascript/Gruntfile.js
index cfa39e3..82c2029 100644
--- a/sdks/html5-javascript/Gruntfile.js
+++ b/sdks/html5-javascript/Gruntfile.js
@@ -4,7 +4,6 @@ module.exports = function(grunt) {
"lib/modules/util/Logger.js",
"lib/modules/util/Promise.js",
"lib/modules/util/Ajax.js",
- "lib/modules/util/Storable.js",
"lib/Usergrid.js",
"lib/modules/Client.js",
"lib/modules/Entity.js",
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6b03eed1/sdks/html5-javascript/lib/Usergrid.js
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/lib/Usergrid.js b/sdks/html5-javascript/lib/Usergrid.js
index 7b28d4f..9ef2583 100644
--- a/sdks/html5-javascript/lib/Usergrid.js
+++ b/sdks/html5-javascript/lib/Usergrid.js
@@ -204,7 +204,6 @@ function doCallback(callback, params, context) {
return p;
};
- Usergrid.Request.prototype= new UsergridStorable();
//TODO more granular handling of statusCodes
Usergrid.Response = function (err, response) {
var p = new Promise();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6b03eed1/sdks/html5-javascript/lib/modules/util/Storable.js
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/lib/modules/util/Storable.js b/sdks/html5-javascript/lib/modules/util/Storable.js
deleted file mode 100644
index 5c4da2e..0000000
--- a/sdks/html5-javascript/lib/modules/util/Storable.js
+++ /dev/null
@@ -1,88 +0,0 @@
-function UsergridStorable(storage, keyPrefix){
- //throw Error("'UsergridStorable' is not intended to be invoked directly")
-}
-UsergridStorable.prototype.setStorage = function(storage) {
- if(!(storage instanceof Storage)){
- console.warn("parameter passed to 'setStorage' is not a browser Storage interface. using sessionStorage");
- storage=sessionStorage;
- }
- return this._storage=storage;
-};
-UsergridStorable.prototype.getStorage = function() {
- if(!(this._storage instanceof Storage)){
- console.warn("parameter passed to 'setStorage' is not a browser Storage interface. using sessionStorage");
- this._storage=sessionStorage;
- }
- return this._storage;
-};
-UsergridStorable.prototype.getStorageKey = function(key) {
- if(!this._keyPrefix)this._keyPrefix='usergrid_js_sdk_';
- return this._keyPrefix+key;
-};
-UsergridStorable.prototype.get=function(key){
- var value;
- if(arguments.length>1){
- key=[].slice.call(arguments).reduce(function(p,c,i,a){
- if(c instanceof Array){
- p= p.concat(c);
- }else{
- p.push(c);
- }
- return p;
- },[]);
- }
- if(this._storage instanceof Storage){
- if(key instanceof Array){
- var self=this;
- value=key.map(function(k){return self.get(k)});
- }else if("undefined" !== typeof key){
- this[key]=JSON.parse(this.getStorage().getItem(this.getStorageKey(key)));
- value=this[key];
- }
- }
- return value;
-}
-UsergridStorable.prototype.set=function(key, value){
- if(this._storage instanceof Storage){
- if(value){
- this[key]=JSON.stringify(value);
- this.getStorage().setItem(this.getStorageKey(key),this[key]);
- }else{
- delete this[key];
- this.getStorage().removeItem(this.getStorageKey(key));
- }
- }
-}
-/*
- * A public method to store the OAuth token for later use - uses localstorage if available
- *
- * @method setToken
- * @public
- * @params {string} token
- * @return none
- */
-UsergridStorable.prototype.setToken = function (token) {
- return this.set('token', token);
-};
-
-/*
- * A public method to get the OAuth token
- *
- * @method getToken
- * @public
- * @return {string} token
- */
-UsergridStorable.prototype.getToken = function () {
- return this.get('token');
-};
-UsergridStorable.mixin = function(destObject){
- var props = ['getStorage', 'setStorage', 'getStorageKey', 'get', 'set', 'getToken', 'setToken'];
- for(var i = 0; i < props.length; i ++){
- if(props[i] in destObject.prototype){
- console.warn("overwriting '"+props[i]+"' on '"+destObject.name+"'.");
- console.warn("the previous version can be found at '_"+props[i]+"' on '"+destObject.name+"'.");
- destObject.prototype['_'+props[i]]=destObject.prototype[props[i]];
- }
- destObject.prototype[props[i]] = UsergridStorable.prototype[props[i]];
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6b03eed1/sdks/html5-javascript/tests/mocha/test.js
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/tests/mocha/test.js b/sdks/html5-javascript/tests/mocha/test.js
index e430c02..216aa0a 100644
--- a/sdks/html5-javascript/tests/mocha/test.js
+++ b/sdks/html5-javascript/tests/mocha/test.js
@@ -163,6 +163,7 @@ describe('Usergrid Client', function() {
var client = getClient();
describe('Usergrid CRUD request', function() {
before(function(done) {
+ this.timeout(10000);
//Make sure our dog doesn't already exist
client.request({
method: 'DELETE',
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6b03eed1/sdks/html5-javascript/usergrid.js
----------------------------------------------------------------------
diff --git a/sdks/html5-javascript/usergrid.js b/sdks/html5-javascript/usergrid.js
index ff83f6c..59e80ef 100644
--- a/sdks/html5-javascript/usergrid.js
+++ b/sdks/html5-javascript/usergrid.js
@@ -253,102 +253,6 @@ UsergridEventable.mixin = function(destObject) {
return global[name];
})();
-function UsergridStorable(storage, keyPrefix) {}
-
-UsergridStorable.prototype.setStorage = function(storage) {
- if (!(storage instanceof Storage)) {
- console.warn("parameter passed to 'setStorage' is not a browser Storage interface. using sessionStorage");
- storage = sessionStorage;
- }
- return this._storage = storage;
-};
-
-UsergridStorable.prototype.getStorage = function() {
- if (!(this._storage instanceof Storage)) {
- console.warn("parameter passed to 'setStorage' is not a browser Storage interface. using sessionStorage");
- this._storage = sessionStorage;
- }
- return this._storage;
-};
-
-UsergridStorable.prototype.getStorageKey = function(key) {
- if (!this._keyPrefix) this._keyPrefix = "usergrid_js_sdk_";
- return this._keyPrefix + key;
-};
-
-UsergridStorable.prototype.get = function(key) {
- var value;
- if (arguments.length > 1) {
- key = [].slice.call(arguments).reduce(function(p, c, i, a) {
- if (c instanceof Array) {
- p = p.concat(c);
- } else {
- p.push(c);
- }
- return p;
- }, []);
- }
- if (this._storage instanceof Storage) {
- if (key instanceof Array) {
- var self = this;
- value = key.map(function(k) {
- return self.get(k);
- });
- } else if ("undefined" !== typeof key) {
- this[key] = JSON.parse(this.getStorage().getItem(this.getStorageKey(key)));
- value = this[key];
- }
- }
- return value;
-};
-
-UsergridStorable.prototype.set = function(key, value) {
- if (this._storage instanceof Storage) {
- if (value) {
- this[key] = JSON.stringify(value);
- this.getStorage().setItem(this.getStorageKey(key), this[key]);
- } else {
- delete this[key];
- this.getStorage().removeItem(this.getStorageKey(key));
- }
- }
-};
-
-/*
- * A public method to store the OAuth token for later use - uses localstorage if available
- *
- * @method setToken
- * @public
- * @params {string} token
- * @return none
- */
-UsergridStorable.prototype.setToken = function(token) {
- return this.set("token", token);
-};
-
-/*
- * A public method to get the OAuth token
- *
- * @method getToken
- * @public
- * @return {string} token
- */
-UsergridStorable.prototype.getToken = function() {
- return this.get("token");
-};
-
-UsergridStorable.mixin = function(destObject) {
- var props = [ "getStorage", "setStorage", "getStorageKey", "get", "set", "getToken", "setToken" ];
- for (var i = 0; i < props.length; i++) {
- if (props[i] in destObject.prototype) {
- console.warn("overwriting '" + props[i] + "' on '" + destObject.name + "'.");
- console.warn("the previous version can be found at '_" + props[i] + "' on '" + destObject.name + "'.");
- destObject.prototype["_" + props[i]] = destObject.prototype[props[i]];
- }
- destObject.prototype[props[i]] = UsergridStorable.prototype[props[i]];
- }
-};
-
/*
* This module is a collection of classes designed to make working with
* the Appigee App Services API as easy as possible.
@@ -557,7 +461,6 @@ function doCallback(callback, params, context) {
Promise.chain([ request, response ]).then(oncomplete);
return p;
};
- Usergrid.Request.prototype = new UsergridStorable();
//TODO more granular handling of statusCodes
Usergrid.Response = function(err, response) {
var p = new Promise();