mobile_template 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +28 -0
- data/Rakefile +3 -0
- data/bin/mobile_template +71 -0
- data/lib/mobile_template/version.rb +4 -0
- data/lib/mobile_template.rb +5 -0
- data/mobile_template.gemspec +21 -0
- data/templates/assets/Gemfile +4 -0
- data/templates/assets/config.rb +96 -0
- data/templates/assets/config.ru +4 -0
- data/templates/assets/source/images/vendor/ajax-loader.gif +0 -0
- data/templates/assets/source/images/vendor/ajax-loader.png +0 -0
- data/templates/assets/source/images/vendor/icons-18-black.png +0 -0
- data/templates/assets/source/images/vendor/icons-18-white.png +0 -0
- data/templates/assets/source/images/vendor/icons-36-black.png +0 -0
- data/templates/assets/source/images/vendor/icons-36-white.png +0 -0
- data/templates/assets/source/index.html.erb +2 -0
- data/templates/assets/source/javascripts/app/index.js.coffee +2 -0
- data/templates/assets/source/javascripts/application.js.coffee +5 -0
- data/templates/assets/source/javascripts/vendor/cordova.js +4841 -0
- data/templates/assets/source/javascripts/vendor/jquery.js +9267 -0
- data/templates/assets/source/javascripts/vendor/jquery.mobile.js +7410 -0
- data/templates/assets/source/layout.erb +24 -0
- data/templates/assets/source/stylesheets/application.css.scss +2 -0
- data/templates/assets/source/stylesheets/vendor/jquery.mobile.css.scss +1872 -0
- data/templates/cordova_android/.gitignore +18 -0
- data/templates/cordova_android/LICENSE +202 -0
- data/templates/cordova_android/NOTICE +5 -0
- data/templates/cordova_android/README.md +95 -0
- data/templates/cordova_android/VERSION +1 -0
- data/templates/cordova_android/bin/BOOM +4 -0
- data/templates/cordova_android/bin/autotest +2 -0
- data/templates/cordova_android/bin/bench +29 -0
- data/templates/cordova_android/bin/create +46 -0
- data/templates/cordova_android/bin/create.bat +1 -0
- data/templates/cordova_android/bin/create.js +88 -0
- data/templates/cordova_android/bin/create.xml +79 -0
- data/templates/cordova_android/bin/node_modules/.bin/cake +7 -0
- data/templates/cordova_android/bin/node_modules/.bin/coffee +7 -0
- data/templates/cordova_android/bin/node_modules/.bin/nodeunit +120 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/.npmignore +11 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/LICENSE +22 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/README +48 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/Rakefile +78 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/bin/cake +7 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/bin/coffee +7 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/extras/jsl.conf +44 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/browser.js +75 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/cake.js +76 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/coffee-script.js +135 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/command.js +301 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/grammar.js +591 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/helpers.js +66 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/index.js +8 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/lexer.js +656 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/nodes.js +2289 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/optparse.js +111 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/parser.js +676 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/repl.js +123 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/rewriter.js +363 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/lib/scope.js +120 -0
- data/templates/cordova_android/bin/node_modules/coffee-script/package.json +27 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/.gitignore +5 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/.npmignore +3 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/CONTRIBUTORS.md +60 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/LICENSE +19 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/Makefile +126 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/README.md +432 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/bin/nodeunit +120 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/bin/nodeunit.json +10 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/async.js +623 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/console.log.js +55 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/ejs.js +125 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/deps/json2.js +483 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/nodeunit.js +1757 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/suite1.js +12 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/suite2.js +13 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/test.html +16 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/img/example_fail.png +0 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/img/example_pass.png +0 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/index.js +3 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/assert.js +316 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/core.js +260 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/nodeunit.js +82 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/browser.js +119 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/default.js +123 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/html.js +107 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/index.js +9 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/junit.js +183 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/minimal.js +112 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/skip_passed.js +105 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/track.js +48 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/types.js +187 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/lib/utils.js +209 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/man1/nodeunit.1 +95 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/nodelint.cfg +4 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/package.json +56 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/junit.xml.ejs +19 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/license.js +11 -0
- data/templates/cordova_android/bin/node_modules/nodeunit/share/nodeunit.css +70 -0
- data/templates/cordova_android/bin/templates/project/.cordova/android/readme.md +1 -0
- data/templates/cordova_android/bin/templates/project/.cordova/readme.md +3 -0
- data/templates/cordova_android/bin/templates/project/cordova/create +36 -0
- data/templates/cordova_android/bin/templates/project/cordova/debug +9 -0
- data/templates/cordova_android/bin/templates/project/cordova/emulate +12 -0
- data/templates/cordova_android/bin/templates/project/cordova/log +3 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/Activity.java +16 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/AndroidManifest.xml +50 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/index.html +42 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/main.js +146 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/master.css +96 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/drawable/icon.png +0 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/xml/cordova.xml +5 -0
- data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/xml/plugins.xml +19 -0
- data/templates/cordova_android/bin/test +26 -0
- data/templates/cordova_android/bin/tests/autotest.coffee +4 -0
- data/templates/cordova_android/bin/tests/create.coffee +21 -0
- data/templates/cordova_android/bin/tests/debug.coffee +0 -0
- data/templates/cordova_android/bin/tests/test.coffee +0 -0
- data/templates/cordova_android/framework/.classpath +8 -0
- data/templates/cordova_android/framework/.project +33 -0
- data/templates/cordova_android/framework/AndroidManifest.xml +68 -0
- data/templates/cordova_android/framework/ant.properties +34 -0
- data/templates/cordova_android/framework/assets/js/accelerometer.js +137 -0
- data/templates/cordova_android/framework/assets/js/app.js +89 -0
- data/templates/cordova_android/framework/assets/js/battery.js +134 -0
- data/templates/cordova_android/framework/assets/js/camera.js +168 -0
- data/templates/cordova_android/framework/assets/js/capture.js +203 -0
- data/templates/cordova_android/framework/assets/js/compass.js +168 -0
- data/templates/cordova_android/framework/assets/js/contact.js +310 -0
- data/templates/cordova_android/framework/assets/js/cordova.android.js +4841 -0
- data/templates/cordova_android/framework/assets/js/cordova.js.base +924 -0
- data/templates/cordova_android/framework/assets/js/crypto.js +54 -0
- data/templates/cordova_android/framework/assets/js/device.js +83 -0
- data/templates/cordova_android/framework/assets/js/file.js +1082 -0
- data/templates/cordova_android/framework/assets/js/filetransfer.js +125 -0
- data/templates/cordova_android/framework/assets/js/geolocation.js +209 -0
- data/templates/cordova_android/framework/assets/js/header.txt +19 -0
- data/templates/cordova_android/framework/assets/js/media.js +233 -0
- data/templates/cordova_android/framework/assets/js/network.js +100 -0
- data/templates/cordova_android/framework/assets/js/notification.js +133 -0
- data/templates/cordova_android/framework/assets/js/position.js +100 -0
- data/templates/cordova_android/framework/assets/js/storage.js +439 -0
- data/templates/cordova_android/framework/assets/www/index.html +27 -0
- data/templates/cordova_android/framework/build.xml +216 -0
- data/templates/cordova_android/framework/libs/commons-codec-1.3.jar +0 -0
- data/templates/cordova_android/framework/proguard-project.txt +20 -0
- data/templates/cordova_android/framework/project.properties +14 -0
- data/templates/cordova_android/framework/res/drawable/icon.png +0 -0
- data/templates/cordova_android/framework/res/drawable/splash.png +0 -0
- data/templates/cordova_android/framework/res/layout/main.xml +29 -0
- data/templates/cordova_android/framework/res/values/strings.xml +23 -0
- data/templates/cordova_android/framework/res/xml/cordova.xml +37 -0
- data/templates/cordova_android/framework/res/xml/plugins.xml +37 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/IPlugin.java +27 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/LOG.java +28 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PhonegapActivity.java +28 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/Plugin.java +27 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PluginManager.java +35 -0
- data/templates/cordova_android/framework/src/com/phonegap/api/PluginResult.java +53 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AccelListener.java +311 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/App.java +198 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AudioHandler.java +364 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AudioPlayer.java +450 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/AuthenticationToken.java +69 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/BatteryListener.java +156 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CallbackServer.java +431 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CameraLauncher.java +500 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Capture.java +400 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CompassListener.java +308 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessor.java +198 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessorSdk5.java +1934 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ContactManager.java +113 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CordovaChromeClient.java +314 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/CordovaWebViewClient.java +306 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Device.java +219 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/DirectoryManager.java +161 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/DroidGap.java +1417 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/ExifHelper.java +165 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileTransfer.java +458 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileUploadResult.java +63 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/FileUtils.java +1048 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GeoBroker.java +165 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GeoListener.java +133 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/GpsListener.java +163 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/HttpHandler.java +80 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java +104 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/NetworkListener.java +153 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/NetworkManager.java +248 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Notification.java +366 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/PreferenceNode.java +34 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/PreferenceSet.java +62 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/StandAlone.java +35 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/Storage.java +239 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/TempListener.java +112 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/CordovaInterface.java +145 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/IPlugin.java +116 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/LOG.java +234 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/Plugin.java +210 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginManager.java +359 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginResult.java +119 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/EncodingException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/FileExistsException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/InvalidModificationException.java +29 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/NoModificationAllowedException.java +28 -0
- data/templates/cordova_android/framework/src/org/apache/cordova/file/TypeMismatchException.java +29 -0
- data/templates/cordova_android/framework/test/org/apache/cordova/PreferenceNodeTest.java +53 -0
- data/templates/cordova_android/framework/test/org/apache/cordova/PreferenceSetTest.java +73 -0
- metadata +279 -0
@@ -0,0 +1,112 @@
|
|
1
|
+
/*!
|
2
|
+
* Nodeunit
|
3
|
+
* Copyright (c) 2010 Caolan McMahon
|
4
|
+
* MIT Licensed
|
5
|
+
*/
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Module dependencies
|
9
|
+
*/
|
10
|
+
|
11
|
+
var nodeunit = require('../nodeunit'),
|
12
|
+
utils = require('../utils'),
|
13
|
+
fs = require('fs'),
|
14
|
+
path = require('path'),
|
15
|
+
AssertionError = require('assert').AssertionError;
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Reporter info string
|
19
|
+
*/
|
20
|
+
|
21
|
+
exports.info = "Pretty minimal output";
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Run all tests within each module, reporting the results to the command-line.
|
25
|
+
*
|
26
|
+
* @param {Array} files
|
27
|
+
* @api public
|
28
|
+
*/
|
29
|
+
|
30
|
+
exports.run = function (files, options) {
|
31
|
+
|
32
|
+
if (!options) {
|
33
|
+
// load default options
|
34
|
+
var content = fs.readFileSync(
|
35
|
+
__dirname + '/../../bin/nodeunit.json', 'utf8'
|
36
|
+
);
|
37
|
+
options = JSON.parse(content);
|
38
|
+
}
|
39
|
+
|
40
|
+
var red = function (str) {
|
41
|
+
return options.error_prefix + str + options.error_suffix;
|
42
|
+
};
|
43
|
+
var green = function (str) {
|
44
|
+
return options.ok_prefix + str + options.ok_suffix;
|
45
|
+
};
|
46
|
+
var magenta = function (str) {
|
47
|
+
return options.assertion_prefix + str + options.assertion_suffix;
|
48
|
+
};
|
49
|
+
var bold = function (str) {
|
50
|
+
return options.bold_prefix + str + options.bold_suffix;
|
51
|
+
};
|
52
|
+
|
53
|
+
var start = new Date().getTime();
|
54
|
+
var paths = files.map(function (p) {
|
55
|
+
return path.join(process.cwd(), p);
|
56
|
+
});
|
57
|
+
|
58
|
+
nodeunit.runFiles(paths, {
|
59
|
+
testspec: options.testspec,
|
60
|
+
moduleStart: function (name) {
|
61
|
+
process.stdout.write(bold(name) + ': ');
|
62
|
+
},
|
63
|
+
moduleDone: function (name, assertions) {
|
64
|
+
console.log('');
|
65
|
+
if (assertions.failures()) {
|
66
|
+
assertions.forEach(function (a) {
|
67
|
+
if (a.failed()) {
|
68
|
+
a = utils.betterErrors(a);
|
69
|
+
if (a.error instanceof AssertionError && a.message) {
|
70
|
+
console.log(
|
71
|
+
'Assertion in test ' + bold(a.testname) + ': ' +
|
72
|
+
magenta(a.message)
|
73
|
+
);
|
74
|
+
}
|
75
|
+
console.log(a.error.stack + '\n');
|
76
|
+
}
|
77
|
+
});
|
78
|
+
}
|
79
|
+
|
80
|
+
},
|
81
|
+
testStart: function () {
|
82
|
+
},
|
83
|
+
testDone: function (name, assertions) {
|
84
|
+
if (!assertions.failures()) {
|
85
|
+
process.stdout.write('.');
|
86
|
+
}
|
87
|
+
else {
|
88
|
+
process.stdout.write(red('F'));
|
89
|
+
assertions.forEach(function (assertion) {
|
90
|
+
assertion.testname = name;
|
91
|
+
});
|
92
|
+
}
|
93
|
+
},
|
94
|
+
done: function (assertions) {
|
95
|
+
var end = new Date().getTime();
|
96
|
+
var duration = end - start;
|
97
|
+
if (assertions.failures()) {
|
98
|
+
console.log(
|
99
|
+
'\n' + bold(red('FAILURES: ')) + assertions.failures() +
|
100
|
+
'/' + assertions.length + ' assertions failed (' +
|
101
|
+
assertions.duration + 'ms)'
|
102
|
+
);
|
103
|
+
}
|
104
|
+
else {
|
105
|
+
console.log(
|
106
|
+
'\n' + bold(green('OK: ')) + assertions.length +
|
107
|
+
' assertions (' + assertions.duration + 'ms)'
|
108
|
+
);
|
109
|
+
}
|
110
|
+
}
|
111
|
+
});
|
112
|
+
};
|
@@ -0,0 +1,105 @@
|
|
1
|
+
/*!
|
2
|
+
* Nodeunit
|
3
|
+
* Copyright (c) 2010 Caolan McMahon
|
4
|
+
* MIT Licensed
|
5
|
+
*/
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Module dependencies
|
9
|
+
*/
|
10
|
+
|
11
|
+
var nodeunit = require('../nodeunit'),
|
12
|
+
utils = require('../utils'),
|
13
|
+
fs = require('fs'),
|
14
|
+
path = require('path'),
|
15
|
+
AssertionError = require('assert').AssertionError;
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Reporter info string
|
19
|
+
*/
|
20
|
+
|
21
|
+
exports.info = "Skip passed tests output";
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Run all tests within each module, reporting the results to the command-line.
|
25
|
+
*
|
26
|
+
* @param {Array} files
|
27
|
+
* @api public
|
28
|
+
*/
|
29
|
+
|
30
|
+
exports.run = function (files, options) {
|
31
|
+
|
32
|
+
if (!options) {
|
33
|
+
// load default options
|
34
|
+
var content = fs.readFileSync(
|
35
|
+
__dirname + '/../../bin/nodeunit.json', 'utf8'
|
36
|
+
);
|
37
|
+
options = JSON.parse(content);
|
38
|
+
}
|
39
|
+
|
40
|
+
var error = function (str) {
|
41
|
+
return options.error_prefix + str + options.error_suffix;
|
42
|
+
};
|
43
|
+
var ok = function (str) {
|
44
|
+
return options.ok_prefix + str + options.ok_suffix;
|
45
|
+
};
|
46
|
+
var bold = function (str) {
|
47
|
+
return options.bold_prefix + str + options.bold_suffix;
|
48
|
+
};
|
49
|
+
var assertion_message = function (str) {
|
50
|
+
return options.assertion_prefix + str + options.assertion_suffix;
|
51
|
+
};
|
52
|
+
|
53
|
+
var start = new Date().getTime();
|
54
|
+
var paths = files.map(function (p) {
|
55
|
+
return path.join(process.cwd(), p);
|
56
|
+
});
|
57
|
+
|
58
|
+
nodeunit.runFiles(paths, {
|
59
|
+
testspec: options.testspec,
|
60
|
+
moduleStart: function (name) {
|
61
|
+
console.log('\n' + bold(name));
|
62
|
+
},
|
63
|
+
testDone: function (name, assertions) {
|
64
|
+
if (assertions.failures()) {
|
65
|
+
console.log(error('✖ ' + name) + '\n');
|
66
|
+
assertions.forEach(function (a) {
|
67
|
+
if (a.failed()) {
|
68
|
+
a = utils.betterErrors(a);
|
69
|
+
if (a.error instanceof AssertionError && a.message) {
|
70
|
+
console.log(
|
71
|
+
'Assertion Message: ' + assertion_message(a.message)
|
72
|
+
);
|
73
|
+
}
|
74
|
+
console.log(a.error.stack + '\n');
|
75
|
+
}
|
76
|
+
});
|
77
|
+
}
|
78
|
+
},
|
79
|
+
moduleDone: function (name, assertions) {
|
80
|
+
if (!assertions.failures()) {
|
81
|
+
console.log('✔ all tests passed');
|
82
|
+
}
|
83
|
+
else {
|
84
|
+
console.log(error('✖ some tests failed'));
|
85
|
+
}
|
86
|
+
},
|
87
|
+
done: function (assertions) {
|
88
|
+
var end = new Date().getTime();
|
89
|
+
var duration = end - start;
|
90
|
+
if (assertions.failures()) {
|
91
|
+
console.log(
|
92
|
+
'\n' + bold(error('FAILURES: ')) + assertions.failures() +
|
93
|
+
'/' + assertions.length + ' assertions failed (' +
|
94
|
+
assertions.duration + 'ms)'
|
95
|
+
);
|
96
|
+
}
|
97
|
+
else {
|
98
|
+
console.log(
|
99
|
+
'\n' + bold(ok('OK: ')) + assertions.length +
|
100
|
+
' assertions (' + assertions.duration + 'ms)'
|
101
|
+
);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
});
|
105
|
+
};
|
@@ -0,0 +1,48 @@
|
|
1
|
+
/*!
|
2
|
+
* Simple util module to track tests. Adds a process.exit hook to print
|
3
|
+
* the undone tests.
|
4
|
+
*/
|
5
|
+
|
6
|
+
|
7
|
+
exports.createTracker = function (on_exit) {
|
8
|
+
var names = {};
|
9
|
+
var tracker = {
|
10
|
+
names: function () {
|
11
|
+
var arr = [];
|
12
|
+
for (var k in names) {
|
13
|
+
if (names.hasOwnProperty(k)) {
|
14
|
+
arr.push(k);
|
15
|
+
}
|
16
|
+
}
|
17
|
+
return arr;
|
18
|
+
},
|
19
|
+
unfinished: function () {
|
20
|
+
return tracker.names().length;
|
21
|
+
},
|
22
|
+
put: function (testname) {
|
23
|
+
names[testname] = testname;
|
24
|
+
},
|
25
|
+
remove: function (testname) {
|
26
|
+
delete names[testname];
|
27
|
+
}
|
28
|
+
};
|
29
|
+
|
30
|
+
process.on('exit', function() {
|
31
|
+
on_exit = on_exit || exports.default_on_exit;
|
32
|
+
on_exit(tracker);
|
33
|
+
});
|
34
|
+
|
35
|
+
return tracker;
|
36
|
+
};
|
37
|
+
|
38
|
+
exports.default_on_exit = function (tracker) {
|
39
|
+
if (tracker.unfinished()) {
|
40
|
+
console.log('');
|
41
|
+
console.log('Undone tests (or their setups/teardowns): ');
|
42
|
+
var names = tracker.names();
|
43
|
+
for (var i = 0; i < names.length; i += 1) {
|
44
|
+
console.log(names[i]);
|
45
|
+
}
|
46
|
+
process.reallyExit(tracker.unfinished());
|
47
|
+
}
|
48
|
+
};
|
@@ -0,0 +1,187 @@
|
|
1
|
+
/*!
|
2
|
+
* Nodeunit
|
3
|
+
* Copyright (c) 2010 Caolan McMahon
|
4
|
+
* MIT Licensed
|
5
|
+
*
|
6
|
+
* THIS FILE SHOULD BE BROWSER-COMPATIBLE JS!
|
7
|
+
* You can use @REMOVE_LINE_FOR_BROWSER to remove code from the browser build.
|
8
|
+
* Only code on that line will be removed, its mostly to avoid requiring code
|
9
|
+
* that is node specific
|
10
|
+
*/
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Module dependencies
|
14
|
+
*/
|
15
|
+
|
16
|
+
var assert = require('./assert'), //@REMOVE_LINE_FOR_BROWSER
|
17
|
+
async = require('../deps/async'); //@REMOVE_LINE_FOR_BROWSER
|
18
|
+
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Creates assertion objects representing the result of an assert call.
|
22
|
+
* Accepts an object or AssertionError as its argument.
|
23
|
+
*
|
24
|
+
* @param {object} obj
|
25
|
+
* @api public
|
26
|
+
*/
|
27
|
+
|
28
|
+
exports.assertion = function (obj) {
|
29
|
+
return {
|
30
|
+
method: obj.method || '',
|
31
|
+
message: obj.message || (obj.error && obj.error.message) || '',
|
32
|
+
error: obj.error,
|
33
|
+
passed: function () {
|
34
|
+
return !this.error;
|
35
|
+
},
|
36
|
+
failed: function () {
|
37
|
+
return Boolean(this.error);
|
38
|
+
}
|
39
|
+
};
|
40
|
+
};
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Creates an assertion list object representing a group of assertions.
|
44
|
+
* Accepts an array of assertion objects.
|
45
|
+
*
|
46
|
+
* @param {Array} arr
|
47
|
+
* @param {Number} duration
|
48
|
+
* @api public
|
49
|
+
*/
|
50
|
+
|
51
|
+
exports.assertionList = function (arr, duration) {
|
52
|
+
var that = arr || [];
|
53
|
+
that.failures = function () {
|
54
|
+
var failures = 0;
|
55
|
+
for (var i=0; i<this.length; i++) {
|
56
|
+
if (this[i].failed()) failures++;
|
57
|
+
}
|
58
|
+
return failures;
|
59
|
+
};
|
60
|
+
that.passes = function () {
|
61
|
+
return that.length - that.failures();
|
62
|
+
};
|
63
|
+
that.duration = duration || 0;
|
64
|
+
return that;
|
65
|
+
};
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Create a wrapper function for assert module methods. Executes a callback
|
69
|
+
* after the it's complete with an assertion object representing the result.
|
70
|
+
*
|
71
|
+
* @param {Function} callback
|
72
|
+
* @api private
|
73
|
+
*/
|
74
|
+
|
75
|
+
var assertWrapper = function (callback) {
|
76
|
+
return function (new_method, assert_method, arity) {
|
77
|
+
return function () {
|
78
|
+
var message = arguments[arity-1];
|
79
|
+
var a = exports.assertion({method: new_method, message: message});
|
80
|
+
try {
|
81
|
+
assert[assert_method].apply(null, arguments);
|
82
|
+
}
|
83
|
+
catch (e) {
|
84
|
+
a.error = e;
|
85
|
+
}
|
86
|
+
callback(a);
|
87
|
+
};
|
88
|
+
};
|
89
|
+
};
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Creates the 'test' object that gets passed to every test function.
|
93
|
+
* Accepts the name of the test function as its first argument, followed by
|
94
|
+
* the start time in ms, the options object and a callback function.
|
95
|
+
*
|
96
|
+
* @param {String} name
|
97
|
+
* @param {Number} start
|
98
|
+
* @param {Object} options
|
99
|
+
* @param {Function} callback
|
100
|
+
* @api public
|
101
|
+
*/
|
102
|
+
|
103
|
+
exports.test = function (name, start, options, callback) {
|
104
|
+
var expecting;
|
105
|
+
var a_list = [];
|
106
|
+
|
107
|
+
var wrapAssert = assertWrapper(function (a) {
|
108
|
+
a_list.push(a);
|
109
|
+
if (options.log) {
|
110
|
+
async.nextTick(function () {
|
111
|
+
options.log(a);
|
112
|
+
});
|
113
|
+
}
|
114
|
+
});
|
115
|
+
|
116
|
+
var test = {
|
117
|
+
done: function (err) {
|
118
|
+
if (expecting !== undefined && expecting !== a_list.length) {
|
119
|
+
var e = new Error(
|
120
|
+
'Expected ' + expecting + ' assertions, ' +
|
121
|
+
a_list.length + ' ran'
|
122
|
+
);
|
123
|
+
var a1 = exports.assertion({method: 'expect', error: e});
|
124
|
+
a_list.push(a1);
|
125
|
+
if (options.log) {
|
126
|
+
async.nextTick(function () {
|
127
|
+
options.log(a1);
|
128
|
+
});
|
129
|
+
}
|
130
|
+
}
|
131
|
+
if (err) {
|
132
|
+
var a2 = exports.assertion({error: err});
|
133
|
+
a_list.push(a2);
|
134
|
+
if (options.log) {
|
135
|
+
async.nextTick(function () {
|
136
|
+
options.log(a2);
|
137
|
+
});
|
138
|
+
}
|
139
|
+
}
|
140
|
+
var end = new Date().getTime();
|
141
|
+
async.nextTick(function () {
|
142
|
+
var assertion_list = exports.assertionList(a_list, end - start);
|
143
|
+
options.testDone(name, assertion_list);
|
144
|
+
callback(null, a_list);
|
145
|
+
});
|
146
|
+
},
|
147
|
+
ok: wrapAssert('ok', 'ok', 2),
|
148
|
+
same: wrapAssert('same', 'deepEqual', 3),
|
149
|
+
equals: wrapAssert('equals', 'equal', 3),
|
150
|
+
expect: function (num) {
|
151
|
+
expecting = num;
|
152
|
+
},
|
153
|
+
_assertion_list: a_list
|
154
|
+
};
|
155
|
+
// add all functions from the assert module
|
156
|
+
for (var k in assert) {
|
157
|
+
if (assert.hasOwnProperty(k)) {
|
158
|
+
test[k] = wrapAssert(k, k, assert[k].length);
|
159
|
+
}
|
160
|
+
}
|
161
|
+
return test;
|
162
|
+
};
|
163
|
+
|
164
|
+
/**
|
165
|
+
* Ensures an options object has all callbacks, adding empty callback functions
|
166
|
+
* if any are missing.
|
167
|
+
*
|
168
|
+
* @param {Object} opt
|
169
|
+
* @return {Object}
|
170
|
+
* @api public
|
171
|
+
*/
|
172
|
+
|
173
|
+
exports.options = function (opt) {
|
174
|
+
var optionalCallback = function (name) {
|
175
|
+
opt[name] = opt[name] || function () {};
|
176
|
+
};
|
177
|
+
|
178
|
+
optionalCallback('moduleStart');
|
179
|
+
optionalCallback('moduleDone');
|
180
|
+
optionalCallback('testStart');
|
181
|
+
optionalCallback('testDone');
|
182
|
+
//optionalCallback('log');
|
183
|
+
|
184
|
+
// 'done' callback is not optional.
|
185
|
+
|
186
|
+
return opt;
|
187
|
+
};
|
@@ -0,0 +1,209 @@
|
|
1
|
+
/*!
|
2
|
+
* Nodeunit
|
3
|
+
* Copyright (c) 2010 Caolan McMahon
|
4
|
+
* MIT Licensed
|
5
|
+
*/
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Module dependencies
|
9
|
+
*/
|
10
|
+
|
11
|
+
var async = require('../deps/async'),
|
12
|
+
fs = require('fs'),
|
13
|
+
util = require('util'),
|
14
|
+
Script = process.binding('evals').Script,
|
15
|
+
http = require('http');
|
16
|
+
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Detect if coffee-script is available and search for .coffee as an
|
20
|
+
* extension in modulePaths if it is.
|
21
|
+
*/
|
22
|
+
|
23
|
+
var extensionPattern;
|
24
|
+
try {
|
25
|
+
require('coffee-script');
|
26
|
+
extensionPattern = /\.(?:js|coffee)$/;
|
27
|
+
}
|
28
|
+
catch (e) {
|
29
|
+
extensionPattern = /\.js$/;
|
30
|
+
}
|
31
|
+
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Finds all modules at each path in an array, If a path is a directory, it
|
35
|
+
* returns all supported file types inside it. This only reads 1 level deep in
|
36
|
+
* the directory and does not recurse through sub-directories.
|
37
|
+
*
|
38
|
+
* The extension (.js, .coffee etc) is stripped from the filenames so they can
|
39
|
+
* simply be require()'ed.
|
40
|
+
*
|
41
|
+
* @param {Array} paths
|
42
|
+
* @param {Function} callback
|
43
|
+
* @api public
|
44
|
+
*/
|
45
|
+
|
46
|
+
exports.modulePaths = function (paths, callback) {
|
47
|
+
async.concat(paths, function (p, cb) {
|
48
|
+
fs.stat(p, function (err, stats) {
|
49
|
+
if (err) {
|
50
|
+
return cb(err);
|
51
|
+
}
|
52
|
+
if (stats.isFile()) {
|
53
|
+
return cb(null, [p]);
|
54
|
+
}
|
55
|
+
if (stats.isDirectory()) {
|
56
|
+
fs.readdir(p, function (err, files) {
|
57
|
+
if (err) {
|
58
|
+
return cb(err);
|
59
|
+
}
|
60
|
+
|
61
|
+
// filter out any filenames with unsupported extensions
|
62
|
+
var modules = files.filter(function (filename) {
|
63
|
+
return extensionPattern.exec(filename);
|
64
|
+
});
|
65
|
+
|
66
|
+
// remove extension from module name and prepend the
|
67
|
+
// directory path
|
68
|
+
var fullpaths = modules.map(function (filename) {
|
69
|
+
var mod_name = filename.replace(extensionPattern, '');
|
70
|
+
return [p, mod_name].join('/');
|
71
|
+
});
|
72
|
+
|
73
|
+
// sort filenames here, because Array.map changes order
|
74
|
+
fullpaths.sort();
|
75
|
+
|
76
|
+
cb(null, fullpaths);
|
77
|
+
});
|
78
|
+
}
|
79
|
+
});
|
80
|
+
}, callback);
|
81
|
+
};
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Evaluates JavaScript files in a sandbox, returning the context. The first
|
85
|
+
* argument can either be a single filename or an array of filenames. If
|
86
|
+
* multiple filenames are given their contents are concatenated before
|
87
|
+
* evalution. The second argument is an optional context to use for the sandbox.
|
88
|
+
*
|
89
|
+
* @param files
|
90
|
+
* @param {Object} sandbox
|
91
|
+
* @return {Object}
|
92
|
+
* @api public
|
93
|
+
*/
|
94
|
+
|
95
|
+
exports.sandbox = function (files, /*optional*/sandbox) {
|
96
|
+
var source, script, result;
|
97
|
+
if (!(files instanceof Array)) {
|
98
|
+
files = [files];
|
99
|
+
}
|
100
|
+
source = files.map(function (file) {
|
101
|
+
return fs.readFileSync(file, 'utf8');
|
102
|
+
}).join('');
|
103
|
+
|
104
|
+
if (!sandbox) {
|
105
|
+
sandbox = {};
|
106
|
+
}
|
107
|
+
script = new Script(source);
|
108
|
+
result = script.runInNewContext(sandbox);
|
109
|
+
return sandbox;
|
110
|
+
};
|
111
|
+
|
112
|
+
/**
|
113
|
+
* Provides a http request, response testing environment.
|
114
|
+
*
|
115
|
+
* Example:
|
116
|
+
*
|
117
|
+
* var httputil = require('nodeunit').utils.httputil
|
118
|
+
* exports.testSomething = function(test) {
|
119
|
+
* httputil(function (req, resp) {
|
120
|
+
* resp.writeHead(200, {});
|
121
|
+
* resp.end('test data');
|
122
|
+
* },
|
123
|
+
* function(server, client) {
|
124
|
+
* client.fetch('GET', '/', {}, function(resp) {
|
125
|
+
* test.equal('test data', resp.body);
|
126
|
+
* server.close();
|
127
|
+
* test.done();
|
128
|
+
* })
|
129
|
+
* });
|
130
|
+
* };
|
131
|
+
*
|
132
|
+
* @param {Function} cgi
|
133
|
+
* @param {Function} envReady
|
134
|
+
* @api public
|
135
|
+
*/
|
136
|
+
exports.httputil = function (cgi, envReady) {
|
137
|
+
var hostname = process.env.HOSTNAME || 'localhost';
|
138
|
+
var port = process.env.PORT || 3000;
|
139
|
+
|
140
|
+
var server = http.createServer(cgi);
|
141
|
+
server.listen(port, hostname);
|
142
|
+
|
143
|
+
var client = http.createClient(port, hostname);
|
144
|
+
client.fetch = function (method, path, headers, respReady) {
|
145
|
+
var request = this.request(method, path, headers);
|
146
|
+
request.end();
|
147
|
+
request.on('response', function (response) {
|
148
|
+
response.setEncoding('utf8');
|
149
|
+
response.on('data', function (chunk) {
|
150
|
+
if (response.body) {
|
151
|
+
response.body += chunk;
|
152
|
+
} else {
|
153
|
+
response.body = chunk;
|
154
|
+
}
|
155
|
+
});
|
156
|
+
response.on('end', function () {
|
157
|
+
if (response.headers['content-type'] === 'application/json') {
|
158
|
+
response.bodyAsObject = JSON.parse(response.body);
|
159
|
+
}
|
160
|
+
respReady(response);
|
161
|
+
});
|
162
|
+
});
|
163
|
+
};
|
164
|
+
|
165
|
+
process.nextTick(function () {
|
166
|
+
if (envReady && typeof envReady === 'function') {
|
167
|
+
envReady(server, client);
|
168
|
+
}
|
169
|
+
});
|
170
|
+
};
|
171
|
+
|
172
|
+
|
173
|
+
/**
|
174
|
+
* Improves formatting of AssertionError messages to make deepEqual etc more
|
175
|
+
* readable.
|
176
|
+
*
|
177
|
+
* @param {Object} assertion
|
178
|
+
* @return {Object}
|
179
|
+
* @api public
|
180
|
+
*/
|
181
|
+
|
182
|
+
exports.betterErrors = function (assertion) {
|
183
|
+
if (!assertion.error) return;
|
184
|
+
|
185
|
+
var e = assertion.error;
|
186
|
+
// deepEqual error message is a bit sucky, lets improve it!
|
187
|
+
// e.actual and e.expected could be null or undefined, so
|
188
|
+
// using getOwnPropertyDescriptor to see if they exist:
|
189
|
+
if (Object.getOwnPropertyDescriptor(e, 'actual') &&
|
190
|
+
Object.getOwnPropertyDescriptor(e, 'expected')) {
|
191
|
+
|
192
|
+
// alexgorbatchev 2010-10-22 :: Added a bit of depth to inspection
|
193
|
+
var actual = util.inspect(e.actual, false, 10).replace(/\n$/, '');
|
194
|
+
var expected = util.inspect(e.expected, false, 10).replace(/\n$/, '');
|
195
|
+
var multiline = (
|
196
|
+
actual.indexOf('\n') !== -1 ||
|
197
|
+
expected.indexOf('\n') !== -1
|
198
|
+
);
|
199
|
+
var spacing = (multiline ? '\n' : ' ');
|
200
|
+
e._message = e.message;
|
201
|
+
e.stack = (
|
202
|
+
e.name + ':' + spacing +
|
203
|
+
actual + spacing + e.operator + spacing +
|
204
|
+
expected + '\n' +
|
205
|
+
e.stack.split('\n').slice(1).join('\n')
|
206
|
+
);
|
207
|
+
}
|
208
|
+
return assertion;
|
209
|
+
};
|