Skip to content

Commit

Permalink
see UPDATELOG.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Bosn committed Jul 16, 2013
1 parent 7d02b28 commit 0bd92e5
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Rigel Automation Platform
===

@version v0.4.0
@version v0.5.0
@author Bosn Ma
@weibo http://weibo.com/bosn
@mail [email protected]
Expand Down
8 changes: 5 additions & 3 deletions UPDATELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
======================rap v0.5 =================================================
* data mock
fix problems when request URL is absolute
fix problems when request URL is absolute 07/15/2013
enhance JSON import, default add @value into remark field 07/15/2013
fix bugs when JSON imported has Array<xxx> elements 07/16/2013

======================rap v0.4 =================================================
* change version back to 0.4
Expand All @@ -9,15 +11,15 @@
* add new tag format like @format[3], @value[4] to affect specified index of array element
* add new tag regex like @regex=[a-zA-Z]bc to import powerful regular expression mechanism
* update pageTester, add new tabs modify and reset which can help operate on mock data

======================rap v1.3 =================================================
* UE: login automatically redirect 09/10/2012
* add new mock data tag:@value=[xx], for mocking from 01 to 30, eg->@value=2012-09-[xx], output: 2012-09-01, 2012-09-02, 2012-09-03... 09/10/2012
* update mock service, add @type=array, @type=array_map, @length=\d+ for action description, add new _c callback 09/10/2012
* add @code @end support for action description area for code formatting 09/10/2012
* increase size of working area 09/10/2012
* fix bugs (data type choose, word file export encoding, etc.) 09/10/2012

======================rap v1.2 =================================================
* simplify operation flow √ 08/29/2012
* fix shortcuts compatibilities in different browsers (1.1 only support Firefox) 07/24/2012
Expand Down
49 changes: 34 additions & 15 deletions WebContent/stat/js/core/rap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
var rap = rap || {};

/********************************************************
* *
* ##util module begin *
* *
* *
* ##util module begin *
* *
********************************************************/

/**
Expand All @@ -25,7 +25,7 @@ var rap = rap || {};
* @return 转义后的输出
*/
util.escaper.escapeInHJ = function(inputStr) {
var inputStr = inputStr.replace(/\&/g, "&amp;");
inputStr.replace(/\&/g, "&amp;");
inputStr = inputStr.replace(/\</g, "&lt;");
inputStr = inputStr.replace(/\>/g, "&gt;");
inputStr = inputStr.replace(/\\/g, "\\\\");
Expand Down Expand Up @@ -2899,6 +2899,11 @@ var rap = rap || {};

/**
* process JSON import
*
* @param {object} f value to be processed
* @param {string} k key
* @param {number} pid parameter id
* @param {boolean} notFirst
*/
function processJSONImport(f, k, pId, notFirst) {
var id, param, item;
Expand All @@ -2914,28 +2919,42 @@ var rap = rap || {};
}
}
var key;
var f2; // child of f2
if (f instanceof Array && f.length) {
if (notFirst) {
item = f[0];
if (typeof f === 'string') {
f2 = f[0];
if (typeof f2 === 'string') {
param.dataType = 'array<string>';
} else if (typeof f === 'number') {
param.remark = '@value=' + f;
} else if (typeof f2 === 'number') {
param.dataType = 'array<number>';
} else if (typeof f === 'boolean') {
param.remark = '@value=' + f;
} else if (typeof f2 === 'boolean') {
param.dataType = 'array<boolean>';
} else if (f !== null && typeof f === 'object') {
param.remark = '@value=' + f;
} else if (f !== null && typeof f2 === 'object') {
param.dataType = 'array<object>';
for (key in item) {
processJSONImport(item[key], key, notFirst ? id : null, true);
}
}
}
} else if (typeof f === 'string') {
param && (param.dataType = 'string');
if(param) {
param.dataType = 'string';
param.remark = '@value=' + f;
}
} else if (typeof f === 'number') {
param && (param.dataType = 'number');
if(param) {
param.dataType = 'number';
param.remark = '@value=' + f;
}
} else if (typeof f === 'boolean') {
param && (param.dataType = 'boolean');
if(param) {
param.dataType = 'boolean';
param.remark = '@value=' + f;
}
} else if (typeof f === 'undefined') {
} else if (f === null) {
} else if (typeof f === 'object') {
Expand All @@ -2949,10 +2968,10 @@ var rap = rap || {};


/***************************************************
* *
* ##html-template-engine-begin *
* *
* */
* *
* ##html-template-engine-begin *
* *
* */


/**
Expand Down
Binary file not shown.
24 changes: 14 additions & 10 deletions src/com/baidu/rigel/rap/mock/service/impl/MockMgrImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,16 +337,20 @@ private void parseTags(String[] tags, Map<String, String> tagMap, boolean isMock
// tag format validation
if (tag.startsWith("@") && tag.contains("=")) {
if (tag.startsWith("@value")) {
String val = tag.split("=")[1];
if (val.contains("[xx]") && isMocking) {
Integer n = _num++ % 30;
val = val.replace("[xx]", n >= 10 ? n.toString() : "0" + n);
}
if (tag.contains("value[")) {
tagMap.put("value_index", val + "_INDEX_" + tag.substring(tag.indexOf("[") + 1, tag.indexOf("]")));
} else {
tagMap.put("value", val);
}
String[] valueSplitArr = tag.split("=");
String val = null;
if (valueSplitArr.length > 1) {
val = valueSplitArr[1];
if (val.contains("[xx]") && isMocking) {
Integer n = _num++ % 30;
val = val.replace("[xx]", n >= 10 ? n.toString() : "0" + n);
}
if (tag.contains("value[")) {
tagMap.put("value_index", val + "_INDEX_" + tag.substring(tag.indexOf("[") + 1, tag.indexOf("]")));
} else {
tagMap.put("value", val);
}
}
} else if (tag.startsWith("@format")) {
if (tag.contains("format[")) {
tagMap.put("format_index", tag.split("=")[1] + "_INDEX_" + tag.substring(tag.indexOf("[") + 1, tag.indexOf("]")));
Expand Down

0 comments on commit 0bd92e5

Please sign in to comment.