Compare commits

...

12 Commits

Author SHA1 Message Date
acc0e5221b 0.0.13 2015-12-10 15:52:25 +01:00
a6839420f1 added merge and replace operations for objectstorage 2015-12-10 15:52:14 +01:00
2df7cf1467 0.0.12 2015-12-06 21:55:56 +01:00
bae4305dec update dependencies 2015-12-06 21:55:49 +01:00
1737075753 0.0.11 2015-12-06 21:50:05 +01:00
1a74ee8bb6 switched params for smartenv.obs.add() 2015-12-06 21:49:57 +01:00
28538001e9 0.0.10 2015-12-02 15:33:06 +01:00
9ec0b49716 refactored some functin names within obs module 2015-12-02 15:32:58 +01:00
cab52e1b02 0.0.9 2015-12-02 15:23:59 +01:00
d601a0eeb0 Merge branch 'master' of github.com:pushrocks/smartenv 2015-12-02 15:23:59 +01:00
491f22ffca clean up and fix some errors 2015-12-02 15:23:48 +01:00
1fec5323d9 closes #1 2015-12-01 08:29:58 +01:00
12 changed files with 208 additions and 139 deletions

View File

@ -24,8 +24,14 @@ var Environment = (function () {
*/ */
var SmartenvEnvironment; var SmartenvEnvironment;
(function (SmartenvEnvironment) { (function (SmartenvEnvironment) {
function init() {
var environment; var environment;
var envDetermined = false;
/**
* returns the environment
* @returns {Environment}
*/
var getEnv = function () {
if (!envDetermined) {
(function () { (function () {
var localRunTimeEnv = "undefined"; var localRunTimeEnv = "undefined";
var localUserAgent = "undefined"; var localUserAgent = "undefined";
@ -38,36 +44,75 @@ var SmartenvEnvironment;
} }
environment = new Environment(localRunTimeEnv, localUserAgent); environment = new Environment(localRunTimeEnv, localUserAgent);
})(); })();
return function () { }
;
return environment; return environment;
}; };
/**
* prints the environment to console
*/
var printEnv = function () {
if (this.getEnv().isNode) {
var smartenvVersion = require("./package.json").version;
plugins.beautylog.log("node version is " + this.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
} }
SmartenvEnvironment.init = init; else {
plugins.beautylog.log("browser is " + this.getEnv().userAgent);
}
plugins.beautylog.log("the smartenv registration store currently holds the following properties:");
console.log(Object.getOwnPropertyNames(smartenv.obs.getAll()));
};
SmartenvEnvironment.init = function (objectArg) {
objectArg.getEnv = getEnv;
objectArg.printEnv = printEnv;
};
})(SmartenvEnvironment || (SmartenvEnvironment = {})); })(SmartenvEnvironment || (SmartenvEnvironment = {}));
/// <reference path="index.ts" /> /// <reference path="index.ts" />
var SmartenvObjectStorage; var SmartenvObjectStorage;
(function (SmartenvObjectStorage) { (function (SmartenvObjectStorage) {
function init() { function init() {
var obs = {}; var obs = {
var obsItems = {}; add: function (paramNameArg, objectArg) {
obs.addItem = function (objectArg, paramName) { if (paramNameArg === void 0) { paramNameArg = "undefined"; }
if (paramName === void 0) { paramName = "undefined"; } if (objectArg === void 0) { objectArg = "undefined"; }
if (paramName == "undefined") { if (paramNameArg == "undefined") {
plugins.beautylog.error("paramName is undefined"); plugins.beautylog.error("paramName is undefined");
return; return;
} }
obsItems[paramName] = objectArg; if (objectArg == "undefined") {
}; plugins.beautylog.error("objectArg is undefined");
obs.getItem = function (keyName) { }
if (typeof obsItems[paramNameArg] === "undefined") {
obsItems[paramNameArg] = objectArg;
}
else {
plugins.beautylog.error("object is already present, so add operation has failed.");
}
return obsItems[paramNameArg];
},
replace: function (paramNameArg, objectArg) {
obsItems[paramNameArg] = objectArg;
},
merge: function (paramNameArg, objectArg) {
if (!(typeof obsItems[paramNameArg] === "undefined")) {
obsItems[paramNameArg] = plugins._.assign(obsItems[paramNameArg], objectArg);
}
else {
plugins.beautylog.error("object is not present, so there is nothing to merge");
}
},
get: function (keyName) {
return obsItems[keyName]; return obsItems[keyName];
}; },
obs.getComplete = function () { getAll: function () {
return obsItems; return obsItems;
}; },
obs.addComplete = function (itemsArg) { addComplete: function (itemsArg) {
obsItems = plugins._.assign(obsItems, itemsArg); obsItems = plugins._.assign(obsItems, itemsArg);
return obsItems; return obsItems;
}
}; };
var obsItems = {};
return obs; return obs;
} }
SmartenvObjectStorage.init = init; SmartenvObjectStorage.init = init;
@ -81,20 +126,6 @@ var plugins = {
_: require("lodash") _: require("lodash")
}; };
var smartenv = {}; //create smartenv object var smartenv = {}; //create smartenv object
smartenv.getEnv = SmartenvEnvironment.init(); SmartenvEnvironment.init(smartenv);
smartenv.obs = SmartenvObjectStorage.init(); smartenv.obs = SmartenvObjectStorage.init();
/* ----------------------------------------- *
* ----- print info ------------------------ *
* ----------------------------------------- */
smartenv.printEnv = function () {
if (smartenv.getEnv().isNode) {
var smartenvVersion = require("./package.json").version;
plugins.beautylog.log("node version is " + smartenv.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
}
else {
plugins.beautylog.log("browser is " + smartenv.getEnv().userAgent);
}
plugins.beautylog.log("the smartenv registration store currently holds the following properties:");
console.log(Object.getOwnPropertyNames(smartenv.obs.getComplete).sort());
};
module.exports = smartenv; module.exports = smartenv;

View File

@ -1,13 +1,14 @@
{ {
"name": "smartenv", "name": "smartenv",
"version": "0.0.8", "version": "0.0.13",
"description": "store things about your environment and let them travel across modules", "description": "store things about your environment and let them travel across modules",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "(cd ts/compile && node compile.js) && (node test.js)", "test": "(cd ts/compile && node compile.js) && (node test.js)",
"reinstall": "(rm -r node_modules && npm install)", "reinstall": "(rm -r node_modules && npm install)",
"release": "(git pull origin master && npm version patch && git push origin master && git checkout release && git merge master && git push origin release && git checkout master)", "release": "(git pull origin master && npm version patch && git push origin master && git checkout release && git merge master && git push origin release && git checkout master)",
"startdev": "(git checkout master && git pull origin master && npm install)" "update": "(git checkout master && git pull origin master && npm install)",
"upgrade": "(npm run update) && (ncu upgradeAll && npm install)"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -23,11 +24,11 @@
}, },
"homepage": "https://github.com/pushrocks/smartenv", "homepage": "https://github.com/pushrocks/smartenv",
"dependencies": { "dependencies": {
"beautylog": "^1.0.4", "beautylog": "^1.0.6",
"lodash": "^3.10.1" "lodash": "^3.10.1"
}, },
"devDependencies": { "devDependencies": {
"gulp": "^3.9.0", "gulp": "^3.9.0",
"gulp-typescript": "^2.9.2" "gulp-typescript": "^2.10.0"
} }
} }

17
test.js
View File

@ -4,11 +4,18 @@ var beautylog = require("beautylog")("os");
beautylog.info("Now testing the smartenv module"); beautylog.info("Now testing the smartenv module");
smartenv.printEnv(); smartenv.printEnv();
beautylog.info("Now testing the smartenv module"); beautylog.info("Now testing the smartenv module");
smartenv.obs.addItem({ key1: "Peter" }, "docit"); //test smartenv.obs.add
smartenv.obs.add("myTestObject", { key1: "Peter" });
smartenv.obs.add("myTestObject", { key1: "Klaus" }); //now trying to add a second
smartenv.printEnv(); smartenv.printEnv();
beautylog.log(smartenv.obs.getItem("docit").key1); beautylog.log(smartenv.obs.get("myTestObject").key1); // this should be Peter
beautylog.log(smartenv.obs.getItem("docit").key1); //test smartenv.obs.replace
smartenv.obs.replace("myTestObject", { key1: "Klaus" });
beautylog.log(smartenv.obs.get("myTestObject").key1); // this should be Klaus
//test smartenv.obs.merge
smartenv.obs.merge("myTestObject", { key2: "Peter" });
beautylog.log(smartenv.obs.get("myTestObject").key1 + smartenv.obs.get("myTestObject").key2); // this should be KlausPeter
var key2 = "hello"; var key2 = "hello";
smartenv.obs.getItem("docit").key2 = key2; smartenv.obs.get("myTestObject").key2 = key2;
beautylog.log(smartenv.obs.getItem("docit").key2); beautylog.log(smartenv.obs.get("myTestObject").key2);
beautylog.success("Success!"); beautylog.success("Success!");

View File

@ -7,21 +7,7 @@ var plugins = {
_: require("lodash") _: require("lodash")
}; };
var smartenv = {}; //create smartenv object var smartenv = {}; //create smartenv object
smartenv.getEnv = SmartenvEnvironment.init(); SmartenvEnvironment.init(smartenv);
smartenv.obs = SmartenvObjectStorage.init(); smartenv.obs = SmartenvObjectStorage.init();
/* ----------------------------------------- *
* ----- print info ------------------------ *
* ----------------------------------------- */
smartenv.printEnv = function () {
if (smartenv.getEnv().isNode) {
var smartenvVersion = require("./package.json").version;
plugins.beautylog.log("node version is " + smartenv.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
}
else {
plugins.beautylog.log("browser is " + smartenv.getEnv().userAgent);
}
plugins.beautylog.log("the smartenv registration store currently holds the following properties:");
console.log(Object.getOwnPropertyNames(smartenv.obs.getComplete).sort());
};
module.exports = smartenv; module.exports = smartenv;
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,4CAA4C;AAC5C,gDAAgD;AAChD,kDAAkD;AAClD,IAAI,OAAO,GAAG;IACV,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC;IACrC,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC;CACvB,CAAA;AACD,IAAI,QAAQ,GAAO,EAAE,CAAC,CAAC,wBAAwB;AAE/C,QAAQ,CAAC,MAAM,GAAG,mBAAmB,CAAC,IAAI,EAAE,CAAC;AAC7C,QAAQ,CAAC,GAAG,GAAG,qBAAqB,CAAC,IAAI,EAAE,CAAC;AAG5C;;+CAE+C;AAC/C,QAAQ,CAAC,QAAQ,GAAG;IAChB,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QAC3B,IAAI,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC;QACxD,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,kBAAkB,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,WAAW,GAAG,2BAA2B,GAAG,eAAe,CAAC,CAAC;IAC9H,CAAC;IAAC,IAAI,CAAC,CAAC;QACJ,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAA;IACtE,CAAC;IACD,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,2EAA2E,CAAC,CAAC;IACnG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAC7E,CAAC,CAAC;AAIF,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAC"} {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,4CAA4C;AAC5C,gDAAgD;AAChD,kDAAkD;AAClD,IAAI,OAAO,GAAG;IACV,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC;IACrC,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC;CACvB,CAAA;AACD,IAAI,QAAQ,GAAO,EAAE,CAAC,CAAC,wBAAwB;AAE/C,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACnC,QAAQ,CAAC,GAAG,GAAG,qBAAqB,CAAC,IAAI,EAAE,CAAC;AAI5C,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAC"}

View File

@ -8,24 +8,9 @@ var plugins = {
} }
var smartenv:any = {}; //create smartenv object var smartenv:any = {}; //create smartenv object
smartenv.getEnv = SmartenvEnvironment.init(); SmartenvEnvironment.init(smartenv);
smartenv.obs = SmartenvObjectStorage.init(); smartenv.obs = SmartenvObjectStorage.init();
/* ----------------------------------------- *
* ----- print info ------------------------ *
* ----------------------------------------- */
smartenv.printEnv = function() {
if (smartenv.getEnv().isNode) {
var smartenvVersion = require("./package.json").version;
plugins.beautylog.log("node version is " + smartenv.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
} else {
plugins.beautylog.log("browser is " + smartenv.getEnv().userAgent)
}
plugins.beautylog.log("the smartenv registration store currently holds the following properties:");
console.log(Object.getOwnPropertyNames(smartenv.obs.getComplete).sort());
};
module.exports = smartenv; module.exports = smartenv;

View File

@ -2,7 +2,7 @@
class Environment { class Environment {
public runtimeEnv:string; public runtimeEnv:string;
public userAgent:string; public userAgent:string;
public nodeVersion; public nodeVersion:string;
public isBrowser:boolean; public isBrowser:boolean;
public isNode:boolean; public isNode:boolean;
constructor(runtimeEnvArg,userAgentArg = "undefined") { constructor(runtimeEnvArg,userAgentArg = "undefined") {

View File

@ -3,8 +3,16 @@
* Deals with the environment the current JS script is running in. * Deals with the environment the current JS script is running in.
*/ */
module SmartenvEnvironment { module SmartenvEnvironment {
export function init(){
var environment:Environment; var environment:Environment;
var envDetermined:boolean = false;
/**
* returns the environment
* @returns {Environment}
*/
var getEnv = function(){
if (!envDetermined) {
(function() { (function() {
var localRunTimeEnv = "undefined"; var localRunTimeEnv = "undefined";
var localUserAgent = "undefined"; var localUserAgent = "undefined";
@ -16,10 +24,26 @@ module SmartenvEnvironment {
} }
environment = new Environment(localRunTimeEnv,localUserAgent); environment = new Environment(localRunTimeEnv,localUserAgent);
})(); })();
};
return function() {
return environment; return environment;
}; };
/**
* prints the environment to console
*/
var printEnv = function() {
if (this.getEnv().isNode) {
var smartenvVersion = require("./package.json").version;
plugins.beautylog.log("node version is " + this.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
} else {
plugins.beautylog.log("browser is " + this.getEnv().userAgent)
}
plugins.beautylog.log("the smartenv registration store currently holds the following properties:");
console.log(Object.getOwnPropertyNames(smartenv.obs.getAll()));
}
export var init = function(objectArg) {
objectArg.getEnv = getEnv;
objectArg.printEnv = printEnv;
} }
} }

View File

@ -1,26 +1,44 @@
/// <reference path="index.ts" /> /// <reference path="index.ts" />
module SmartenvObjectStorage { module SmartenvObjectStorage {
export function init() { export function init() {
var obs:any = {}; var obs:any = {
var obsItems:any = {}; add: function(paramNameArg = "undefined",objectArg = "undefined") {
obs.addItem = function(objectArg,paramName = "undefined") { if (paramNameArg == "undefined"){
if (paramName == "undefined"){
plugins.beautylog.error("paramName is undefined"); plugins.beautylog.error("paramName is undefined");
return; return;
} }
obsItems[paramName] = objectArg; if (objectArg == "undefined"){
}; plugins.beautylog.error("objectArg is undefined");
obs.getItem = function(keyName) {
return obsItems[keyName];
};
obs.getComplete = function () {
return obsItems;
} }
if (typeof obsItems[paramNameArg] === "undefined"){
obs.addComplete = function(itemsArg) { obsItems[paramNameArg] = objectArg;
} else {
plugins.beautylog.error("object is already present, so add operation has failed.");
}
return obsItems[paramNameArg];
},
replace: function(paramNameArg,objectArg){
obsItems[paramNameArg] = objectArg;
},
merge: function(paramNameArg,objectArg){
if(!(typeof obsItems[paramNameArg] === "undefined")){
obsItems[paramNameArg] = plugins._.assign(obsItems[paramNameArg],objectArg);
} else {
plugins.beautylog.error("object is not present, so there is nothing to merge");
}
},
get: function(keyName) {
return obsItems[keyName];
},
getAll: function () {
return obsItems;
},
addComplete: function(itemsArg) {
obsItems = plugins._.assign(obsItems,itemsArg); obsItems = plugins._.assign(obsItems,itemsArg);
return obsItems; return obsItems;
}
}; };
var obsItems:any = {};
return obs; return obs;
} }
} }

View File

@ -4,12 +4,19 @@ var beautylog = require("beautylog")("os");
beautylog.info("Now testing the smartenv module"); beautylog.info("Now testing the smartenv module");
smartenv.printEnv(); smartenv.printEnv();
beautylog.info("Now testing the smartenv module"); beautylog.info("Now testing the smartenv module");
smartenv.obs.addItem({ key1: "Peter" }, "docit"); //test smartenv.obs.add
smartenv.obs.add("myTestObject", { key1: "Peter" });
smartenv.obs.add("myTestObject", { key1: "Klaus" }); //now trying to add a second
smartenv.printEnv(); smartenv.printEnv();
beautylog.log(smartenv.obs.getItem("docit").key1); beautylog.log(smartenv.obs.get("myTestObject").key1); // this should be Peter
beautylog.log(smartenv.obs.getItem("docit").key1); //test smartenv.obs.replace
smartenv.obs.replace("myTestObject", { key1: "Klaus" });
beautylog.log(smartenv.obs.get("myTestObject").key1); // this should be Klaus
//test smartenv.obs.merge
smartenv.obs.merge("myTestObject", { key2: "Peter" });
beautylog.log(smartenv.obs.get("myTestObject").key1 + smartenv.obs.get("myTestObject").key2); // this should be KlausPeter
var key2 = "hello"; var key2 = "hello";
smartenv.obs.getItem("docit").key2 = key2; smartenv.obs.get("myTestObject").key2 = key2;
beautylog.log(smartenv.obs.getItem("docit").key2); beautylog.log(smartenv.obs.get("myTestObject").key2);
beautylog.success("Success!"); beautylog.success("Success!");
//# sourceMappingURL=test.js.map //# sourceMappingURL=test.js.map

View File

@ -1 +1 @@
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,IAAI,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AACrC,IAAI,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC;AAC3C,SAAS,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;AAClD,QAAQ,CAAC,QAAQ,EAAE,CAAC;AACpB,SAAS,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;AAClD,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAC,IAAI,EAAC,OAAO,EAAC,EAAC,OAAO,CAAC,CAAC;AAC7C,QAAQ,CAAC,QAAQ,EAAE,CAAC;AACpB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AAClD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AAElD,IAAI,IAAI,GAAG,OAAO,CAAC;AACnB,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC;AAC1C,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AAElD,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC"} {"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,IAAI,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AACrC,IAAI,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC;AAC3C,SAAS,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;AAClD,QAAQ,CAAC,QAAQ,EAAE,CAAC;AACpB,SAAS,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;AAElD,uBAAuB;AACvB,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,EAAC,EAAC,IAAI,EAAC,OAAO,EAAC,CAAC,CAAC;AAChD,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,EAAC,EAAC,IAAI,EAAC,OAAO,EAAC,CAAC,CAAC,CAAC,4BAA4B;AAC7E,QAAQ,CAAC,QAAQ,EAAE,CAAC;AACpB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,uBAAuB;AAE7E,2BAA2B;AAC3B,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,EAAC,EAAC,IAAI,EAAC,OAAO,EAAC,CAAC,CAAC;AACpD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,uBAAuB;AAE7E,yBAAyB;AACzB,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,cAAc,EAAC,EAAC,IAAI,EAAC,OAAO,EAAC,CAAC,CAAC;AAClD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,4BAA4B;AAE1H,IAAI,IAAI,GAAG,OAAO,CAAC;AACnB,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC;AAC7C,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC;AAErD,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC"}

View File

@ -4,13 +4,23 @@ var beautylog = require("beautylog")("os");
beautylog.info("Now testing the smartenv module"); beautylog.info("Now testing the smartenv module");
smartenv.printEnv(); smartenv.printEnv();
beautylog.info("Now testing the smartenv module"); beautylog.info("Now testing the smartenv module");
smartenv.obs.addItem({key1:"Peter"},"docit");
//test smartenv.obs.add
smartenv.obs.add("myTestObject",{key1:"Peter"});
smartenv.obs.add("myTestObject",{key1:"Klaus"}); //now trying to add a second
smartenv.printEnv(); smartenv.printEnv();
beautylog.log(smartenv.obs.getItem("docit").key1); beautylog.log(smartenv.obs.get("myTestObject").key1); // this should be Peter
beautylog.log(smartenv.obs.getItem("docit").key1);
//test smartenv.obs.replace
smartenv.obs.replace("myTestObject",{key1:"Klaus"});
beautylog.log(smartenv.obs.get("myTestObject").key1); // this should be Klaus
//test smartenv.obs.merge
smartenv.obs.merge("myTestObject",{key2:"Peter"});
beautylog.log(smartenv.obs.get("myTestObject").key1 + smartenv.obs.get("myTestObject").key2); // this should be KlausPeter
var key2 = "hello"; var key2 = "hello";
smartenv.obs.getItem("docit").key2 = key2; smartenv.obs.get("myTestObject").key2 = key2;
beautylog.log(smartenv.obs.getItem("docit").key2); beautylog.log(smartenv.obs.get("myTestObject").key2);
beautylog.success("Success!"); beautylog.success("Success!");