distil 0.13.6 → 0.14.0.b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. data/Rakefile +1 -0
  2. data/VERSION +1 -1
  3. data/assets/distil.js +9 -7
  4. data/bin/distil +36 -60
  5. data/distil.gemspec +17 -32
  6. data/distil.tmproj +46 -15
  7. data/lib/distil/browser.rb +30 -26
  8. data/lib/distil/configurable.rb +64 -153
  9. data/lib/distil/error-reporter.rb +22 -20
  10. data/lib/distil/file-vendor.rb +29 -0
  11. data/lib/distil/hash-additions.rb +45 -0
  12. data/lib/distil/javascript-code.rb +12 -0
  13. data/lib/distil/{task/validate-js-task.rb → javascript-file-validator.rb} +19 -23
  14. data/lib/distil/library.rb +243 -0
  15. data/lib/distil/product/cache-manifest-product.rb +21 -0
  16. data/lib/distil/product/css-product.rb +41 -23
  17. data/lib/distil/product/html-product.rb +20 -0
  18. data/lib/distil/product/javascript-product.rb +122 -111
  19. data/lib/distil/product.rb +90 -76
  20. data/lib/distil/project.rb +370 -104
  21. data/lib/distil/recursive-http-fetcher.rb +72 -0
  22. data/lib/distil/server.rb +43 -0
  23. data/lib/distil/source-file/css-file.rb +56 -3
  24. data/lib/distil/source-file/html-file.rb +5 -6
  25. data/lib/distil/source-file/javascript-file.rb +96 -8
  26. data/lib/distil/source-file/json-file.rb +2 -4
  27. data/lib/distil/source-file/yui-minifiable-file.rb +19 -0
  28. data/lib/distil/source-file.rb +50 -92
  29. data/lib/distil/subclass-tracker.rb +13 -0
  30. data/lib/distil.rb +21 -37
  31. metadata +40 -39
  32. data/assets/mime.types +0 -1240
  33. data/lib/distil/configurable/file-set.rb +0 -85
  34. data/lib/distil/configurable/interpolated.rb +0 -36
  35. data/lib/distil/configurable/output-path.rb +0 -25
  36. data/lib/distil/configurable/project-path.rb +0 -25
  37. data/lib/distil/product/concatenated.rb +0 -83
  38. data/lib/distil/product/debug.rb +0 -32
  39. data/lib/distil/product/javascript-base-product.rb +0 -35
  40. data/lib/distil/product/javascript-doc-product.rb +0 -61
  41. data/lib/distil/product/minified.rb +0 -41
  42. data/lib/distil/product/page-product.rb +0 -27
  43. data/lib/distil/product/pdoc-product.rb +0 -42
  44. data/lib/distil/project/distil-project.rb +0 -157
  45. data/lib/distil/project/external-project.rb +0 -58
  46. data/lib/distil/project/remote-project.rb +0 -43
  47. data/lib/distil/target.rb +0 -251
  48. data/lib/distil/task/css-dependency-task.rb +0 -64
  49. data/lib/distil/task/jsl-dependency-task.rb +0 -50
  50. data/lib/distil/task/nib-task.rb +0 -72
  51. data/lib/distil/task.rb +0 -50
  52. data/lib/jsdoc.conf +0 -18
  53. data/lib/test/HtmlTestReporter.js +0 -127
  54. data/lib/test/Test.js +0 -248
  55. data/lib/test/TestReporter.js +0 -79
  56. data/lib/test/TestRunner.js +0 -132
  57. data/lib/test/browser.rb +0 -97
  58. data/lib/test/scriptwrapper.html +0 -10
  59. data/lib/test/unittest.html +0 -127
@@ -1,127 +0,0 @@
1
- var TestReporter= {
2
-
3
- __numberOfFailures: 0,
4
- __numberOfTests: 0,
5
- __numberOfPasses: 0,
6
- __numberOfSkipped: 0,
7
-
8
- __currentTest: '',
9
-
10
- setup: function(id)
11
- {
12
- this.container= document.getElementById(id);
13
- this.results= document.createElement('p');
14
- this.results.className='test-results';
15
- this.container.appendChild(this.results);
16
- this.node= document.createElement('ul');
17
- this.node.className='test-report-items';
18
- this.container.appendChild(this.node);
19
- },
20
-
21
- statistics: function()
22
- {
23
- return {
24
- numberOfFailures: this.__numberOfFailures,
25
- numberOfTests: this.__numberOfTests,
26
- numberOfPasses: this.__numberOfPasses,
27
- numberOfSkipped: this.__numberOfSkipped
28
- };
29
- },
30
-
31
- complete: function()
32
- {
33
- var text= [this.__numberOfTests, ' tests: ', this.__numberOfPasses,
34
- ' passed ', this.__numberOfFailures, ' failed ',
35
- this.__numberOfSkipped, ' skipped'].join("");
36
-
37
- var node= document.createTextNode(text);
38
- this.results.innerHTML="";
39
- this.results.appendChild(node);
40
- },
41
-
42
- log: function()
43
- {
44
- var len= arguments.length;
45
- var m= [];
46
-
47
- for (var i=0; i<len; ++i)
48
- m.push(String(arguments[i]));
49
- this.print(' log: ' + this.__currentTest + ': ' + m.join(' '));
50
- },
51
-
52
- print: function(m, status)
53
- {
54
- var line= document.createElement('li');
55
- if (status)
56
- line.className='test-report-item-' + status;
57
-
58
- line.appendChild(document.createTextNode(m));
59
- var text= line.innerHTML;
60
- var r= /((?:(?:&lt;)|\s|^)(\w+:\/\/[^\s]*?)(?:(?:&gt;)|\s|$))/g;
61
- text= text.replace(r, '<a href="$2">$1</a>');
62
- line.innerHTML= text;
63
- this.node.appendChild(line);
64
-
65
- if ('failure'==status && this.onfailure)
66
- this.onfailure(m);
67
- },
68
-
69
- beginTest: function(test, testName)
70
- {
71
- this.__currentTest= test + '#' + testName;
72
- ++this.__numberOfTests;
73
- },
74
-
75
- endTest: function(test, testName)
76
- {
77
- },
78
-
79
- failed: function(test, testName, message)
80
- {
81
- this.print('failed: ' + test + "#" + testName + ": " + message, 'failure');
82
- ++this.__numberOfFailures;
83
- },
84
-
85
- skipped: function(test, testName, message)
86
- {
87
- this.print('skipped: ' + test + "#" + testName + ': ' + message,
88
- 'skip');
89
- ++this.__numberOfSkipped;
90
- },
91
-
92
- passed: function(test, testName)
93
- {
94
- this.print('passed: ' + test + '#' + testName);
95
- ++this.__numberOfPasses;
96
- },
97
-
98
- uncaughtException: function(test, testName, e)
99
- {
100
- this.print('uncaught exception: ' + test + '#' + testName + ': ' +
101
- e.name + ': ' + e.message, 'failure');
102
- ++this.__numberOfFailures;
103
- },
104
-
105
- exceptionInSetup: function(test, testName, e)
106
- {
107
- this.print('uncaught exception in setup: ' + test + '#' + testName + ': ' +
108
- e.name + ': ' + e.message, 'failure');
109
- ++this.__numberOfFailures;
110
- },
111
-
112
- exceptionInTeardown: function(test, testName, e)
113
- {
114
- this.print('uncaught exception in teardown: ' + test + '#' + testName + ': ' +
115
- e.name + ': ' + e.message, 'failure');
116
- ++this.__numberOfFailures;
117
- },
118
-
119
- timeoutExpired: function(test, testName, timeout)
120
- {
121
- this.print('timeout: ' + test + '#' + testName +
122
- ': did not complete after ' + timeout + ' milliseconds',
123
- 'failure');
124
- ++this.__numberOfFailures;
125
- }
126
-
127
- };
data/lib/test/Test.js DELETED
@@ -1,248 +0,0 @@
1
- function TestHelper(scope, report, test, testName)
2
- {
3
- this.scope= scope;
4
- this.report= report;
5
- this.test= test;
6
- this.testName= testName;
7
- this._async= false;
8
- }
9
- TestHelper.prototype= {
10
-
11
- __ASYNC_MARKER__: 'async_marker',
12
-
13
- stringFromValue: function(v)
14
- {
15
- return String(v);
16
- },
17
-
18
- compareArrays: function(a1, a2)
19
- {
20
- if (a1.length==a2.length)
21
- {
22
- var len=a1.length;
23
- var i;
24
-
25
- for (i=0; i<len; ++i)
26
- if (a1[i]!==a2[i])
27
- return false;
28
- return true;
29
- }
30
-
31
- return false;
32
- },
33
-
34
- log: function()
35
- {
36
- this.report.log.apply(this.report, arguments);
37
- },
38
-
39
- passed: function()
40
- {
41
- if (this._finished)
42
- return;
43
-
44
- this.report.passed(this.test, this.testName);
45
- this.finishAsync();
46
- },
47
-
48
- clearTimer: function()
49
- {
50
- if (!this._timer)
51
- return;
52
- window.clearTimeout(this._timer);
53
- this._timer= 0;
54
- },
55
-
56
- finishAsync: function()
57
- {
58
- if (!this._async || this._finished)
59
- return;
60
-
61
- this._finished= true;
62
- this.clearTimer();
63
- try
64
- {
65
- if (this.teardown)
66
- this.teardown.call(this.scope);
67
- }
68
- catch (e)
69
- {
70
- this.report.exceptionInTeardown(this.test, this.testName, e);
71
- }
72
-
73
- this.report.endTest(this.test, this.testName);
74
- if (this.ontestcomplete)
75
- this.ontestcomplete();
76
- },
77
-
78
- /** Create an asynchronous handler for this method. If the test
79
- * doesn't complete before the timeout expires, then the test
80
- * fails.
81
- */
82
- async: function(timeout)
83
- {
84
- var helper= this;
85
-
86
- function timeoutFn()
87
- {
88
- helper.report.timeoutExpired(helper.test, helper.testName, timeout);
89
- helper.finishAsync();
90
- }
91
-
92
- this._timer= window.setTimeout(timeoutFn, timeout);
93
- this._async= true;
94
- return this.__ASYNC_MARKER__;
95
- },
96
-
97
- assert: function(value, msg)
98
- {
99
- this.assertTrue(value, msg);
100
- },
101
-
102
- assertEqual: function(value, expected, msg)
103
- {
104
- if ('object'===typeof(value) && 'object'===typeof(expected) &&
105
- value.splice && expected.splice)
106
- {
107
- if (this.compareArrays(value, expected))
108
- return;
109
- }
110
- else if (value===expected)
111
- return;
112
-
113
- this.fail(msg||(this.stringFromValue(value) + '===' +
114
- this.stringFromValue(expected)));
115
- },
116
-
117
- assertNotEqual: function(value, expected, msg)
118
- {
119
- if (value!==expected)
120
- return;
121
- this.fail(msg||(this.stringFromValue(value) + '!==' +
122
- this.stringFromValue(expected)));
123
- },
124
-
125
- assertTrue: function(value, msg)
126
- {
127
- if (true===value)
128
- return;
129
- this.fail(msg||(this.stringFromValue(value) + ' is not true'));
130
- },
131
-
132
- assertFalse: function(value, msg)
133
- {
134
- if (false===value)
135
- return;
136
- this.fail(msg||(this.stringFromValue(value) + ' is not false'));
137
- },
138
-
139
- assertNull: function(value, msg)
140
- {
141
- if (null===value)
142
- return;
143
- this.fail(msg||(this.stringFromValue(value) + ' is not null'));
144
- },
145
-
146
- assertNotNull: function(value, msg)
147
- {
148
- if (null!==value)
149
- return;
150
- this.fail(msg||(this.stringFromValue(value) + ' is null'));
151
- },
152
-
153
- assertUndefined: function(value, msg)
154
- {
155
- if ('undefined'===typeof(value))
156
- return;
157
- this.fail(msg||(this.stringFromValue(value) + ' is not undefined'));
158
- },
159
-
160
- assertNotUndefined: function(value, msg)
161
- {
162
- if ('undefined'!==typeof(value))
163
- return;
164
- this.fail(msg||(this.stringFromValue(value) + ' is undefined'));
165
- },
166
-
167
- assertMatch: function(regex, value, msg)
168
- {
169
- if (regex.exec(value))
170
- return;
171
- this.fail(msg||(this.stringFromValue(value) + ' did not match /' + regex.source + '/'));
172
- },
173
-
174
- assertNotMatch: function(regex, value, msg)
175
- {
176
- if (!regex.exec(value))
177
- return;
178
- this.fail(msg||(this.stringFromValue(value) + ' matched /' + regex.source + '/'));
179
- },
180
-
181
- assertInstanceOf: function(value, klass, msg)
182
- {
183
- if (value instanceof klass)
184
- return;
185
- this.fail(msg||(this.stringFromValue(value) + ' is not an instance'));
186
- },
187
-
188
- assertNotInstanceOf: function(value, klass, msg)
189
- {
190
- if (!(value instanceof klass))
191
- return;
192
- this.fail(msg||(this.stringFromValue(value) + ' is an instance'));
193
- },
194
-
195
- fail: function(msg)
196
- {
197
- if (this._finished)
198
- return;
199
-
200
- msg= msg||'failed';
201
- this.report.failed(this.test, this.testName, msg);
202
-
203
- this.finishAsync();
204
-
205
- var error= new Error(msg);
206
- error.name= 'AssertionError';
207
- throw error;
208
- },
209
-
210
- skip: function(why)
211
- {
212
- if (this._finished)
213
- return;
214
-
215
- why= why||'Test skipped';
216
- this.report.skipped(this.test, this.testName, why);
217
-
218
- this.finishAsync();
219
-
220
- var error= new Error(why);
221
- error.name= 'AssertionError';
222
- throw error;
223
- }
224
-
225
- };
226
-
227
-
228
- var Test= {
229
-
230
- /** Register a group of tests. This might do some clever processing of
231
- * each test function.
232
- */
233
- create: function(name, decl)
234
- {
235
- window.top.Test.numberOfRegisteredTests++;
236
- window.top.Test._tests[name]= decl;
237
- },
238
-
239
- reset: function()
240
- {
241
- this._tests={};
242
- this.numberOfRegisteredTests= 0;
243
- },
244
-
245
- numberOfRegisteredTests: 0,
246
- _tests: {}
247
-
248
- };
@@ -1,79 +0,0 @@
1
- function print(msg)
2
- {
3
- console.log(msg);
4
- }
5
-
6
- var TestReporter= {
7
-
8
- __numberOfFailures: 0,
9
- __numberOfTests: 0,
10
- __numberOfPasses: 0,
11
- __numberOfSkipped: 0,
12
-
13
- setup: function()
14
- {},
15
-
16
- complete: function()
17
- {
18
- print(this.__numberOfTests + ' tests ' + this.__numberOfPasses + ' passed ' +
19
- this.__numberOfFailures + ' failed ' + this.__numberOfSkipped + ' skipped');
20
- },
21
-
22
- beginTest: function(test, testName)
23
- {
24
- print('begin: ' + test + '#' + testName);
25
- ++this.__numberOfTests;
26
- },
27
-
28
- endTest: function(test, testName)
29
- {
30
- print('end: ' + test + '#' + testName);
31
- },
32
-
33
- failed: function(test, testName, message)
34
- {
35
- print('failed: ' + test + "#" + testName + ": " + message);
36
- ++this.__numberOfFailures;
37
- },
38
-
39
- skipped: function(test, testName, message)
40
- {
41
- print('skipped: ' + test + "#" + testName + ': ' + message);
42
- ++this.__numberOfSkipped;
43
- },
44
-
45
- passed: function(test, testName)
46
- {
47
- print('passed: ' + test + '#' + testName);
48
- ++this.__numberOfPasses;
49
- },
50
-
51
- uncaughtException: function(test, testName, e)
52
- {
53
- print('uncaught exception: ' + test + '#' + testName + ': ' +
54
- e.name + ': ' + e.message);
55
- ++this.__numberOfFailures;
56
- },
57
-
58
- exceptionInSetup: function(test, testName, e)
59
- {
60
- print('uncaught exception in setup: ' + test + '#' + testName + ': ' +
61
- e.name + ': ' + e.message);
62
- ++this.__numberOfFailures;
63
- },
64
-
65
- exceptionInTeardown: function(test, testName, e)
66
- {
67
- print('uncaught exception in teardown: ' + test + '#' + testName + ': ' +
68
- e.name + ': ' + e.message);
69
- ++this.__numberOfFailures;
70
- },
71
-
72
- timeoutExpired: function(test, testName, timeout)
73
- {
74
- print('timeout: ' + test + '#' + testName +
75
- ': did not complete after ' + timeout + ' milliseconds');
76
- ++this.__numberOfFailures;
77
- }
78
-
79
- };
@@ -1,132 +0,0 @@
1
- /*jsl:import Test.js*/
2
- /*jsl:import TestReporter.js*/
3
-
4
- var TestRunner = {
5
-
6
- _queue: [],
7
- _timer: 0,
8
-
9
- run: function(testGroup, reporter)
10
- {
11
- var test= Test._tests[testGroup];
12
- reporter= reporter || TestReporter;
13
-
14
- for (var testName in test)
15
- {
16
- if (!/^test[A-Z]/.test(testName))
17
- continue;
18
- this._queue.push([testGroup, testName, reporter]);
19
- }
20
-
21
- this.next();
22
- },
23
-
24
- runAll: function(reporter)
25
- {
26
- reporter= reporter || TestReporter;
27
- for (var testGroup in Test._tests)
28
- this.run(testGroup, reporter);
29
- this.next();
30
- },
31
-
32
- next: function()
33
- {
34
- if (this._timer)
35
- return;
36
-
37
- if (!this._queue.length)
38
- {
39
- TestReporter.complete();
40
- if (this.oncomplete)
41
- this.oncomplete();
42
- return;
43
- }
44
-
45
- var args= this._queue.shift();
46
- var runner= this;
47
-
48
- function go()
49
- {
50
- runner._timer= 0;
51
- runner._run.apply(runner, args);
52
- }
53
- this._timer= window.setTimeout(go, 10);
54
- },
55
-
56
- _run: function(testGroup, testName, reporter)
57
- {
58
- var runner= this;
59
- var test= Test._tests[testGroup];
60
- if (!test)
61
- {
62
- reporter.failed(testGroup, null, 'could not find test group: "' + testGroup + '"');
63
- return;
64
- }
65
-
66
- var setup= test['setup'];
67
- var teardown= test['teardown'];
68
-
69
- if (!test[testName])
70
- {
71
- reporter.failed(testGroup, testName, 'could not find test function: "' + testName + '"');
72
- return;
73
- }
74
-
75
- function Scope()
76
- {
77
- }
78
- Scope.prototype= test;
79
-
80
- reporter.beginTest(testGroup, testName);
81
-
82
- var scope= new Scope();
83
- var helper= new TestHelper(scope, reporter, testGroup, testName);
84
- helper.ontestcomplete= function()
85
- {
86
- runner.next();
87
- }
88
-
89
- try
90
- {
91
- if (setup)
92
- setup.call(scope);
93
- }
94
- catch (e)
95
- {
96
- reporter.exceptionInSetup(testGroup, testName, e);
97
- return;
98
- }
99
-
100
- try
101
- {
102
- var result= scope[testName](helper);
103
-
104
- if (result===helper.__ASYNC_MARKER__)
105
- {
106
- helper.teardown= teardown;
107
- return;
108
- }
109
-
110
- reporter.passed(testGroup, testName);
111
- }
112
- catch (e)
113
- {
114
- if ('AssertionError'!=e.name)
115
- reporter.uncaughtException(testGroup, testName, e);
116
- }
117
-
118
- try
119
- {
120
- if (teardown)
121
- teardown.call(scope);
122
- }
123
- catch (e)
124
- {
125
- reporter.exceptionInTeardown(testGroup, testName, e);
126
- }
127
-
128
- reporter.endTest(testGroup, testName);
129
- this.next();
130
- }
131
-
132
- };
data/lib/test/browser.rb DELETED
@@ -1,97 +0,0 @@
1
- class Browser
2
- def supported?; true; end
3
- def setup ; end
4
- def open(url) ; end
5
- def teardown ; end
6
-
7
- def host
8
- require 'rbconfig'
9
- Config::CONFIG['host']
10
- end
11
-
12
- def macos?
13
- host.include?('darwin')
14
- end
15
-
16
- def windows?
17
- host.include?('mswin')
18
- end
19
-
20
- def linux?
21
- host.include?('linux')
22
- end
23
-
24
- def applescript(script)
25
- raise "Can't run AppleScript on #{host}" unless macos?
26
- system "osascript -e '#{script}' 2>&1 >/dev/null"
27
- end
28
- end
29
-
30
- class FirefoxBrowser < Browser
31
- def initialize(path=File.join(ENV['ProgramFiles'] || 'c:\Program Files', '\Mozilla Firefox\firefox.exe'))
32
- @path = path
33
- end
34
-
35
- def visit(url)
36
- system("open -a \"Firefox.app\" '#{url}'") if macos?
37
- system("#{@path} #{url}") if windows?
38
- system("firefox #{url}") if linux?
39
- end
40
-
41
- def to_s
42
- "Firefox"
43
- end
44
- end
45
-
46
- class SafariBrowser < Browser
47
- def supported?
48
- macos?
49
- end
50
-
51
- def setup
52
- applescript('tell application "Safari" to make new document')
53
- end
54
-
55
- def visit(url)
56
- applescript('tell application "Safari" to set URL of front document to "' + url + '"')
57
- end
58
-
59
- def teardown
60
- #applescript('tell application "Safari" to close front document')
61
- end
62
-
63
- def to_s
64
- "Safari"
65
- end
66
- end
67
-
68
- class IEBrowser < Browser
69
- def setup
70
- require 'win32ole' if windows?
71
- end
72
-
73
- def supported?
74
- windows?
75
- end
76
-
77
- def visit(url)
78
- if windows?
79
- ie = WIN32OLE.new('InternetExplorer.Application')
80
- ie.visible = true
81
- ie.Navigate(url)
82
- while ie.ReadyState != 4 do
83
- sleep(1)
84
- end
85
- end
86
- end
87
-
88
- def to_s
89
- "Internet Explorer"
90
- end
91
- end
92
-
93
- $browsers= {
94
- "safari" => SafariBrowser,
95
- "firefox" => FirefoxBrowser,
96
- "ie" => IEBrowser
97
- }
@@ -1,10 +0,0 @@
1
- <!DOCTYPE HTML">
2
- <html>
3
- <head>
4
- <title>@title@</title>
5
- <script src="/lib/test/Test.js" type="text/javascript" charset="utf-8"></script>
6
- @scripts@
7
- </head>
8
- <body>
9
- </body>
10
- </html>