Skip to content

Commit 59974d1

Browse files
committed
New build & test process, update test suite and libs. New README.
* Build process - into ./build directory. - Puts version (from version.txt) and current date on top. - Build command into build.sh, shortcut: $ sh build.sh * Test infrastructure - Renamed to index.html for easy access from the directory, - Removed duplicate test.min.html file, added [build-min] option in QUnit checkboxes in index.html - Added cache buster with timestamp so that test suite always uses the latest development version. * Test suite - Update test suite to use new QUnit 'assert' structure. - Lint everything * Save jquery in ./libs/jquery.js (no hardcoded version in filename) so that we don't have to update references to it every time. * Updated README and moved into root.
1 parent 3b5fe2c commit 59974d1

File tree

12 files changed

+178
-178
lines changed

12 files changed

+178
-178
lines changed

README

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## Build
2+
3+
To run the minifier, run this command from the root directory of the repository:
4+
5+
$ sh ./build.sh
6+
7+
## Test
8+
9+
Open up ./test/index.html in your browsers and run the test.
10+
For it to pass in modern browsers, you have to enable the `disable_native`
11+
option from the QUnit toolbar.
12+
13+
Also, before releasing. Make sure to test the build version as well, you can
14+
do so by enabling the `build-min` option in the QUnit toolbar. This will load
15+
the code from the `./build/` directory instead of `./src/`.
16+
17+
## Version
18+
19+
We use the Semantic Versioning guidelines as much as possible.
20+
21+
Releases will be numbered in the following format:
22+
23+
<major>.<minor>.<patch>
24+
25+
The -alpha suffix is used to indicate unreleased versions in development.
26+
27+
For more information on SemVer, please visit http://semver.org/.

build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
printf '/*! jQuery JSON plugin %s | code.google.com/p/jquery-json */' "$(cat version.txt)" > build/jquery.json.min.js;
2+
python libs/jsmin.py < src/jquery.json.js >> build/jquery.json.min.js;

build/jquery.json.min.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*! jQuery JSON plugin 2.4-alpha | code.google.com/p/jquery-json */
2+
(function($){"use strict";var escapeable=/["\\\x00-\x1f\x7f-\x9f]/g,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},hasOwn=Object.prototype.hasOwnProperty;$.toJSON=typeof JSON==='object'&&JSON.stringify?JSON.stringify:function(o){if(o===null){return'null';}
3+
var pairs,i,k,name,val,type=typeof o,$type=$.type(o);if(type==='undefined'){return undefined;}
4+
if(type==='number'||type==='boolean'){return String(o);}
5+
if(type==='string'){return $.quoteString(o);}
6+
if(type==='object'){if(typeof o.toJSON==='function'){return $.toJSON(o.toJSON());}
7+
if($type==='date'){var month=o.getUTCMonth()+1,day=o.getUTCDate(),year=o.getUTCFullYear(),hours=o.getUTCHours(),minutes=o.getUTCMinutes(),seconds=o.getUTCSeconds(),milli=o.getUTCMilliseconds();if(month<10){month='0'+month;}
8+
if(day<10){day='0'+day;}
9+
if(hours<10){hours='0'+hours;}
10+
if(minutes<10){minutes='0'+minutes;}
11+
if(seconds<10){seconds='0'+seconds;}
12+
if(milli<100){milli='0'+milli;}
13+
if(milli<10){milli='0'+milli;}
14+
return'"'+year+'-'+month+'-'+day+'T'+
15+
hours+':'+minutes+':'+seconds+'.'+milli+'Z"';}
16+
pairs=[];if($.isArray(o)){for(i=0;i<o.length;i++){pairs.push($.toJSON(o[i])||'null');}
17+
return'['+pairs.join(',')+']';}
18+
for(k in o){if(!hasOwn.call(o,k)){continue;}
19+
type=typeof k;if(type==='number'){name='"'+k+'"';}else if(type==='string'){name=$.quoteString(k);}else{continue;}
20+
type=typeof o[k];if(type==='function'||type==='undefined'){continue;}
21+
val=$.toJSON(o[k]);pairs.push(name+':'+val);}
22+
return'{'+pairs.join(',')+'}';}};$.evalJSON=typeof JSON==='object'&&JSON.parse?JSON.parse:function(src){return eval('('+src+')');};$.secureEvalJSON=typeof JSON==='object'&&JSON.parse?JSON.parse:function(src){var filtered=src.replace(/\\["\\\/bfnrtu]/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,'');if(/^[\],:{}\s]*$/.test(filtered)){return eval('('+src+')');}
23+
throw new SyntaxError('Error parsing JSON, source is not valid.');};$.quoteString=function(string){if(string.match(escapeable)){return'"'+string.replace(escapeable,function(a){var c=meta[a];if(typeof c==='string'){return c;}
24+
c=a.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+(c%16).toString(16);})+'"';}
25+
return'"'+string+'"';};}(jQuery));

libs/README

Lines changed: 0 additions & 3 deletions
This file was deleted.
File renamed without changes.

src/jquery.json.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* jQuery JSON Plugin v2.4-edge (2012-05-13)
2+
* jQuery JSON plugin 2.4-alpha
33
*
44
* @author Brantley Harris, 2009-2011
55
* @author Timo Tijhof, 2011-2012

src/jquery.json.min.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

test/index.html

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<!-- Libs -->
5+
<script src="../libs/jquery.js"></script>
6+
<script src="../libs/jquery.qunit.js"></script>
7+
<link rel="stylesheet" href="../libs/jquery.qunit.css">
8+
<!-- Testrun preparation -->
9+
<script>
10+
/**
11+
* Implement 'min' option.
12+
* Also makes sure we force a cache miss to ease develoment.
13+
*/
14+
QUnit.config.urlConfig.push('build-min');
15+
16+
var srcPath,
17+
cacheBust = '?' + (+new Date());
18+
19+
if (QUnit.urlParams['build-min']) {
20+
srcPath = '../build/jquery.json.min.js';
21+
} else {
22+
srcPath = '../src/jquery.json.js';
23+
}
24+
25+
// Load source
26+
document.write(
27+
'<script src="' + srcPath + cacheBust + '"><\/script>'
28+
);
29+
30+
// Load test suite
31+
document.write(
32+
'<script src="jquery.json.test.js' + cacheBust + '"><\/script>'
33+
);
34+
35+
/**
36+
* Implement 'disable native' option.
37+
* Useful for disabling the browsers native JSON api,
38+
* and thus test the plugins methods instead.
39+
*/
40+
41+
// Adds a checkbox to QUnit's header for 'disable_native'
42+
QUnit.config.urlConfig.push('disable_native');
43+
44+
if (QUnit.urlParams.disable_native) {
45+
// Unset the native methods in order to trigger the plugin's methods
46+
window.JSON = undefined;
47+
}
48+
</script>
49+
</head>
50+
<body>
51+
<h1 id="qunit-header">jQuery JSON Test Suite</h1>
52+
<h2 id="qunit-banner"></h2>
53+
<div id="qunit-testrunner-toolbar"></div>
54+
<h2 id="qunit-userAgent"></h2>
55+
<ol id="qunit-tests"></ol></body>
56+
</html>

0 commit comments

Comments
 (0)