ninjs 0.14.1 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.bundle/config +2 -2
- data/.travis.yml +1 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +13 -11
- data/README.md +108 -93
- data/Rakefile +17 -7
- data/VERSION +1 -1
- data/bin/ninjs +24 -22
- data/lib/ninjs/command.rb +32 -21
- data/lib/ninjs/configuration.rb +35 -53
- data/lib/ninjs/generator.rb +6 -6
- data/lib/ninjs/notification.rb +5 -5
- data/lib/ninjs/project.rb +31 -25
- data/ninjs.gemspec +18 -142
- data/repository/ninjs/core/application.js +13 -24
- data/repository/ninjs/core/dom.js +87 -68
- data/repository/ninjs/core/existence.js +44 -105
- data/repository/ninjs/core/extend.js +11 -32
- data/repository/ninjs/core/module.js +53 -107
- data/repository/ninjs/core/nin.js +5 -7
- data/repository/ninjs/tests/extension.test.js +0 -10
- data/repository/ninjs/tests/index.html +19 -20
- data/repository/ninjs/tests/module.test.js +52 -56
- data/repository/ninjs/utilities/array.js +8 -8
- data/repository/ninjs/utilities/cookie.js +59 -0
- data/repository/ninjs/utilities/css.js +7 -7
- data/repository/ninjs/utilities/number.js +2 -2
- data/repository/ninjs/utilities/string.js +26 -26
- data/spec/cli_spec.rb +90 -88
- data/spec/command_spec.rb +104 -137
- data/spec/configuration_spec.rb +23 -37
- data/spec/fixtures/_global.module.js +9 -0
- data/spec/fixtures/compressed.myapp.js +23 -44
- data/spec/fixtures/foo.elements.js +1 -1
- data/spec/fixtures/foo.js +5 -5
- data/spec/fixtures/foo.model.js +1 -1
- data/spec/fixtures/foo.module.js +3 -3
- data/spec/fixtures/hello.elements.js +1 -1
- data/spec/fixtures/hello.js +5 -5
- data/spec/fixtures/hello.model.js +1 -1
- data/spec/fixtures/hello.module.js +3 -3
- data/spec/fixtures/myapp.initial.js +198 -329
- data/spec/fixtures/myapp.js +285 -357
- data/spec/fixtures/mymodule.alias.module.js +2 -2
- data/spec/fixtures/mymodule.dependencies.module.js +2 -2
- data/spec/fixtures/mymodule.elements.js +1 -1
- data/spec/fixtures/mymodule.model.js +1 -1
- data/spec/fixtures/mymodule.module.js +2 -2
- data/spec/fixtures/mymodule.module_alias.module.js +10 -0
- data/spec/fixtures/new.ninjs.conf +2 -0
- data/spec/fixtures/nin.js +198 -329
- data/spec/fixtures/ninjs.conf +2 -0
- data/spec/fixtures/updated.ninjs.conf +8 -0
- data/spec/generator_spec.rb +37 -26
- data/spec/ninjs_spec.rb +6 -6
- data/spec/project_spec.rb +229 -221
- data/spec/spec_helper.rb +3 -1
- data/spec/testspec_spec.rb +7 -0
- metadata +28 -145
- data/repository/json2.js +0 -482
- data/repository/modernizr/1.5.js +0 -28
- data/repository/modernizr/latest.js +0 -1
- data/repository/ninjs/docs/Data/ClassHierarchy.nd +0 -0
- data/repository/ninjs/docs/Data/ConfigFileInfo.nd +0 -0
- data/repository/ninjs/docs/Data/FileInfo.nd +0 -16
- data/repository/ninjs/docs/Data/ImageFileInfo.nd +0 -0
- data/repository/ninjs/docs/Data/ImageReferenceTable.nd +0 -0
- data/repository/ninjs/docs/Data/IndexInfo.nd +0 -0
- data/repository/ninjs/docs/Data/PreviousMenuState.nd +0 -0
- data/repository/ninjs/docs/Data/PreviousSettings.nd +0 -0
- data/repository/ninjs/docs/Data/SymbolTable.nd +0 -0
- data/repository/ninjs/docs/Languages.txt +0 -113
- data/repository/ninjs/docs/Menu.txt +0 -63
- data/repository/ninjs/docs/Topics.txt +0 -81
- data/repository/ninjs/docs/files/core/application-js.html +0 -44
- data/repository/ninjs/docs/files/core/existence-js.html +0 -60
- data/repository/ninjs/docs/files/core/extend-js.html +0 -55
- data/repository/ninjs/docs/files/core/module-js.html +0 -80
- data/repository/ninjs/docs/files/core/nin-js.html +0 -38
- data/repository/ninjs/docs/index.html +0 -1
- data/repository/ninjs/docs/index/Classes.html +0 -33
- data/repository/ninjs/docs/index/Files.html +0 -45
- data/repository/ninjs/docs/index/Functions.html +0 -65
- data/repository/ninjs/docs/index/General.html +0 -85
- data/repository/ninjs/docs/index/Variables.html +0 -45
- data/repository/ninjs/docs/javascript/main.js +0 -841
- data/repository/ninjs/docs/javascript/prettify.js +0 -1526
- data/repository/ninjs/docs/javascript/searchdata.js +0 -152
- data/repository/ninjs/docs/search/ClassesN.html +0 -20
- data/repository/ninjs/docs/search/FilesA.html +0 -20
- data/repository/ninjs/docs/search/FilesE.html +0 -20
- data/repository/ninjs/docs/search/FilesM.html +0 -20
- data/repository/ninjs/docs/search/FilesN.html +0 -20
- data/repository/ninjs/docs/search/FunctionsA.html +0 -20
- data/repository/ninjs/docs/search/FunctionsC.html +0 -20
- data/repository/ninjs/docs/search/FunctionsE.html +0 -20
- data/repository/ninjs/docs/search/FunctionsI.html +0 -20
- data/repository/ninjs/docs/search/FunctionsM.html +0 -20
- data/repository/ninjs/docs/search/FunctionsR.html +0 -20
- data/repository/ninjs/docs/search/FunctionsS.html +0 -20
- data/repository/ninjs/docs/search/FunctionsSymbols.html +0 -20
- data/repository/ninjs/docs/search/FunctionsU.html +0 -20
- data/repository/ninjs/docs/search/GeneralA.html +0 -20
- data/repository/ninjs/docs/search/GeneralC.html +0 -20
- data/repository/ninjs/docs/search/GeneralD.html +0 -20
- data/repository/ninjs/docs/search/GeneralE.html +0 -20
- data/repository/ninjs/docs/search/GeneralF.html +0 -20
- data/repository/ninjs/docs/search/GeneralI.html +0 -20
- data/repository/ninjs/docs/search/GeneralM.html +0 -20
- data/repository/ninjs/docs/search/GeneralN.html +0 -20
- data/repository/ninjs/docs/search/GeneralR.html +0 -20
- data/repository/ninjs/docs/search/GeneralS.html +0 -20
- data/repository/ninjs/docs/search/GeneralSymbols.html +0 -20
- data/repository/ninjs/docs/search/GeneralT.html +0 -20
- data/repository/ninjs/docs/search/GeneralU.html +0 -20
- data/repository/ninjs/docs/search/GeneralV.html +0 -20
- data/repository/ninjs/docs/search/NoResults.html +0 -15
- data/repository/ninjs/docs/search/VariablesD.html +0 -20
- data/repository/ninjs/docs/search/VariablesN.html +0 -20
- data/repository/ninjs/docs/search/VariablesR.html +0 -20
- data/repository/ninjs/docs/search/VariablesT.html +0 -20
- data/repository/ninjs/docs/styles/main.css +0 -828
- data/repository/nullconsole.js +0 -7
- data/repository/qunit/assets/css/qunit.css +0 -196
- data/repository/qunit/qunit.js +0 -1374
- data/repository/selectivizr/1.0.js +0 -5
- data/repository/selectivizr/latest.js +0 -1
- data/repository/syntaxhighlighter/all.js +0 -11
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCore.css +0 -226
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreDefault.css +0 -328
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreDjango.css +0 -331
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreEclipse.css +0 -339
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreEmacs.css +0 -324
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreFadeToGrey.css +0 -328
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreMDUltra.css +0 -324
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreMidnight.css +0 -324
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shCoreRDark.css +0 -324
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeDefault.css +0 -117
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeDjango.css +0 -120
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeEclipse.css +0 -128
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeEmacs.css +0 -113
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeFadeToGrey.css +0 -117
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeMDUltra.css +0 -113
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeMidnight.css +0 -113
- data/repository/syntaxhighlighter/assets/css/syntaxhighlighter/shThemeRDark.css +0 -113
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCore.scss +0 -216
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreDefault.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreDjango.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreEclipse.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreEmacs.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreFadeToGrey.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreMDUltra.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreMidnight.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shCoreRDark.scss +0 -2
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeDefault.scss +0 -7
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeDjango.scss +0 -36
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeEclipse.scss +0 -48
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeEmacs.scss +0 -32
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeFadeToGrey.scss +0 -36
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeMDUltra.scss +0 -32
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeMidnight.scss +0 -32
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_shThemeRDark.scss +0 -32
- data/repository/syntaxhighlighter/assets/scss/syntaxhighlighter/_theme_template.scss +0 -120
- data/repository/syntaxhighlighter/shAutoloader.js +0 -17
- data/repository/syntaxhighlighter/shBrushAS3.js +0 -59
- data/repository/syntaxhighlighter/shBrushAppleScript.js +0 -75
- data/repository/syntaxhighlighter/shBrushBash.js +0 -59
- data/repository/syntaxhighlighter/shBrushCSharp.js +0 -65
- data/repository/syntaxhighlighter/shBrushColdFusion.js +0 -100
- data/repository/syntaxhighlighter/shBrushCpp.js +0 -97
- data/repository/syntaxhighlighter/shBrushCss.js +0 -91
- data/repository/syntaxhighlighter/shBrushDelphi.js +0 -55
- data/repository/syntaxhighlighter/shBrushDiff.js +0 -41
- data/repository/syntaxhighlighter/shBrushErlang.js +0 -52
- data/repository/syntaxhighlighter/shBrushGroovy.js +0 -67
- data/repository/syntaxhighlighter/shBrushJScript.js +0 -52
- data/repository/syntaxhighlighter/shBrushJava.js +0 -57
- data/repository/syntaxhighlighter/shBrushJavaFX.js +0 -58
- data/repository/syntaxhighlighter/shBrushPerl.js +0 -72
- data/repository/syntaxhighlighter/shBrushPhp.js +0 -88
- data/repository/syntaxhighlighter/shBrushPlain.js +0 -33
- data/repository/syntaxhighlighter/shBrushPowerShell.js +0 -74
- data/repository/syntaxhighlighter/shBrushPython.js +0 -64
- data/repository/syntaxhighlighter/shBrushRuby.js +0 -55
- data/repository/syntaxhighlighter/shBrushSass.js +0 -94
- data/repository/syntaxhighlighter/shBrushScala.js +0 -51
- data/repository/syntaxhighlighter/shBrushSql.js +0 -66
- data/repository/syntaxhighlighter/shBrushVb.js +0 -56
- data/repository/syntaxhighlighter/shBrushXml.js +0 -69
- data/repository/syntaxhighlighter/shCore.js +0 -17
- data/repository/syntaxhighlighter/shLegacy.js +0 -17
@@ -1,33 +1,29 @@
|
|
1
1
|
var spec = new QSpec('NinjsModule');
|
2
2
|
|
3
3
|
spec.should('return the module when adding a module', function() {
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
var test_app = new NinjsApplication('myapp');
|
5
|
+
var module = test_app.add_module('mymod');
|
6
|
+
console.log(module);
|
7
|
+
equals(module, test_app.mymod, 'returns the module when adding a module');
|
7
8
|
});
|
8
9
|
|
9
10
|
spec.should("have the correct defaults", function() {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
ok(is_defined(testapp.testmodule.run), 'testapp.testmodule.run is defined');
|
27
|
-
ok(is_typeof(Function, testapp.testmodule.run), "testapp.testmodule.run is a valid Function");
|
28
|
-
ok(is_defined(testapp.testmodule.execute), 'testmodule.testapp.execute is defined');
|
29
|
-
ok(is_defined(testapp.testmodule.elements), 'testapp.testmodule.elements is defined');
|
30
|
-
ok(is_defined(testapp.testmodule.set_data), 'testapp.testmodule.set_data is defined');
|
11
|
+
var testapp = new NinjsApplication();
|
12
|
+
testapp.add_module('testmodule');
|
13
|
+
|
14
|
+
// properties
|
15
|
+
ok(is_defined(testapp.testmodule.data), "testapp.testmodule.data is defined");
|
16
|
+
ok(is_defined(testapp.testmodule.name), 'testapp.testmodule.name is defined');
|
17
|
+
equals(testapp.testmodule.name, 'testmodule', 'testapp.testmodule.name is correct');
|
18
|
+
|
19
|
+
// methods
|
20
|
+
ok(is_defined(testapp.testmodule.actions), 'testapp.testmodule.actions is defined');
|
21
|
+
ok(is_typeof(Function, testapp.testmodule.actions), "testapp.testmodule.actions is a valid Function");
|
22
|
+
ok(is_defined(testapp.testmodule.run), 'testapp.testmodule.run is defined');
|
23
|
+
ok(is_typeof(Function, testapp.testmodule.run), "testapp.testmodule.run is a valid Function");
|
24
|
+
ok(is_defined(testapp.testmodule.execute), 'testmodule.testapp.execute is defined');
|
25
|
+
ok(is_defined(testapp.testmodule.elements), 'testapp.testmodule.elements is defined');
|
26
|
+
ok(is_defined(testapp.testmodule.set_data), 'testapp.testmodule.set_data is defined');
|
31
27
|
});
|
32
28
|
|
33
29
|
spec.run_all();
|
@@ -35,41 +31,41 @@ spec.run_all();
|
|
35
31
|
// Qunit waits for DOM to load before running tests
|
36
32
|
// to test DOM wait feature, we need to run some code outside the tests
|
37
33
|
(function() {
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
34
|
+
var spec = new QSpec('NinjsModule');
|
35
|
+
|
36
|
+
var testapp = new NinjsApplication();
|
37
|
+
testapp.add_module('testmodule');
|
38
|
+
testapp.testmodule.actions = function() {
|
39
|
+
// append an element to be sure the DOM is ready for manipulation and test for the element's existence
|
40
|
+
$('body').append('<div id="made-by-actions"/>');
|
41
|
+
|
42
|
+
spec.should("run the module actions", function() {
|
43
|
+
equals($('#made-by-actions').length, 1,'testapp.test.actions ran after DOM was ready');
|
44
|
+
});
|
45
|
+
|
46
|
+
spec.run_all();
|
47
|
+
};
|
48
|
+
|
49
|
+
testapp.testmodule.run();
|
54
50
|
}());
|
55
51
|
|
56
52
|
// Qunit waits for DOM to load before running tests
|
57
53
|
// to test DOM wait feature, we need to run some code outside the tests
|
58
54
|
(function() {
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
55
|
+
spec.should('set elements', function() {
|
56
|
+
this.app = new NinjsApplication('myapp');
|
57
|
+
var mod = this.app.add_module('mymod');
|
58
|
+
|
59
|
+
|
60
|
+
mod.dom.ready(function() {
|
61
|
+
mod.elements({
|
62
|
+
body: $('body')
|
63
|
+
});
|
64
|
+
|
65
|
+
equals(mod.elements('body').length, 1, 'mod.elements("body") has length of 1');
|
66
|
+
equals(mod.elements('body').text(), $('body').text(), 'mod.elements("body").text() = $("body").text()');
|
67
|
+
});
|
68
|
+
});
|
69
|
+
|
70
|
+
spec.run_all();
|
75
71
|
}());
|
@@ -1,12 +1,12 @@
|
|
1
|
-
Array.
|
1
|
+
Array.prototype.is_empty = function() {
|
2
2
|
return is_empty(this);
|
3
|
-
}
|
3
|
+
};
|
4
4
|
|
5
|
-
Array.
|
5
|
+
Array.prototype.not_empty = function() {
|
6
6
|
return is_not_empty(this);
|
7
|
-
}
|
7
|
+
};
|
8
8
|
|
9
|
-
Array.
|
9
|
+
Array.prototype.each = function(callback) {
|
10
10
|
if(is_undefined(callback)) {
|
11
11
|
throw new SyntaxError("Array.each(callback): callback is undefined");
|
12
12
|
}
|
@@ -15,9 +15,9 @@ Array.method('each', function(callback) {
|
|
15
15
|
var args = [this[i], i];
|
16
16
|
callback.apply(this, args);
|
17
17
|
}
|
18
|
-
}
|
18
|
+
};
|
19
19
|
|
20
|
-
Array.
|
20
|
+
Array.prototype.contains = function(suspect) {
|
21
21
|
var matches = [];
|
22
22
|
this.each(function(value, index) {
|
23
23
|
if(value === suspect) {
|
@@ -26,4 +26,4 @@ Array.method('contains', function(suspect) {
|
|
26
26
|
});
|
27
27
|
|
28
28
|
return matches.not_empty() ? matches : false;
|
29
|
-
}
|
29
|
+
};
|
@@ -0,0 +1,59 @@
|
|
1
|
+
var Cookie = function(name, data, exp) {
|
2
|
+
if (is_undefined(name)) {
|
3
|
+
throw new SyntaxError('new Cookie(name, data[, exp]): name is undefined');
|
4
|
+
}
|
5
|
+
|
6
|
+
function set_exp(days) {
|
7
|
+
var date = new Date();
|
8
|
+
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
9
|
+
var expires = "; expires=" + date.toGMTString();
|
10
|
+
}
|
11
|
+
|
12
|
+
this.name = name;
|
13
|
+
|
14
|
+
unless(this.read(), function() {
|
15
|
+
if (is_undefined(data)) {
|
16
|
+
this.data = '';
|
17
|
+
}
|
18
|
+
else {
|
19
|
+
this.data = data;
|
20
|
+
}
|
21
|
+
|
22
|
+
if (is_defined(days)) {
|
23
|
+
this.exp = set_exp(days);
|
24
|
+
}
|
25
|
+
else {
|
26
|
+
this.exp = '';
|
27
|
+
}
|
28
|
+
});
|
29
|
+
|
30
|
+
this.save();
|
31
|
+
};
|
32
|
+
|
33
|
+
Cookie.prototype.save = function() {
|
34
|
+
document.cookie = this.name + "=" + this.data + this.exp + "; path=/";
|
35
|
+
};
|
36
|
+
|
37
|
+
Cookie.prototype.read = function() {
|
38
|
+
var nameEQ = this.name + "=";
|
39
|
+
var ca = document.cookie.split(';');
|
40
|
+
var length = ca.length;
|
41
|
+
|
42
|
+
for (var i = 0; i < length; i++) {
|
43
|
+
var c = ca[i];
|
44
|
+
while (c.charAt(0) == ' ') {
|
45
|
+
c = c.substring(1, c.length);
|
46
|
+
}
|
47
|
+
if (c.indexOf(nameEQ) === 0) {
|
48
|
+
return c.substring(nameEQ.length,c.length);
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
return null;
|
53
|
+
};
|
54
|
+
|
55
|
+
Cookie.prototype.remove = function() {
|
56
|
+
this.data = '';
|
57
|
+
this.exp = -1;
|
58
|
+
this.save();
|
59
|
+
};
|
@@ -10,7 +10,7 @@ CSS.rgb2hex = function(r,g,b) {
|
|
10
10
|
else {
|
11
11
|
rgb = false;
|
12
12
|
}
|
13
|
-
|
13
|
+
|
14
14
|
if (rgb) {
|
15
15
|
r = parseInt(rgb[0], 10);
|
16
16
|
g = parseInt(rgb[1], 10);
|
@@ -26,26 +26,26 @@ CSS.rgb2hex = function(r,g,b) {
|
|
26
26
|
|
27
27
|
CSS.hex2rgb = function(hex) {
|
28
28
|
hex = hex.replace('#', '');
|
29
|
-
|
29
|
+
|
30
30
|
var rgb = [];
|
31
|
-
|
31
|
+
|
32
32
|
rgb[0] = parseInt(hex.substring(0,2), 16);
|
33
33
|
rgb[1] = parseInt(hex.substring(2,4), 16);
|
34
34
|
rgb[2] = parseInt(hex.substring(4,6), 16);
|
35
|
-
|
35
|
+
|
36
36
|
rgb.red = rgb[0];
|
37
37
|
rgb.green = rgb[1];
|
38
38
|
rgb.blue = rgb[2];
|
39
|
-
|
39
|
+
|
40
40
|
rgb.to_s = function() {
|
41
41
|
return 'rgb(' + rgb.red +', ' + rgb.green + ', ' + rgb.blue + ')';
|
42
42
|
};
|
43
|
-
|
43
|
+
|
44
44
|
rgb.each = function(callback) {
|
45
45
|
for (var i = 0; i < 3; i++) {
|
46
46
|
callback.call(this, rgb[i]);
|
47
47
|
}
|
48
48
|
};
|
49
|
-
|
49
|
+
|
50
50
|
return rgb;
|
51
51
|
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Number.
|
1
|
+
Number.prototype.to_hex = function() {
|
2
2
|
if (this === 0) {
|
3
3
|
return "00";
|
4
4
|
}
|
@@ -8,4 +8,4 @@ Number.method('to_hex', function() {
|
|
8
8
|
n = Math.min(n, 255);
|
9
9
|
n = Math.round(n);
|
10
10
|
return chars.charAt((n - n % 16)/16) + chars.charAt(n % 16);
|
11
|
-
}
|
11
|
+
};
|
@@ -1,29 +1,29 @@
|
|
1
|
-
String.
|
1
|
+
String.prototype.is_empty = function() {
|
2
2
|
return (this.length < 1) ? true : false;
|
3
|
-
}
|
3
|
+
};
|
4
4
|
|
5
|
-
String.
|
5
|
+
String.prototype.not_empty = function() {
|
6
6
|
return (this.length < 1) ? false : true;
|
7
|
-
}
|
7
|
+
};
|
8
8
|
|
9
|
-
String.
|
9
|
+
String.prototype.is_numeric = function() {
|
10
10
|
var pattern = /^(\.|-)?\d+(?:\.\d*)?(?:e[+\-]?\d+)?$/i;
|
11
11
|
return pattern.test(this);
|
12
|
-
}
|
12
|
+
};
|
13
13
|
|
14
|
-
String.
|
14
|
+
String.prototype.trim = function() {
|
15
15
|
return this.replace(/^\s+|\s+$/g, "");
|
16
|
-
}
|
16
|
+
};
|
17
17
|
|
18
|
-
String.
|
18
|
+
String.prototype.ltrim = function() {
|
19
19
|
return this.replace(/^\s+/,"");
|
20
|
-
}
|
20
|
+
};
|
21
21
|
|
22
|
-
String.
|
22
|
+
String.prototype.rtrim = function() {
|
23
23
|
return this.replace(/\s+$/,"");
|
24
|
-
}
|
24
|
+
};
|
25
25
|
|
26
|
-
String.
|
26
|
+
String.prototype.each = function(callback) {
|
27
27
|
if(is_undefined(callback)) {
|
28
28
|
throw new SyntaxError("String.each(callback): callback is undefined");
|
29
29
|
}
|
@@ -32,30 +32,30 @@ String.method('each', function(callback) {
|
|
32
32
|
var args = [this.charAt(i), i];
|
33
33
|
callback.apply(this, args);
|
34
34
|
}
|
35
|
-
}
|
35
|
+
};
|
36
36
|
|
37
|
-
String.
|
37
|
+
String.prototype.capitalize = function() {
|
38
38
|
return this.substr(0, 1).toUpperCase() + this.substr(1);
|
39
|
-
}
|
39
|
+
};
|
40
40
|
|
41
|
-
String.
|
41
|
+
String.prototype.reverse = function() {
|
42
42
|
return this.split('').reverse().join('');
|
43
|
-
}
|
43
|
+
};
|
44
44
|
|
45
|
-
String.
|
45
|
+
String.prototype.to_n = function() {
|
46
46
|
return parseFloat(this);
|
47
|
-
}
|
47
|
+
};
|
48
48
|
|
49
|
-
String.
|
49
|
+
String.prototype.pluck = function(needle) {
|
50
50
|
var pattern = new RegExp(needle, 'g');
|
51
51
|
return this.replace(pattern, '');
|
52
|
-
}
|
52
|
+
};
|
53
53
|
|
54
|
-
String.
|
54
|
+
String.prototype.single_space = function() {
|
55
55
|
var no_hard_spaces = this.replace(/\ \;/g, ' ');
|
56
56
|
return no_hard_spaces.replace(/\s+/g, ' ');
|
57
|
-
}
|
57
|
+
};
|
58
58
|
|
59
|
-
String.
|
59
|
+
String.prototype.compress = function() {
|
60
60
|
return this.replace(/\s+/g, '');
|
61
|
-
}
|
61
|
+
};
|
data/spec/cli_spec.rb
CHANGED
@@ -2,158 +2,160 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe 'CLI' do
|
4
4
|
before :each do
|
5
|
-
@bin = "#{
|
5
|
+
@bin = "#{Ninjs::BASE_DIR}/bin/ninjs"
|
6
6
|
end
|
7
7
|
|
8
8
|
after :each do
|
9
|
-
FileUtils.rm_rf
|
10
|
-
FileUtils.rm_rf
|
11
|
-
FileUtils.rm_rf
|
12
|
-
FileUtils.rm_rf
|
13
|
-
FileUtils.rm_rf
|
14
|
-
FileUtils.rm_rf
|
15
|
-
FileUtils.rm_rf
|
16
|
-
FileUtils.rm_rf
|
17
|
-
FileUtils.rm_rf
|
9
|
+
FileUtils.rm_rf "#{SPEC_DIR}/application"
|
10
|
+
FileUtils.rm_rf "#{SPEC_DIR}/modules"
|
11
|
+
FileUtils.rm_rf "#{SPEC_DIR}/elements"
|
12
|
+
FileUtils.rm_rf "#{SPEC_DIR}/models"
|
13
|
+
FileUtils.rm_rf "#{SPEC_DIR}/lib"
|
14
|
+
FileUtils.rm_rf "#{SPEC_DIR}/plugins"
|
15
|
+
FileUtils.rm_rf "#{SPEC_DIR}/tests"
|
16
|
+
FileUtils.rm_rf "#{SPEC_DIR}/ninjs.conf"
|
17
|
+
FileUtils.rm_rf "#{SPEC_DIR}/js" if File.exists? "#{SPEC_DIR}/js"
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should create a new application' do
|
21
|
-
suppress_output
|
21
|
+
suppress_output do
|
22
|
+
%x(cd #{SPEC_DIR}; #{@bin} create myapp)
|
23
|
+
end
|
22
24
|
|
23
|
-
|
25
|
+
"#{SPEC_DIR}/ninjs.conf".should be_same_file_as "#{SPEC_DIR}/fixtures/ninjs.conf"
|
24
26
|
|
25
|
-
File.directory?("application").should be_true
|
26
|
-
File.directory?("elements").should be_true
|
27
|
-
File.directory?("lib").should be_true
|
28
|
-
File.directory?("models").should be_true
|
29
|
-
File.directory?("modules").should be_true
|
30
|
-
File.directory?("plugins").should be_true
|
31
|
-
File.directory?("tests").should be_true
|
27
|
+
File.directory?("#{SPEC_DIR}/application").should be_true
|
28
|
+
File.directory?("#{SPEC_DIR}/elements").should be_true
|
29
|
+
File.directory?("#{SPEC_DIR}/lib").should be_true
|
30
|
+
File.directory?("#{SPEC_DIR}/models").should be_true
|
31
|
+
File.directory?("#{SPEC_DIR}/modules").should be_true
|
32
|
+
File.directory?("#{SPEC_DIR}/plugins").should be_true
|
33
|
+
File.directory?("#{SPEC_DIR}/tests").should be_true
|
32
34
|
|
33
|
-
File.exists?(
|
34
|
-
File.exists?(
|
35
|
+
File.exists?("#{SPEC_DIR}/lib/nin.js").should be_true
|
36
|
+
File.exists?("#{SPEC_DIR}/lib/utilities.js").should be_true
|
35
37
|
|
36
|
-
File.exists?(
|
37
|
-
application_file_content = File.open("application/myapp.js").readlines
|
38
|
+
File.exists?("#{SPEC_DIR}/application/myapp.js").should be_true
|
39
|
+
application_file_content = File.open("#{SPEC_DIR}/application/myapp.js").readlines
|
38
40
|
application_file_content.shift
|
39
|
-
application_file_content.join('').should == File.open(
|
41
|
+
application_file_content.join('').should == File.open("#{SPEC_DIR}/fixtures/myapp.initial.js").readlines.join('')
|
40
42
|
|
41
|
-
File.exists?(
|
42
|
-
File.exists?(
|
43
|
-
File.exists?(
|
44
|
-
File.exists?(
|
45
|
-
File.exists?(
|
46
|
-
File.exists?(
|
47
|
-
File.exists?(
|
48
|
-
File.exists?(
|
49
|
-
File.exists?(
|
43
|
+
File.exists?("#{SPEC_DIR}/tests").should be_true
|
44
|
+
File.exists?("#{SPEC_DIR}/tests/index.html").should be_true
|
45
|
+
File.exists?("#{SPEC_DIR}/tests/application.test.js").should be_true
|
46
|
+
File.exists?("#{SPEC_DIR}/tests/array.utilities.test.js").should be_true
|
47
|
+
File.exists?("#{SPEC_DIR}/tests/existence.test.js").should be_true
|
48
|
+
File.exists?("#{SPEC_DIR}/tests/extension.test.js").should be_true
|
49
|
+
File.exists?("#{SPEC_DIR}/tests/module.test.js").should be_true
|
50
|
+
File.exists?("#{SPEC_DIR}/tests/qspec.js").should be_true
|
51
|
+
File.exists?("#{SPEC_DIR}/tests/string.utilities.test.js").should be_true
|
50
52
|
end
|
51
53
|
|
52
54
|
it 'should create a new application in a subdirectory' do
|
53
|
-
suppress_output {
|
54
|
-
|
55
|
-
|
55
|
+
suppress_output { %x(cd #{SPEC_DIR} && #{@bin} create myapp js) }
|
56
|
+
|
57
|
+
"#{SPEC_DIR}/js/ninjs.conf".should be_same_file_as "#{SPEC_DIR}/fixtures/ninjs.conf"
|
56
58
|
|
57
|
-
File.directory?("js/application").should be_true
|
58
|
-
File.directory?("js/elements").should be_true
|
59
|
-
File.directory?("js/lib").should be_true
|
60
|
-
File.directory?("js/models").should be_true
|
61
|
-
File.directory?("js/modules").should be_true
|
62
|
-
File.directory?("js/plugins").should be_true
|
63
|
-
File.directory?("js/tests").should be_true
|
59
|
+
File.directory?("#{SPEC_DIR}/js/application").should be_true
|
60
|
+
File.directory?("#{SPEC_DIR}/js/elements").should be_true
|
61
|
+
File.directory?("#{SPEC_DIR}/js/lib").should be_true
|
62
|
+
File.directory?("#{SPEC_DIR}/js/models").should be_true
|
63
|
+
File.directory?("#{SPEC_DIR}/js/modules").should be_true
|
64
|
+
File.directory?("#{SPEC_DIR}/js/plugins").should be_true
|
65
|
+
File.directory?("#{SPEC_DIR}/js/tests").should be_true
|
64
66
|
|
65
|
-
File.exists?(
|
66
|
-
File.exists?(
|
67
|
+
File.exists?("#{SPEC_DIR}/js/lib/nin.js").should be_true
|
68
|
+
File.exists?("#{SPEC_DIR}/js/lib/utilities.js").should be_true
|
67
69
|
|
68
|
-
File.exists?(
|
69
|
-
application_file_content = File.open("js/application/myapp.js").readlines
|
70
|
+
File.exists?("#{SPEC_DIR}/js/application/myapp.js").should be_true
|
71
|
+
application_file_content = File.open("#{SPEC_DIR}/js/application/myapp.js").readlines
|
70
72
|
application_file_content.shift
|
71
|
-
application_file_content.join('').should == File.open(
|
73
|
+
application_file_content.join('').should == File.open("#{SPEC_DIR}/fixtures/myapp.initial.js").readlines.join('')
|
72
74
|
|
73
|
-
File.exists?(
|
74
|
-
File.exists?(
|
75
|
-
File.exists?(
|
76
|
-
File.exists?(
|
77
|
-
File.exists?(
|
78
|
-
File.exists?(
|
79
|
-
File.exists?(
|
80
|
-
File.exists?(
|
81
|
-
File.exists?(
|
75
|
+
File.exists?("#{SPEC_DIR}/js/tests").should be_true
|
76
|
+
File.exists?("#{SPEC_DIR}/js/tests/index.html").should be_true
|
77
|
+
File.exists?("#{SPEC_DIR}/js/tests/application.test.js").should be_true
|
78
|
+
File.exists?("#{SPEC_DIR}/js/tests/array.utilities.test.js").should be_true
|
79
|
+
File.exists?("#{SPEC_DIR}/js/tests/existence.test.js").should be_true
|
80
|
+
File.exists?("#{SPEC_DIR}/js/tests/extension.test.js").should be_true
|
81
|
+
File.exists?("#{SPEC_DIR}/js/tests/module.test.js").should be_true
|
82
|
+
File.exists?("#{SPEC_DIR}/js/tests/qspec.js").should be_true
|
83
|
+
File.exists?("#{SPEC_DIR}/js/tests/string.utilities.test.js").should be_true
|
82
84
|
end
|
83
85
|
|
84
86
|
it 'should compile the application' do
|
85
|
-
suppress_output {
|
87
|
+
suppress_output { %x(cd #{SPEC_DIR} && #{@bin} create myapp) }
|
86
88
|
|
87
|
-
FileUtils.cp
|
88
|
-
FileUtils.cp
|
89
|
-
FileUtils.cp
|
90
|
-
FileUtils.cp
|
91
|
-
FileUtils.cp
|
92
|
-
FileUtils.cp
|
89
|
+
FileUtils.cp "#{SPEC_DIR}/fixtures/hello.module.js", "#{SPEC_DIR}/modules"
|
90
|
+
FileUtils.cp "#{SPEC_DIR}/fixtures/hello.elements.js", "#{SPEC_DIR}/elements"
|
91
|
+
FileUtils.cp "#{SPEC_DIR}/fixtures/hello.model.js", "#{SPEC_DIR}/models"
|
92
|
+
FileUtils.cp "#{SPEC_DIR}/fixtures/foo.module.js", "#{SPEC_DIR}/modules"
|
93
|
+
FileUtils.cp "#{SPEC_DIR}/fixtures/foo.elements.js", "#{SPEC_DIR}/elements"
|
94
|
+
FileUtils.cp "#{SPEC_DIR}/fixtures/foo.model.js", "#{SPEC_DIR}/models"
|
93
95
|
|
94
|
-
suppress_output {
|
96
|
+
suppress_output { %x(cd #{SPEC_DIR} && #{@bin} compile) }
|
95
97
|
|
96
|
-
File.exists?(
|
97
|
-
File.exists?(
|
98
|
+
File.exists?("#{SPEC_DIR}/application/hello.js").should be_true
|
99
|
+
File.exists?("#{SPEC_DIR}/application/foo.js").should be_true
|
98
100
|
end
|
99
101
|
|
100
102
|
it 'should update the application' do
|
101
|
-
suppress_output {
|
103
|
+
suppress_output { %x(cd #{SPEC_DIR} && #{@bin} create myapp) }
|
102
104
|
|
103
|
-
File.open(
|
105
|
+
File.open("#{SPEC_DIR}/lib/nin.js", 'w+') do |file|
|
104
106
|
file << 'changed'
|
105
107
|
end
|
106
108
|
|
107
|
-
suppress_output {
|
109
|
+
suppress_output { %x(cd #{SPEC_DIR} && #{@bin} update) }
|
108
110
|
|
109
|
-
|
111
|
+
"#{SPEC_DIR}/lib/nin.js".should be_same_file_as "#{SPEC_DIR}/fixtures/nin.js"
|
110
112
|
end
|
111
113
|
|
112
114
|
it 'should generate a module file' do
|
113
115
|
suppress_output do
|
114
|
-
|
115
|
-
|
116
|
+
%x(cd #{SPEC_DIR} && #{@bin} create myapp)
|
117
|
+
%x(cd #{SPEC_DIR} && #{@bin} generate module mymodule)
|
116
118
|
end
|
117
119
|
|
118
|
-
|
120
|
+
"#{SPEC_DIR}/modules/mymodule.module.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.module.js"
|
119
121
|
end
|
120
122
|
|
121
123
|
it 'should generate a module file with an alias' do
|
122
124
|
suppress_output do
|
123
|
-
|
124
|
-
|
125
|
+
%x(cd #{SPEC_DIR} && #{@bin} create myapp)
|
126
|
+
%x(cd #{SPEC_DIR} && #{@bin} generate module mymodule -a)
|
125
127
|
end
|
126
128
|
|
127
|
-
|
129
|
+
"#{SPEC_DIR}/modules/mymodule.module.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.alias.module.js"
|
128
130
|
end
|
129
131
|
|
130
132
|
it 'should generate an elements file' do
|
131
133
|
suppress_output do
|
132
|
-
|
133
|
-
|
134
|
+
%x(cd #{SPEC_DIR} && #{@bin} create myapp)
|
135
|
+
%x(cd #{SPEC_DIR} && #{@bin} generate elements mymodule)
|
134
136
|
end
|
135
137
|
|
136
|
-
|
138
|
+
"#{SPEC_DIR}/elements/mymodule.elements.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.elements.js"
|
137
139
|
end
|
138
140
|
|
139
141
|
it 'should generate a model file' do
|
140
142
|
suppress_output do
|
141
|
-
|
142
|
-
|
143
|
+
%x(cd #{SPEC_DIR} && #{@bin} create myapp)
|
144
|
+
%x(cd #{SPEC_DIR} && #{@bin} generate model mymodule)
|
143
145
|
end
|
144
146
|
|
145
|
-
|
147
|
+
"#{SPEC_DIR}/models/mymodule.model.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.model.js"
|
146
148
|
end
|
147
149
|
|
148
150
|
it 'should generate a module file with dependencies' do
|
149
151
|
suppress_output do
|
150
|
-
|
151
|
-
|
152
|
+
%x(cd #{SPEC_DIR} && #{@bin} create myapp)
|
153
|
+
%x(cd #{SPEC_DIR} && #{@bin} generate module mymodule -em)
|
152
154
|
end
|
153
155
|
|
154
|
-
|
155
|
-
|
156
|
-
|
156
|
+
"#{SPEC_DIR}/modules/mymodule.module.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.dependencies.module.js"
|
157
|
+
"#{SPEC_DIR}/elements/mymodule.elements.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.elements.js"
|
158
|
+
"#{SPEC_DIR}/models/mymodule.model.js".should be_same_file_as "#{SPEC_DIR}/fixtures/mymodule.model.js"
|
157
159
|
end
|
158
160
|
|
159
161
|
end
|