judojs 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.markdown +29 -0
- data/bin/jpm +52 -0
- data/bin/judojs +52 -0
- data/lib/judojs/command.rb +136 -0
- data/lib/judojs/configuration.rb +77 -0
- data/lib/judojs/dependencies.rb +14 -0
- data/lib/judojs/helpers.rb +16 -0
- data/lib/judojs/jpm.rb +62 -0
- data/lib/judojs/project.rb +193 -0
- data/lib/judojs.rb +31 -0
- data/repository/jquery/1.1.4.js +2508 -0
- data/repository/jquery/1.2.6.js +32 -0
- data/repository/jquery/1.3.2.js +19 -0
- data/repository/jquery/1.4.2.js +154 -0
- data/repository/jquery/latest.js +1 -0
- data/repository/judojs/core/existence.js +41 -0
- data/repository/judojs/core/extend.js +22 -0
- data/repository/judojs/core/judo.js +26 -0
- data/repository/judojs/tests/index.html +21 -0
- data/repository/judojs/tests/judojs.test.js +109 -0
- data/repository/judojs/tests/judojs.utilities.test.js +149 -0
- data/repository/judojs/utilities/all.js +2 -0
- data/repository/judojs/utilities/array.js +34 -0
- data/repository/judojs/utilities/string.js +66 -0
- data/repository/modernizr/1.5.js +28 -0
- data/repository/modernizr/latest.js +1 -0
- data/repository/selectivizr/1.0.js +5 -0
- data/repository/selectivizr/latest.js +1 -0
- data/tests/fixtures/global.js +6 -0
- data/tests/fixtures/global.module.js +3 -0
- data/tests/fixtures/judojs.conf +5 -0
- data/tests/fixtures/myapplication.js +90 -0
- data/tests/fixtures/test.elements.js +4 -0
- data/tests/fixtures/test.js +2 -0
- data/tests/fixtures/test.model.js +3 -0
- data/tests/fixtures/test.module.js +12 -0
- data/tests/fixtures/update.judojs.conf +4 -0
- data/tests/fixtures/updated.myapplication.js +27 -0
- data/tests/fixtures/utilities.js +100 -0
- data/tests/jpm_test.rb +10 -0
- data/tests/judo_test.rb +12 -0
- data/tests/project_test.rb +91 -0
- data/tests/update_test.rb +70 -0
- metadata +165 -0
@@ -0,0 +1,149 @@
|
|
1
|
+
module("array utility tests");
|
2
|
+
|
3
|
+
test("can test for emptiness", function() {
|
4
|
+
expect(4);
|
5
|
+
|
6
|
+
ok([].is_empty(), "[].is_empty() is true");
|
7
|
+
equals(['one', 'two', 'three'].is_empty(), false, "['one', 'two', 'three'].is_empty()");
|
8
|
+
ok(['one', 'two', 'three'].not_empty(), "['one', 'two', 'three'].not_empty() is false");
|
9
|
+
equals([].not_empty(), false, "[].not_empty() is false");
|
10
|
+
});
|
11
|
+
|
12
|
+
test("can iterate over each element", function() {
|
13
|
+
expect(7);
|
14
|
+
|
15
|
+
var iteration_count = 0;
|
16
|
+
var test_array_values = [];
|
17
|
+
var test_array_indices = [];
|
18
|
+
|
19
|
+
['one', 'two', 'three'].each(function(value, index) {
|
20
|
+
iteration_count++;
|
21
|
+
test_array_values.push(value);
|
22
|
+
test_array_indices.push(index);
|
23
|
+
});
|
24
|
+
|
25
|
+
equals(test_array_values[0], 'one', 'value at index 0 is correct');
|
26
|
+
equals(test_array_values[1], 'two', 'value at index 1 is correct');
|
27
|
+
equals(test_array_values[2], 'three', 'value at index 2 is correct');
|
28
|
+
|
29
|
+
equals(test_array_indices[0], 0, 'first index is correct');
|
30
|
+
equals(test_array_indices[1], 1, 'second index is correct');
|
31
|
+
equals(test_array_indices[2], 2, 'third index is correct');
|
32
|
+
|
33
|
+
equals(iteration_count, 3, 'made only three iterations');
|
34
|
+
});
|
35
|
+
|
36
|
+
test("can test if an array contains an element", function() {
|
37
|
+
var array = ['one', 'two', 'three'];
|
38
|
+
var string = 'hello';
|
39
|
+
var object = {
|
40
|
+
name: 'some object'
|
41
|
+
};
|
42
|
+
var number = 45;
|
43
|
+
var date = new Date();
|
44
|
+
|
45
|
+
var test_array = [array, string, object, number, date];
|
46
|
+
|
47
|
+
ok(test_array.contains(array), 'array.contains(array)');
|
48
|
+
ok(test_array.contains(string), 'array.contains(string)');
|
49
|
+
ok(test_array.contains(object), 'array.contains(object)');
|
50
|
+
ok(test_array.contains(number), 'array.contains(number)');
|
51
|
+
ok(test_array.contains(date), 'array.contains(date)');
|
52
|
+
equals(test_array.contains('not in there'), false, 'non-existent value is false');
|
53
|
+
});
|
54
|
+
|
55
|
+
test("can shuffle an array", function() {
|
56
|
+
var array = [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
57
|
+
ok(array != [1, 2, 3, 4, 5, 6, 7, 8, 9], "array is shuffled");
|
58
|
+
same(array, [1, 2, 3, 4, 5, 6, 7, 8, 9], 'array is not altered');
|
59
|
+
});
|
60
|
+
|
61
|
+
module("string utility tests");
|
62
|
+
|
63
|
+
test("can test for emptiness", function() {
|
64
|
+
ok(''.is_empty(), "''.is_empty() is true");
|
65
|
+
equals('hey there'.is_empty(), false, "'hey there'.is_empty() is false");
|
66
|
+
ok('hey there'.not_empty(), "'hey there'.not_empty() is false");
|
67
|
+
equals(''.not_empty(), false, "''.not_empty() is false");
|
68
|
+
});
|
69
|
+
|
70
|
+
test('can test for number', function() {
|
71
|
+
equals('34'.is_number(), true, "34 is a number");
|
72
|
+
equals('0.5'.is_number(), true, ".5 is a number");
|
73
|
+
equals('-34'.is_number(), true, '-34 is a number');
|
74
|
+
equals('-0.5'.is_number(), true, '-.05 is a number');
|
75
|
+
equals('hello'.is_number(), false, 'hello is not a number');
|
76
|
+
});
|
77
|
+
|
78
|
+
test('can trim a string', function() {
|
79
|
+
equals(' hello '.trim(), 'hello', "' hello '.trim()");
|
80
|
+
equals(' hello '.ltrim(), 'hello ', "' hello '.ltrim()");
|
81
|
+
equals(' hello '.rtrim(), ' hello', "' hello '.rtrim()");
|
82
|
+
});
|
83
|
+
|
84
|
+
test("can iterate over each character", function() {
|
85
|
+
var iteration_count = 0;
|
86
|
+
var test_chars = [];
|
87
|
+
var test_indices = [];
|
88
|
+
'123'.each(function(character, index) {
|
89
|
+
test_chars.push(character);
|
90
|
+
test_indices.push(index);
|
91
|
+
iteration_count++;
|
92
|
+
});
|
93
|
+
|
94
|
+
equals(test_chars[0], '1', 'first character of 123 is 1');
|
95
|
+
equals(test_chars[1], '2', 'second character of 123 is 2');
|
96
|
+
equals(test_chars[2], '3', 'second character of 123 is 3');
|
97
|
+
|
98
|
+
equals(test_indices[0], 0, 'first index is correct');
|
99
|
+
equals(test_indices[1], 1, 'second index is correct');
|
100
|
+
equals(test_indices[2], 2, 'third index is correct');
|
101
|
+
|
102
|
+
equals(iteration_count, 3, 'made only three iterations');
|
103
|
+
});
|
104
|
+
|
105
|
+
test('can capitalize a string', function() {
|
106
|
+
equals('hello world'.capitalize(), 'Hello world', 'capitalized string correctly');
|
107
|
+
});
|
108
|
+
|
109
|
+
test('can reverse a string', function() {
|
110
|
+
equals('hello world'.reverse(), 'dlrow olleh', 'reversed string correctly');
|
111
|
+
equals('satan oscillate my metallic sonatas'.reverse(), 'satanos cillatem ym etallicso natas', 'fucking palindromes, how do they work?');
|
112
|
+
});
|
113
|
+
|
114
|
+
test("can convert to number", function() {
|
115
|
+
var whole_number = '32';
|
116
|
+
var decimal = '0.08';
|
117
|
+
var negative_number = '-32';
|
118
|
+
var negative_float = '-0.08';
|
119
|
+
|
120
|
+
same(whole_number.to_n(), 32, "whole_number.to_n() is 32");
|
121
|
+
same(decimal.to_n(), 0.08, "decimal.to_n() is 0.08");
|
122
|
+
same(negative_number.to_n(), -32, "negative_number.to_n() is -32");
|
123
|
+
same(negative_float.to_n(), -0.08, "negative_float.to_n() -0.08");
|
124
|
+
});
|
125
|
+
|
126
|
+
test("can pluck a string", function() {
|
127
|
+
equals('one, two, three'.pluck(','), 'one two three', "'one, two, three'.pluck(',')");
|
128
|
+
});
|
129
|
+
|
130
|
+
test("can single space a string", function() {
|
131
|
+
var hard_space = 'one two three four five six';
|
132
|
+
var soft_space = 'one two three four five six';
|
133
|
+
var mixed_space = 'one two three four five six';
|
134
|
+
|
135
|
+
equals(hard_space.single_space(), 'one two three four five six', 'correctly spaced ');
|
136
|
+
equals(soft_space.single_space(), 'one two three four five six', "correctly spaced soft spaces");
|
137
|
+
equals(mixed_space.single_space(), 'one two three four five six', "correctly spaced mixed spaces");
|
138
|
+
});
|
139
|
+
|
140
|
+
test("can compress a string", function() {
|
141
|
+
var string = "satan\n\t oscillate\n\t my\n\t metallic\n sonatas";
|
142
|
+
same(string.compress(), 'satanoscillatemymetallicsonatas', "string is compressed correctly");
|
143
|
+
});
|
144
|
+
|
145
|
+
test("can shuffle a string", function() {
|
146
|
+
var string = 'Hello World';
|
147
|
+
ok('Hello World' != string.shuffle(), "string is shuffled");
|
148
|
+
same(string, 'Hello World', 'array is not altered');
|
149
|
+
});
|
@@ -0,0 +1,34 @@
|
|
1
|
+
Array.method('is_empty', function() {
|
2
|
+
return (this.length < 1) ? true : false;
|
3
|
+
});
|
4
|
+
|
5
|
+
Array.method('not_empty', function() {
|
6
|
+
return (this.length > 0) ? true : false;
|
7
|
+
});
|
8
|
+
|
9
|
+
Array.method('each', function(callback) {
|
10
|
+
try {
|
11
|
+
if(doesNotExist(callback)) {
|
12
|
+
throw new SyntaxError("Array.each(callback): callback is undefined");
|
13
|
+
}
|
14
|
+
|
15
|
+
for (var i = 0; i < this.length; i++) {
|
16
|
+
var args = [this[i], i];
|
17
|
+
callback.apply(this, args);
|
18
|
+
}
|
19
|
+
}
|
20
|
+
catch(error) {
|
21
|
+
alert(error.message);
|
22
|
+
}
|
23
|
+
});
|
24
|
+
|
25
|
+
Array.method('contains', function(suspect) {
|
26
|
+
var matches = [];
|
27
|
+
this.each(function(value, index) {
|
28
|
+
if(value === suspect) {
|
29
|
+
matches.push(index);
|
30
|
+
}
|
31
|
+
});
|
32
|
+
|
33
|
+
return matches.not_empty() ? matches : false;
|
34
|
+
});
|
@@ -0,0 +1,66 @@
|
|
1
|
+
String.method('is_empty', function() {
|
2
|
+
return (this == '') ? true : false;
|
3
|
+
});
|
4
|
+
|
5
|
+
String.method('not_empty', function() {
|
6
|
+
return (this == '') ? false : true;
|
7
|
+
});
|
8
|
+
|
9
|
+
String.method('is_number', function() {
|
10
|
+
var pattern = /^(\.|-)?\d+(?:\.\d*)?(?:e[+\-]?\d+)?$/i;
|
11
|
+
return pattern.test(this);
|
12
|
+
});
|
13
|
+
|
14
|
+
String.method('trim', function() {
|
15
|
+
return this.replace(/^\s+|\s+$/g, "");
|
16
|
+
});
|
17
|
+
|
18
|
+
String.method('ltrim', function() {
|
19
|
+
return this.replace(/^\s+/,"");
|
20
|
+
});
|
21
|
+
|
22
|
+
String.method('rtrim', function() {
|
23
|
+
return this.replace(/\s+$/,"");
|
24
|
+
});
|
25
|
+
|
26
|
+
String.method('each', function(callback) {
|
27
|
+
try {
|
28
|
+
if(doesNotExist(callback)) {
|
29
|
+
throw new SyntaxError("String.each(callback): callback is undefined");
|
30
|
+
}
|
31
|
+
|
32
|
+
for (var i = 0; i < this.length; i++) {
|
33
|
+
var args = [this.charAt(i), i];
|
34
|
+
callback.apply(this, args);
|
35
|
+
}
|
36
|
+
}
|
37
|
+
catch(error) {
|
38
|
+
alert(error.message);
|
39
|
+
}
|
40
|
+
});
|
41
|
+
|
42
|
+
String.method('capitalize', function() {
|
43
|
+
return this.substr(0, 1).toUpperCase() + this.substr(1);
|
44
|
+
});
|
45
|
+
|
46
|
+
String.method('reverse', function() {
|
47
|
+
return this.split('').reverse().join('');
|
48
|
+
});
|
49
|
+
|
50
|
+
String.method('to_n', function() {
|
51
|
+
return parseFloat(this);
|
52
|
+
});
|
53
|
+
|
54
|
+
String.method('pluck', function(needle) {
|
55
|
+
var pattern = new RegExp(needle, 'g');
|
56
|
+
return this.replace(pattern, '');
|
57
|
+
});
|
58
|
+
|
59
|
+
String.method('single_space', function() {
|
60
|
+
var no_hard_spaces = this.replace(/\ \;/g, ' ');
|
61
|
+
return no_hard_spaces.replace(/\s+/g, ' ');
|
62
|
+
});
|
63
|
+
|
64
|
+
String.method('compress', function() {
|
65
|
+
return this.replace(/\s+/g, '');
|
66
|
+
});
|
@@ -0,0 +1,28 @@
|
|
1
|
+
/*!
|
2
|
+
* Modernizr JavaScript library 1.5
|
3
|
+
* http://www.modernizr.com/
|
4
|
+
*
|
5
|
+
* Copyright (c) 2009-2010 Faruk Ates - http://farukat.es/
|
6
|
+
* Dual-licensed under the BSD and MIT licenses.
|
7
|
+
* http://www.modernizr.com/license/
|
8
|
+
*
|
9
|
+
* Featuring major contributions by
|
10
|
+
* Paul Irish - http://paulirish.com
|
11
|
+
*/
|
12
|
+
window.Modernizr=function(i,e,I){function C(a,b){for(var c in a)if(m[a[c]]!==I&&(!b||b(a[c],D)))return true}function r(a,b){var c=a.charAt(0).toUpperCase()+a.substr(1);return!!C([a,"Webkit"+c,"Moz"+c,"O"+c,"ms"+c,"Khtml"+c],b)}function P(){j[E]=function(a){for(var b=0,c=a.length;b<c;b++)J[a[b]]=!!(a[b]in n);return J}("autocomplete autofocus list placeholder max min multiple pattern required step".split(" "));j[Q]=function(a){for(var b=0,c,h=a.length;b<h;b++){n.setAttribute("type",a[b]);if(c=n.type!==
|
13
|
+
"text"){n.value=K;/tel|search/.test(n.type)||(c=/url|email/.test(n.type)?n.checkValidity&&n.checkValidity()===false:n.value!=K)}L[a[b]]=!!c}return L}("search tel url email datetime date month week time datetime-local number range color".split(" "))}var j={},s=e.documentElement,D=e.createElement("modernizr"),m=D.style,n=e.createElement("input"),E="input",Q=E+"types",K=":)",M=Object.prototype.toString,y=" -o- -moz- -ms- -webkit- -khtml- ".split(" "),d={},L={},J={},N=[],u=function(){var a={select:"input",
|
14
|
+
change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"},b={};return function(c,h){var t=arguments.length==1;if(t&&b[c])return b[c];h=h||document.createElement(a[c]||"div");c="on"+c;var g=c in h;if(!g&&h.setAttribute){h.setAttribute(c,"return;");g=typeof h[c]=="function"}h=null;return t?(b[c]=g):g}}(),F={}.hasOwnProperty,O;O=typeof F!=="undefined"&&typeof F.call!=="undefined"?function(a,b){return F.call(a,b)}:function(a,b){return b in a&&typeof a.constructor.prototype[b]==="undefined"};
|
15
|
+
d.canvas=function(){return!!e.createElement("canvas").getContext};d.canvastext=function(){return!!(d.canvas()&&typeof e.createElement("canvas").getContext("2d").fillText=="function")};d.geolocation=function(){return!!navigator.geolocation};d.crosswindowmessaging=function(){return!!i.postMessage};d.websqldatabase=function(){var a=!!i.openDatabase;if(a)try{a=!!openDatabase("testdb","1.0","html5 test db",2E5)}catch(b){a=false}return a};d.indexedDB=function(){return!!i.indexedDB};d.hashchange=function(){return u("hashchange",
|
16
|
+
i)&&(document.documentMode===I||document.documentMode>7)};d.historymanagement=function(){return!!(i.history&&history.pushState)};d.draganddrop=function(){return u("drag")&&u("dragstart")&&u("dragenter")&&u("dragover")&&u("dragleave")&&u("dragend")&&u("drop")};d.websockets=function(){return"WebSocket"in i};d.rgba=function(){m.cssText="background-color:rgba(150,255,150,.5)";return(""+m.backgroundColor).indexOf("rgba")!==-1};d.hsla=function(){m.cssText="background-color:hsla(120,40%,100%,.5)";return(""+
|
17
|
+
m.backgroundColor).indexOf("rgba")!==-1};d.multiplebgs=function(){m.cssText="background:url(//:),url(//:),red url(//:)";return/(url\s*\(.*?){3}/.test(m.background)};d.backgroundsize=function(){return r("backgroundSize")};d.borderimage=function(){return r("borderImage")};d.borderradius=function(){return r("borderRadius","",function(a){return(""+a).indexOf("orderRadius")!==-1})};d.boxshadow=function(){return r("boxShadow")};d.opacity=function(){var a=y.join("opacity:.5;")+"";m.cssText=a;return(""+m.opacity).indexOf("0.5")!==
|
18
|
+
-1};d.cssanimations=function(){return r("animationName")};d.csscolumns=function(){return r("columnCount")};d.cssgradients=function(){var a=("background-image:"+y.join("gradient(linear,left top,right bottom,from(#9f9),to(white));background-image:")+y.join("linear-gradient(left top,#9f9, white);background-image:")).slice(0,-17);m.cssText=a;return(""+m.backgroundImage).indexOf("gradient")!==-1};d.cssreflections=function(){return r("boxReflect")};d.csstransforms=function(){return!!C(["transformProperty",
|
19
|
+
"WebkitTransform","MozTransform","OTransform","msTransform"])};d.csstransforms3d=function(){var a=!!C(["perspectiveProperty","WebkitPerspective","MozPerspective","OPerspective","msPerspective"]);if(a){var b=document.createElement("style"),c=e.createElement("div");b.textContent="@media ("+y.join("transform-3d),(")+"modernizr){#modernizr{height:3px}}";e.getElementsByTagName("head")[0].appendChild(b);c.id="modernizr";s.appendChild(c);a=c.offsetHeight===3;b.parentNode.removeChild(b);c.parentNode.removeChild(c)}return a};
|
20
|
+
d.csstransitions=function(){return r("transitionProperty")};d.fontface=function(){var a;if(/*@cc_on@if(@_jscript_version>=5)!@end@*/0)a=true;else{var b=e.createElement("style"),c=e.createElement("span"),h,t=false,g=e.body,o,w;b.textContent="@font-face{font-family:testfont;src:url('data:font/ttf;base64,AAEAAAAMAIAAAwBAT1MvMliohmwAAADMAAAAVmNtYXCp5qrBAAABJAAAANhjdnQgACICiAAAAfwAAAAEZ2FzcP//AAMAAAIAAAAACGdseWYv5OZoAAACCAAAANxoZWFk69bnvwAAAuQAAAA2aGhlYQUJAt8AAAMcAAAAJGhtdHgGDgC4AAADQAAAABRsb2NhAIQAwgAAA1QAAAAMbWF4cABVANgAAANgAAAAIG5hbWUgXduAAAADgAAABPVwb3N03NkzmgAACHgAAAA4AAECBAEsAAUAAAKZAswAAACPApkCzAAAAesAMwEJAAACAAMDAAAAAAAAgAACbwAAAAoAAAAAAAAAAFBmRWQAAAAgqS8DM/8zAFwDMwDNAAAABQAAAAAAAAAAAAMAAAADAAAAHAABAAAAAABGAAMAAQAAAK4ABAAqAAAABgAEAAEAAgAuqQD//wAAAC6pAP///9ZXAwAAAAAAAAACAAAABgBoAAAAAAAvAAEAAAAAAAAAAAAAAAAAAAABAAIAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEACoAAAAGAAQAAQACAC6pAP//AAAALqkA////1lcDAAAAAAAAAAIAAAAiAogAAAAB//8AAgACACIAAAEyAqoAAwAHAC6xAQAvPLIHBADtMrEGBdw8sgMCAO0yALEDAC88sgUEAO0ysgcGAfw8sgECAO0yMxEhESczESMiARDuzMwCqv1WIgJmAAACAFUAAAIRAc0ADwAfAAATFRQWOwEyNj0BNCYrASIGARQGKwEiJj0BNDY7ATIWFX8aIvAiGhoi8CIaAZIoN/43KCg3/jcoAWD0JB4eJPQkHh7++EY2NkbVRjY2RgAAAAABAEH/+QCdAEEACQAANjQ2MzIWFAYjIkEeEA8fHw8QDxwWFhwWAAAAAQAAAAIAAIuYbWpfDzz1AAsEAAAAAADFn9IuAAAAAMWf0i797/8zA4gDMwAAAAgAAgAAAAAAAAABAAADM/8zAFwDx/3v/98DiAABAAAAAAAAAAAAAAAAAAAABQF2ACIAAAAAAVUAAAJmAFUA3QBBAAAAKgAqACoAWgBuAAEAAAAFAFAABwBUAAQAAgAAAAEAAQAAAEAALgADAAMAAAAQAMYAAQAAAAAAAACLAAAAAQAAAAAAAQAhAIsAAQAAAAAAAgAFAKwAAQAAAAAAAwBDALEAAQAAAAAABAAnAPQAAQAAAAAABQAKARsAAQAAAAAABgAmASUAAQAAAAAADgAaAUsAAwABBAkAAAEWAWUAAwABBAkAAQBCAnsAAwABBAkAAgAKAr0AAwABBAkAAwCGAscAAwABBAkABABOA00AAwABBAkABQAUA5sAAwABBAkABgBMA68AAwABBAkADgA0A/tDb3B5cmlnaHQgMjAwOSBieSBEYW5pZWwgSm9obnNvbi4gIFJlbGVhc2VkIHVuZGVyIHRoZSB0ZXJtcyBvZiB0aGUgT3BlbiBGb250IExpY2Vuc2UuIEtheWFoIExpIGdseXBocyBhcmUgcmVsZWFzZWQgdW5kZXIgdGhlIEdQTCB2ZXJzaW9uIDMuYmFlYzJhOTJiZmZlNTAzMiAtIHN1YnNldCBvZiBKdXJhTGlnaHRiYWVjMmE5MmJmZmU1MDMyIC0gc3Vic2V0IG9mIEZvbnRGb3JnZSAyLjAgOiBKdXJhIExpZ2h0IDogMjMtMS0yMDA5YmFlYzJhOTJiZmZlNTAzMiAtIHN1YnNldCBvZiBKdXJhIExpZ2h0VmVyc2lvbiAyIGJhZWMyYTkyYmZmZTUwMzIgLSBzdWJzZXQgb2YgSnVyYUxpZ2h0aHR0cDovL3NjcmlwdHMuc2lsLm9yZy9PRkwAQwBvAHAAeQByAGkAZwBoAHQAIAAyADAAMAA5ACAAYgB5ACAARABhAG4AaQBlAGwAIABKAG8AaABuAHMAbwBuAC4AIAAgAFIAZQBsAGUAYQBzAGUAZAAgAHUAbgBkAGUAcgAgAHQAaABlACAAdABlAHIAbQBzACAAbwBmACAAdABoAGUAIABPAHAAZQBuACAARgBvAG4AdAAgAEwAaQBjAGUAbgBzAGUALgAgAEsAYQB5AGEAaAAgAEwAaQAgAGcAbAB5AHAAaABzACAAYQByAGUAIAByAGUAbABlAGEAcwBlAGQAIAB1AG4AZABlAHIAIAB0AGgAZQAgAEcAUABMACAAdgBlAHIAcwBpAG8AbgAgADMALgBiAGEAZQBjADIAYQA5ADIAYgBmAGYAZQA1ADAAMwAyACAALQAgAHMAdQBiAHMAZQB0ACAAbwBmACAASgB1AHIAYQBMAGkAZwBoAHQAYgBhAGUAYwAyAGEAOQAyAGIAZgBmAGUANQAwADMAMgAgAC0AIABzAHUAYgBzAGUAdAAgAG8AZgAgAEYAbwBuAHQARgBvAHIAZwBlACAAMgAuADAAIAA6ACAASgB1AHIAYQAgAEwAaQBnAGgAdAAgADoAIAAyADMALQAxAC0AMgAwADAAOQBiAGEAZQBjADIAYQA5ADIAYgBmAGYAZQA1ADAAMwAyACAALQAgAHMAdQBiAHMAZQB0ACAAbwBmACAASgB1AHIAYQAgAEwAaQBnAGgAdABWAGUAcgBzAGkAbwBuACAAMgAgAGIAYQBlAGMAMgBhADkAMgBiAGYAZgBlADUAMAAzADIAIAAtACAAcwB1AGIAcwBlAHQAIABvAGYAIABKAHUAcgBhAEwAaQBnAGgAdABoAHQAdABwADoALwAvAHMAYwByAGkAcAB0AHMALgBzAGkAbAAuAG8AcgBnAC8ATwBGAEwAAAAAAgAAAAAAAP+BADMAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAQACAQIAEQt6ZXJva2F5YWhsaQ==')}";
|
21
|
+
e.getElementsByTagName("head")[0].appendChild(b);c.setAttribute("style","font:99px _,arial,helvetica;position:absolute;visibility:hidden");if(!g){g=s.appendChild(e.createElement("fontface"));t=true}c.innerHTML="........";c.id="fonttest";g.appendChild(c);h=c.offsetWidth*c.offsetHeight;c.style.font="99px testfont,_,arial,helvetica";a=h!==c.offsetWidth*c.offsetHeight;var v=function(){if(g.parentNode){a=j.fontface=h!==c.offsetWidth*c.offsetHeight;s.className=s.className.replace(/(no-)?fontface\b/,"")+
|
22
|
+
(a?" ":" no-")+"fontface"}};setTimeout(v,75);setTimeout(v,150);addEventListener("load",function(){v();(w=true)&&o&&o(a);setTimeout(function(){t||(g=c);g.parentNode.removeChild(g);b.parentNode.removeChild(b)},50)},false)}j._fontfaceready=function(p){w||a?p(a):(o=p)};return a||h!==c.offsetWidth};d.video=function(){var a=e.createElement("video"),b=!!a.canPlayType;if(b){b=new Boolean(b);b.ogg=a.canPlayType('video/ogg; codecs="theora"');b.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"');b.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"')}return b};
|
23
|
+
d.audio=function(){var a=e.createElement("audio"),b=!!a.canPlayType;if(b){b=new Boolean(b);b.ogg=a.canPlayType('audio/ogg; codecs="vorbis"');b.mp3=a.canPlayType("audio/mpeg;");b.wav=a.canPlayType('audio/wav; codecs="1"');b.m4a=a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")}return b};d.localStorage=function(){return"localStorage"in i&&i.localStorage!==null};d.sessionStorage=function(){try{return"sessionStorage"in i&&i.sessionStorage!==null}catch(a){return false}};d.webworkers=function(){return!!i.Worker};
|
24
|
+
d.applicationCache=function(){var a=i.applicationCache;return!!(a&&typeof a.status!="undefined"&&typeof a.update=="function"&&typeof a.swapCache=="function")};d.svg=function(){return!!e.createElementNS&&!!e.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect};d.smil=function(){return!!e.createElementNS&&/SVG/.test(M.call(e.createElementNS("http://www.w3.org/2000/svg","animate")))};d.svgclippaths=function(){return!!e.createElementNS&&/SVG/.test(M.call(e.createElementNS("http://www.w3.org/2000/svg",
|
25
|
+
"clipPath")))};for(var z in d)if(O(d,z))N.push(((j[z.toLowerCase()]=d[z]())?"":"no-")+z.toLowerCase());j[E]||P();j.addTest=function(a,b){a=a.toLowerCase();if(!j[a]){b=!!b();s.className+=" "+(b?"":"no-")+a;j[a]=b;return j}};m.cssText="";D=n=null;(function(){var a=e.createElement("div");a.innerHTML="<elem></elem>";return a.childNodes.length!==1})()&&function(a,b){function c(f,k){if(o[f])o[f].styleSheet.cssText+=k;else{var l=t[G],q=b[A]("style");q.media=f;l.insertBefore(q,l[G]);o[f]=q;c(f,k)}}function h(f,
|
26
|
+
k){for(var l=new RegExp("\\b("+w+")\\b(?!.*[;}])","gi"),q=function(B){return".iepp_"+B},x=-1;++x<f.length;){k=f[x].media||k;h(f[x].imports,k);c(k,f[x].cssText.replace(l,q))}}for(var t=b.documentElement,g=b.createDocumentFragment(),o={},w="abbr|article|aside|audio|canvas|command|datalist|details|figure|figcaption|footer|header|hgroup|keygen|mark|meter|nav|output|progress|section|source|summary|time|video",v=w.split("|"),p=[],H=-1,G="firstChild",A="createElement";++H<v.length;){b[A](v[H]);g[A](v[H])}g=
|
27
|
+
g.appendChild(b[A]("div"));a.attachEvent("onbeforeprint",function(){for(var f,k=b.getElementsByTagName("*"),l,q,x=new RegExp("^"+w+"$","i"),B=-1;++B<k.length;)if((f=k[B])&&(q=f.nodeName.match(x))){l=new RegExp("^\\s*<"+q+"(.*)\\/"+q+">\\s*$","i");g.innerHTML=f.outerHTML.replace(/\r|\n/g," ").replace(l,f.currentStyle.display=="block"?"<div$1/div>":"<span$1/span>");l=g.childNodes[0];l.className+=" iepp_"+q;l=p[p.length]=[f,l];f.parentNode.replaceChild(l[1],l[0])}h(b.styleSheets,"all")});a.attachEvent("onafterprint",
|
28
|
+
function(){for(var f=-1,k;++f<p.length;)p[f][1].parentNode.replaceChild(p[f][0],p[f][1]);for(k in o)t[G].removeChild(o[k]);o={};p=[]})}(this,e);j._enableHTML5=true;j._version="1.5";s.className=s.className.replace(/\bno-js\b/,"")+" js";s.className+=" "+N.join(" ");return j}(this,this.document);
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require "1.5"
|
@@ -0,0 +1,5 @@
|
|
1
|
+
/*
|
2
|
+
selectivizr v1.0.0 - (c) Keith Clark, freely distributable under the terms of the MIT license.
|
3
|
+
selectivizr.com
|
4
|
+
*/
|
5
|
+
(function(x){function K(a){return a.replace(L,o).replace(M,function(b,e,c){b=c.split(",");c=0;for(var g=b.length;c<g;c++){var j=N(b[c].replace(O,o).replace(P,o))+t,f=[];b[c]=j.replace(Q,function(d,k,l,i,h){if(k){if(f.length>0){d=f;var u;h=j.substring(0,h).replace(R,n);if(h==n||h.charAt(h.length-1)==t)h+="*";try{u=v(h)}catch(da){}if(u){h=0;for(l=u.length;h<l;h++){i=u[h];for(var y=i.className,z=0,S=d.length;z<S;z++){var q=d[z];if(!RegExp("(^|\\s)"+q.className+"(\\s|$)").test(i.className))if(q.b&&(q.b===true||q.b(i)===true))y=A(y,q.className,true)}i.className=y}}f=[]}return k}else{if(k=l?T(l):!B||B.test(i)?{className:C(i),b:true}:null){f.push(k);return"."+k.className}return d}})}return e+b.join(",")})}function T(a){var b=true,e=C(a.slice(1)),c=a.substring(0,5)==":not(",g,j;if(c)a=a.slice(5,-1);var f=a.indexOf("(");if(f>-1)a=a.substring(0,f);if(a.charAt(0)==":")switch(a.slice(1)){case "root":b=function(d){return c?d!=D:d==D};break;case "target":if(p==8){b=function(d){function k(){var l=location.hash,i=l.slice(1);return c?l==""||d.id!=i:l!=""&&d.id==i}x.attachEvent("onhashchange",function(){r(d,e,k())});return k()};break}return false;case "checked":b=function(d){U.test(d.type)&&d.attachEvent("onpropertychange",function(){event.propertyName=="checked"&&r(d,e,d.checked!==c)});return d.checked!==c};break;case "disabled":c=!c;case "enabled":b=function(d){if(V.test(d.tagName)){d.attachEvent("onpropertychange",function(){event.propertyName=="$disabled"&&r(d,e,d.a===c)});w.push(d);d.a=d.disabled;return d.disabled===c}return a==":enabled"?c:!c};break;case "focus":g="focus";j="blur";case "hover":if(!g){g="mouseenter";j="mouseleave"}b=function(d){d.attachEvent("on"+(c?j:g),function(){r(d,e,true)});d.attachEvent("on"+(c?g:j),function(){r(d,e,false)});return c};break;default:if(!W.test(a))return false;break}return{className:e,b:b}}function C(a){return E+"-"+(p==6&&X?Y++:a.replace(Z,function(b){return b.charCodeAt(0)}))}function N(a){return a.replace(F,o).replace($,t)}function r(a,b,e){var c=a.className;b=A(c,b,e);if(b!=c){a.className=b;a.parentNode.className+=n}}function A(a,b,e){var c=RegExp("(^|\\s)"+b+"(\\s|$)"),g=c.test(a);return e?g?a:a+t+b:g?a.replace(c,o).replace(F,o):a}function G(a,b){if(/^https?:\/\//i.test(a))return b.substring(0,b.indexOf("/",8))==a.substring(0,a.indexOf("/",8))?a:null;if(a.charAt(0)=="/")return b.substring(0,b.indexOf("/",8))+a;var e=b.split("?")[0];if(a.charAt(0)!="?"&&e.charAt(e.length-1)!="/")e=e.substring(0,e.lastIndexOf("/")+1);return e+a}function H(a){if(a){s.open("GET",a,false);s.send();return(s.status==200?s.responseText:n).replace(aa,n).replace(ba,function(b,e,c){return H(G(c,a))})}return n}function ca(){var a,b;a=m.getElementsByTagName("BASE");for(var e=a.length>0?a[0].href:m.location.href,c=0;c<m.styleSheets.length;c++){b=m.styleSheets[c];if(b.href!=n)if(a=G(b.href,e))b.cssText=K(H(a))}w.length>0&&setInterval(function(){for(var g=0,j=w.length;g<j;g++){var f=w[g];if(f.disabled!==f.a)if(f.disabled){f.disabled=false;f.a=true;f.disabled=true}else f.a=f.disabled}},250)}if(!/*@cc_on!@*/true){var m=document,D=m.documentElement,s=function(){if(x.XMLHttpRequest)return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(a){return null}}(),p=/MSIE ([\d])/.exec(navigator.userAgent)[1];if(!(m.compatMode!="CSS1Compat"||p<6||p>8||!s)){var I={NW:"*.Dom.select",DOMAssistant:"*.$",Prototype:"$$",YAHOO:"*.util.Selector.query",MooTools:"$$",Sizzle:"*",jQuery:"*",dojo:"*.query"},v,w=[],Y=0,X=true,E="slvzr",J=E+"DOMReady",aa=/(\/\*[^*]*\*+([^\/][^*]*\*+)*\/)\s*/g,ba=/@import\s*url\(\s*(["'])?(.*?)\1\s*\)[\w\W]*?;/g,W=/^:(empty|(first|last|only|nth(-last)?)-(child|of-type))$/,L=/:(:first-(?:line|letter))/g,M=/(^|})\s*([^\{]*?[\[:][^{]+)/g,Q=/([ +~>])|(:[a-z-]+(?:\(.*?\)+)?)|(\[.*?\])/g,R=/(:not\()?:(hover|enabled|disabled|focus|checked|target|active|visited|first-line|first-letter)\)?/g,Z=/[^\w-]/g,V=/^(INPUT|SELECT|TEXTAREA|BUTTON)$/,U=/^(checkbox|radio)$/,B=p==8?/[\$\^]=(['"])\1/:p==7?/[\$\^*]=(['"])\1/:null,O=/([(\[+~])\s+/g,P=/\s+([)\]+~])/g,$=/\s+/g,F=/^\s*((?:[\S\s]*\S)?)\s*$/,n="",t=" ",o="$1";m.write("<script id="+J+" defer src='//:'><\/script>");m.getElementById(J).onreadystatechange=function(){if(this.readyState=="complete"){a:{var a;for(var b in I)if(x[b]&&(a=eval(I[b].replace("*",b)))){v=a;break a}v=false}if(v){ca();this.parentNode.removeChild(this)}}}}}})(this);
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require "1.0"
|
@@ -0,0 +1,6 @@
|
|
1
|
+
|
2
|
+
MyApplication.addModule('Global');Array.method('is_empty',function(){return(this.length<1)?true:false;});Array.method('not_empty',function(){return(this.length>0)?true:false;});Array.method('each',function(callback){try{if(doesNotExist(callback)){throw new SyntaxError("Array.each(callback): callback is undefined");}
|
3
|
+
for(var i=0;i<this.length;i++){var args=[this[i],i];callback.apply(this,args);}}
|
4
|
+
catch(error){alert(error.message);}});Array.method('contains',function(suspect){var matches=[];this.each(function(value,index){if(value===suspect){matches.push(index);}});return matches.not_empty()?matches:false;});String.method('is_empty',function(){return(this=='')?true:false;});String.method('not_empty',function(){return(this=='')?false:true;});String.method('is_number',function(){var pattern=/^(\.|-)?\d+(?:\.\d*)?(?:e[+\-]?\d+)?$/i;return pattern.test(this);});String.method('trim',function(){return this.replace(/^\s+|\s+$/g,"");});String.method('ltrim',function(){return this.replace(/^\s+/,"");});String.method('rtrim',function(){return this.replace(/\s+$/,"");});String.method('each',function(callback){try{if(doesNotExist(callback)){throw new SyntaxError("String.each(callback): callback is undefined");}
|
5
|
+
for(var i=0;i<this.length;i++){var args=[this.charAt(i),i];callback.apply(this,args);}}
|
6
|
+
catch(error){alert(error.message);}});String.method('capitalize',function(){return this.substr(0,1).toUpperCase()+this.substr(1);});String.method('reverse',function(){return this.split('').reverse().join('');});String.method('to_n',function(){return parseFloat(this);});String.method('pluck',function(needle){var pattern=new RegExp(needle,'g');return this.replace(pattern,'');});String.method('single_space',function(){var no_hard_spaces=this.replace(/\ \;/g,' ');return no_hard_spaces.replace(/\s+/g,' ');});String.method('compress',function(){return this.replace(/\s+/g,'');});
|
@@ -0,0 +1,90 @@
|
|
1
|
+
//-- Judo Tue Nov 02 20:43:51 -0500 2010 --//
|
2
|
+
if (exists === undefined) {
|
3
|
+
var exists = function(variable) {
|
4
|
+
return (variable === undefined) ? false : true;
|
5
|
+
};
|
6
|
+
}
|
7
|
+
|
8
|
+
if (!exists(doesNotExist)) {
|
9
|
+
var doesNotExist = function(variable) {
|
10
|
+
return (variable === undefined) ? true : false;
|
11
|
+
};
|
12
|
+
}
|
13
|
+
|
14
|
+
if (doesNotExist(isTypeof)) {
|
15
|
+
var isTypeof = function(type, variable) {
|
16
|
+
try {
|
17
|
+
if (doesNotExist(type)) {
|
18
|
+
throw new SyntaxError("isTypeof(Type, variable): type is undefined");
|
19
|
+
}
|
20
|
+
if (doesNotExist(variable)) {
|
21
|
+
throw new SyntaxError("isTypeof(Type, variable): variable is undefined");
|
22
|
+
}
|
23
|
+
|
24
|
+
return (variable.constructor == type) ? true : false;
|
25
|
+
}
|
26
|
+
catch(error) {
|
27
|
+
alert(error.message);
|
28
|
+
}
|
29
|
+
};
|
30
|
+
}
|
31
|
+
|
32
|
+
if (doesNotExist(isNumber)) {
|
33
|
+
var isNumber = function(suspect) {
|
34
|
+
if(isTypeof(Number, suspect)) {
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
else {
|
38
|
+
var pattern = /^-?\d+(?:\.\d*)?(?:e[+\-]?\d+)?$/i;
|
39
|
+
return pattern.test(suspect);
|
40
|
+
}
|
41
|
+
};
|
42
|
+
}
|
43
|
+
|
44
|
+
if (doesNotExist(Function.prototype['method'])) {
|
45
|
+
Function.prototype.method = function(name, func) {
|
46
|
+
try {
|
47
|
+
if (doesNotExist(name)) {
|
48
|
+
throw new SyntaxError("Object.method(name, func): name is undefined");
|
49
|
+
}
|
50
|
+
if (doesNotExist(func)) {
|
51
|
+
throw new SyntaxError("Object.method(name, func): func is undefined");
|
52
|
+
}
|
53
|
+
|
54
|
+
if (doesNotExist(this.prototype[name])) {
|
55
|
+
this.prototype[name] = func;
|
56
|
+
return this;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
catch(error) {
|
60
|
+
alert(error.message);
|
61
|
+
}
|
62
|
+
};
|
63
|
+
}
|
64
|
+
|
65
|
+
var JudoModule = function() {};
|
66
|
+
JudoModule.method('actions', function() {});
|
67
|
+
JudoModule.method('run', function() {
|
68
|
+
this.actions();
|
69
|
+
});
|
70
|
+
|
71
|
+
var JudoApplication = function() {};
|
72
|
+
|
73
|
+
JudoApplication.method('addModule', function(name) {
|
74
|
+
try {
|
75
|
+
if (doesNotExist(name)) {
|
76
|
+
throw new SyntaxError("JudoApplication.addModule(name): name is undefined");
|
77
|
+
}
|
78
|
+
|
79
|
+
if (exists(this[name])) {
|
80
|
+
throw new SyntaxError("JudoApplication.addModule(name): '" + name + "' already declared");
|
81
|
+
}
|
82
|
+
|
83
|
+
this[name] = new JudoModule();
|
84
|
+
}
|
85
|
+
catch(error) {
|
86
|
+
alert(error.message);
|
87
|
+
}
|
88
|
+
});
|
89
|
+
|
90
|
+
var MyApplication = new JudoApplication();
|
@@ -0,0 +1,2 @@
|
|
1
|
+
|
2
|
+
MyApplication.addModule('TestModule');$(document).ready(function(){MyApplication.TestModule.test_id=$('#test-element-with-id');console.log(MyApplication.TestModule.test_id);});MyApplication.test_model={some_data_member:'some data value'};MyApplication.TestModule.actions=function(){console.log(MyApplication.TestModule.test_id.html());};$(document).ready(function(){MyApplication.TestModule.run();});
|
@@ -0,0 +1,12 @@
|
|
1
|
+
MyApplication.addModule('TestModule');
|
2
|
+
|
3
|
+
//= require "../elements/test.elements.js"
|
4
|
+
//= require "../models/test.model.js"
|
5
|
+
|
6
|
+
MyApplication.TestModule.actions = function() {
|
7
|
+
console.log(MyApplication.TestModule.test_id.html());
|
8
|
+
};
|
9
|
+
|
10
|
+
$(document).ready(function(){
|
11
|
+
MyApplication.TestModule.run();
|
12
|
+
});
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
if(exists===undefined){var exists=function(variable){return(variable===undefined)?false:true;};}
|
3
|
+
if(!exists(doesNotExist)){var doesNotExist=function(variable){return(variable===undefined)?true:false;};}
|
4
|
+
if(doesNotExist(isTypeof)){var isTypeof=function(type,variable){try{if(doesNotExist(type)){throw new SyntaxError("isTypeof(Type, variable): type is undefined");}
|
5
|
+
if(doesNotExist(variable)){throw new SyntaxError("isTypeof(Type, variable): variable is undefined");}
|
6
|
+
return(variable.constructor==type)?true:false;}
|
7
|
+
catch(error){document.write(error.message);}};}
|
8
|
+
if(doesNotExist(isNumber)){var isNumber=function(suspect){if(isTypeof(Number,suspect)){return true;}
|
9
|
+
else{var pattern=/^-?\d+(?:\.\d*)?(?:e[+\-]?\d+)?$/i;return pattern.test(suspect);}};}
|
10
|
+
if(doesNotExist(die)){var die=function(last_words){if(doesNotExist(last_words)){lastwords=''}
|
11
|
+
document.write(lastwords)};}
|
12
|
+
if(doesNotExist(Object.prototype['method'])){Object.prototype.method=function(name,func){try{if(doesNotExist(name)){throw new SyntaxError("Object.method(name, func): name is undefined");}
|
13
|
+
if(doesNotExist(func)){throw new SyntaxError("Object.method(name, func): func is undefined");}
|
14
|
+
if(doesNotExist(this.prototype[name])){this.prototype[name]=func;return this;}}
|
15
|
+
catch(error){document.write(error.message);}};}
|
16
|
+
if(doesNotExist(Object.prototype['clone'])){Object.method('clone',function(){if(typeof this!=='object'||this===null){return this;}
|
17
|
+
if(this instanceof Node||this instanceof NodeList||this instanceof NamedNodeMap){die('You cannot clone a Node, Nodelist or NamedNodeMap');}
|
18
|
+
var clone=isTypeof(Array,this)?[]:{};for(var prop in this){if(this.hasOwnProperty(prop)){clone[prop]=this[prop];}}
|
19
|
+
return clone;});}
|
20
|
+
var JudoModule=function(){};JudoModule.method('actions',function(){});JudoModule.method('run',function(){this.actions();});var JudoApplication=function(){};JudoApplication.method('addModule',function(name){try{if(doesNotExist(name)){throw new SyntaxError("JudoApplication.addModule(name): name is undefined");}
|
21
|
+
if(exists(this[name])){throw new SyntaxError("JudoApplication.addModule(name): '"+name+"' already declared");}
|
22
|
+
this[name]=new JudoModule();}
|
23
|
+
catch(error){document.write(error.message);}});var Judo::Configuration=new JudoApplication();Array.method('is_empty',function(){return(this.length<1)?true:false;});Array.method('not_empty',function(){return(this.length>0)?true:false;});Array.method('each',function(callback){try{if(doesNotExist(callback)){throw new SyntaxError("Array.each(callback): callback is undefined");}
|
24
|
+
for(var i=0;i<this.length;i++){var args=[this[i],i];callback.apply(this,args);}}
|
25
|
+
catch(error){document.write(error.message);}});Array.method('contains',function(suspect){var matches=[];this.each(function(value,index){if(value===suspect){matches.push(index);}});return matches.not_empty()?matches:false;});Array.method('shuffle',function(){var clone=this.clone();for(var j,x,i=clone.length;i;j=parseInt(Math.random()*i),x=clone[--i],clone[i]=clone[j],clone[j]=x);return clone;});String.method('is_empty',function(){return(this=='')?true:false;});String.method('not_empty',function(){return(this=='')?false:true;});String.method('is_number',function(){var pattern=/^(\.|-)?\d+(?:\.\d*)?(?:e[+\-]?\d+)?$/i;return pattern.test(this);});String.method('trim',function(){return this.replace(/^\s+|\s+$/g,"");});String.method('ltrim',function(){return this.replace(/^\s+/,"");});String.method('rtrim',function(){return this.replace(/\s+$/,"");});String.method('each',function(callback){try{if(doesNotExist(callback)){throw new SyntaxError("String.each(callback): callback is undefined");}
|
26
|
+
for(var i=0;i<this.length;i++){var args=[this.charAt(i),i];callback.apply(this,args);}}
|
27
|
+
catch(error){document.write(error.message);}});String.method('capitalize',function(){return this.substr(0,1).toUpperCase()+this.substr(1);});String.method('reverse',function(){return this.split('').reverse().join('');});String.method('to_n',function(){return parseFloat(this);});String.method('pluck',function(needle){var pattern=new RegExp(needle,'g');return this.replace(pattern,'');});String.method('single_space',function(){var no_hard_spaces=this.replace(/\ \;/g,' ');return no_hard_spaces.replace(/\s+/g,' ');});String.method('compress',function(){return this.replace(/\s+/g,'');});String.method('shuffle',function(){return this.split('').shuffle().join('');})
|
@@ -0,0 +1,100 @@
|
|
1
|
+
Array.method('is_empty', function() {
|
2
|
+
return (this.length < 1) ? true : false;
|
3
|
+
});
|
4
|
+
|
5
|
+
Array.method('not_empty', function() {
|
6
|
+
return (this.length > 0) ? true : false;
|
7
|
+
});
|
8
|
+
|
9
|
+
Array.method('each', function(callback) {
|
10
|
+
try {
|
11
|
+
if(doesNotExist(callback)) {
|
12
|
+
throw new SyntaxError("Array.each(callback): callback is undefined");
|
13
|
+
}
|
14
|
+
|
15
|
+
for (var i = 0; i < this.length; i++) {
|
16
|
+
var args = [this[i], i];
|
17
|
+
callback.apply(this, args);
|
18
|
+
}
|
19
|
+
}
|
20
|
+
catch(error) {
|
21
|
+
alert(error.message);
|
22
|
+
}
|
23
|
+
});
|
24
|
+
|
25
|
+
Array.method('contains', function(suspect) {
|
26
|
+
var matches = [];
|
27
|
+
this.each(function(value, index) {
|
28
|
+
if(value === suspect) {
|
29
|
+
matches.push(index);
|
30
|
+
}
|
31
|
+
});
|
32
|
+
|
33
|
+
return matches.not_empty() ? matches : false;
|
34
|
+
});
|
35
|
+
String.method('is_empty', function() {
|
36
|
+
return (this == '') ? true : false;
|
37
|
+
});
|
38
|
+
|
39
|
+
String.method('not_empty', function() {
|
40
|
+
return (this == '') ? false : true;
|
41
|
+
});
|
42
|
+
|
43
|
+
String.method('is_number', function() {
|
44
|
+
var pattern = /^(\.|-)?\d+(?:\.\d*)?(?:e[+\-]?\d+)?$/i;
|
45
|
+
return pattern.test(this);
|
46
|
+
});
|
47
|
+
|
48
|
+
String.method('trim', function() {
|
49
|
+
return this.replace(/^\s+|\s+$/g, "");
|
50
|
+
});
|
51
|
+
|
52
|
+
String.method('ltrim', function() {
|
53
|
+
return this.replace(/^\s+/,"");
|
54
|
+
});
|
55
|
+
|
56
|
+
String.method('rtrim', function() {
|
57
|
+
return this.replace(/\s+$/,"");
|
58
|
+
});
|
59
|
+
|
60
|
+
String.method('each', function(callback) {
|
61
|
+
try {
|
62
|
+
if(doesNotExist(callback)) {
|
63
|
+
throw new SyntaxError("String.each(callback): callback is undefined");
|
64
|
+
}
|
65
|
+
|
66
|
+
for (var i = 0; i < this.length; i++) {
|
67
|
+
var args = [this.charAt(i), i];
|
68
|
+
callback.apply(this, args);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
catch(error) {
|
72
|
+
alert(error.message);
|
73
|
+
}
|
74
|
+
});
|
75
|
+
|
76
|
+
String.method('capitalize', function() {
|
77
|
+
return this.substr(0, 1).toUpperCase() + this.substr(1);
|
78
|
+
});
|
79
|
+
|
80
|
+
String.method('reverse', function() {
|
81
|
+
return this.split('').reverse().join('');
|
82
|
+
});
|
83
|
+
|
84
|
+
String.method('to_n', function() {
|
85
|
+
return parseFloat(this);
|
86
|
+
});
|
87
|
+
|
88
|
+
String.method('pluck', function(needle) {
|
89
|
+
var pattern = new RegExp(needle, 'g');
|
90
|
+
return this.replace(pattern, '');
|
91
|
+
});
|
92
|
+
|
93
|
+
String.method('single_space', function() {
|
94
|
+
var no_hard_spaces = this.replace(/\ \;/g, ' ');
|
95
|
+
return no_hard_spaces.replace(/\s+/g, ' ');
|
96
|
+
});
|
97
|
+
|
98
|
+
String.method('compress', function() {
|
99
|
+
return this.replace(/\s+/g, '');
|
100
|
+
});
|
data/tests/jpm_test.rb
ADDED
data/tests/judo_test.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require '../lib/judojs.rb'
|
3
|
+
|
4
|
+
class TC_TestProject < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_directories
|
7
|
+
assert_equal('/Volumes/Storage/Development/judojs/lib', Judojs.lib_directory, 'Judojs.lib_directory is set correctly')
|
8
|
+
assert_equal('/Volumes/Storage/Development/judojs', Judojs.base_directory, 'Judojs.base_directory is set correctly')
|
9
|
+
assert_equal('/Volumes/Storage/Development/judojs/tests', Judojs.root_directory,'Judojs.root_directory is set correctly')
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|