architect 0.0.7 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +2 -0
- data/README.md +5 -1
- data/Rakefile +22 -1
- data/app/assets/javascripts/architect/workers/ajax_worker.coffee +1 -0
- data/app/assets/javascripts/workers/ajax_worker.coffee +2 -0
- data/architect.gemspec +21 -0
- data/lib/architect/version.rb +1 -1
- data/lib/tasks/task_helpers.rb +1 -1
- data/static/architect.min.js +10 -1
- data/static/workers/ajax_worker.min.js +10 -1
- data/static/workers/jsonp_worker.min.js +10 -1
- data/static/workers/proxy_worker.min.js +10 -1
- data/test/fixture/foozle_worker.js +4 -0
- data/test/index.html +19 -0
- data/test/runner.js +139 -0
- data/test/unit/architect/polyfill_test.js +54 -0
- data/test/unit/architect_test.js +49 -0
- metadata +23 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cc29094107fa1e8e42c14a8ada858d19648e954
|
4
|
+
data.tar.gz: 15b940dc6ced00de718d161289b17b53a563515d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd3e5db5706aabcccbc7b6b179f328fe72331292c6baebcf4ce6b63d244342c82464853848e8d6bd64110b2801c88b0a9f5ae36f0f32de9f1d94964f2ba0faff
|
7
|
+
data.tar.gz: 64693c0b448646829b70e10a8e9c9d07d1e972b65bd6f8a926e44ad04061f24471cc2686c3ce6a18ca7fcdd045394800753084ff324a5ced3d0ae54fab6f93b7
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Gemfile.lock
|
data/CHANGELOG.md
CHANGED
data/Gemfile
ADDED
data/README.md
CHANGED
@@ -9,6 +9,10 @@
|
|
9
9
|
He will manage and polyfill them workers so you don’t have to.
|
10
10
|
</p>
|
11
11
|
|
12
|
+
<p align="center">
|
13
|
+
<a href="http://badge.fury.io/rb/architect"><img src="https://badge.fury.io/rb/architect@2x.png" alt="Gem Version" height="18"></a>
|
14
|
+
</p>
|
15
|
+
|
12
16
|
## Short-lived workers
|
13
17
|
These will be automatically terminated as soon as the work is done. It will spawn a new worker every time.
|
14
18
|
|
@@ -154,7 +158,7 @@ Architect.workFrom('workers/foozle.js', 'foo', foozleFallback, function(data) {
|
|
154
158
|
3. Restart your server and you'll have access to your very own Architect!
|
155
159
|
|
156
160
|
### Other
|
157
|
-
You’ll need to serve the [worker files](/static/workers) at `/architect` (i.e. `http://foo.com/architect/proxy_worker.min.js`) and manually include [architect.min.js](/static/architect.min.js) to your HTML pages.
|
161
|
+
You’ll need to serve the [worker files](https://github.com/EtienneLem/architect/tree/master/static/workers) at `/architect` (i.e. `http://foo.com/architect/proxy_worker.min.js`) and manually include [architect.min.js](https://github.com/EtienneLem/architect/tree/master/static/architect.min.js) to your HTML pages. Architect is also hosted on [cdnjs.com](http://cdnjs.com).
|
158
162
|
|
159
163
|
#### Custom path
|
160
164
|
You can also specify any path you want to serve the workers from.
|
data/Rakefile
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
$:.unshift File.join(File.dirname(__FILE__), *%w[lib])
|
2
2
|
require 'tasks/task_helpers'
|
3
3
|
|
4
|
+
# Rubygems
|
5
|
+
require 'bundler'
|
6
|
+
Bundler::GemHelper.install_tasks
|
7
|
+
|
8
|
+
# Dependencies
|
4
9
|
require 'uglifier'
|
5
10
|
require 'architect'
|
6
11
|
require 'sprockets'
|
7
12
|
|
13
|
+
# Tasks
|
8
14
|
desc 'Merge, compiles and minify CoffeeScript files'
|
9
15
|
task :compile do
|
10
16
|
@environment = Sprockets::Environment.new
|
@@ -27,6 +33,21 @@ task :default => :compile
|
|
27
33
|
def compile(file)
|
28
34
|
minjs = @environment[file].to_s
|
29
35
|
out = "static/#{file.sub('.js', '.min.js')}"
|
30
|
-
|
36
|
+
|
37
|
+
File.open(out, 'w') { |f| f.write(copyright + minjs + "\n") }
|
31
38
|
success "Compiled #{out}"
|
32
39
|
end
|
40
|
+
|
41
|
+
def copyright
|
42
|
+
@copyright ||= <<-EOS
|
43
|
+
/*
|
44
|
+
* Architect v#{Architect::VERSION}
|
45
|
+
* http://architectjs.org
|
46
|
+
*
|
47
|
+
* Copyright 2013, Etienne Lemay http://heliom.ca
|
48
|
+
* Released under the MIT license
|
49
|
+
*
|
50
|
+
* Date: #{Time.now}
|
51
|
+
*/
|
52
|
+
EOS
|
53
|
+
end
|
@@ -3,6 +3,7 @@ class @Architect.AjaxWorker extends @Architect.Worker
|
|
3
3
|
postMessage: (url) ->
|
4
4
|
xhr = new XMLHttpRequest
|
5
5
|
xhr.open('GET', url)
|
6
|
+
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
|
6
7
|
|
7
8
|
xhr.onreadystatechange = (e) =>
|
8
9
|
return unless xhr.readyState is 4 && xhr.status is 200
|
@@ -4,6 +4,8 @@ handleRequest = (data) ->
|
|
4
4
|
addEventListener 'message', (e) ->
|
5
5
|
xhr = new XMLHttpRequest
|
6
6
|
xhr.open('GET', e.data)
|
7
|
+
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
|
8
|
+
|
7
9
|
xhr.onreadystatechange = (e) ->
|
8
10
|
return unless xhr.readyState is 4 && xhr.status is 200
|
9
11
|
handleRequest(xhr.responseText)
|
data/architect.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require './lib/architect/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'architect'
|
5
|
+
s.version = Architect::VERSION
|
6
|
+
s.authors = ['Etienne Lemay']
|
7
|
+
s.email = ['etienne@heliom.ca']
|
8
|
+
s.homepage = 'http://architectjs.org'
|
9
|
+
s.summary = 'Your web workers’ supervisor'
|
10
|
+
s.description = 'Architect is a JavaScript library built on top of Web Workers that will handle and polyfill HTML Web Workers.'
|
11
|
+
s.license = 'MIT'
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split($/)
|
14
|
+
s.test_files = s.files.grep(%r{^(test)/})
|
15
|
+
|
16
|
+
s.add_dependency 'coffee-rails'
|
17
|
+
|
18
|
+
s.add_development_dependency 'rake'
|
19
|
+
s.add_development_dependency 'uglifier'
|
20
|
+
s.add_development_dependency 'sprockets'
|
21
|
+
end
|
data/lib/architect/version.rb
CHANGED
data/lib/tasks/task_helpers.rb
CHANGED
data/static/architect.min.js
CHANGED
@@ -1 +1,10 @@
|
|
1
|
-
|
1
|
+
/*
|
2
|
+
* Architect v0.1.0
|
3
|
+
* http://architectjs.org
|
4
|
+
*
|
5
|
+
* Copyright 2013, Etienne Lemay http://heliom.ca
|
6
|
+
* Released under the MIT license
|
7
|
+
*
|
8
|
+
* Date: 2013-12-09 22:51:38 -0500
|
9
|
+
*/
|
10
|
+
(function(){this.Architect={},this.Architect.VERSION="0.1.0"}).call(this),function(){this.Architect.Worker=function(){function t(){this.callbacks={},this.callbacksQueue={}}return t.prototype.addEventListener=function(t,r){var e;return this.callbacks[t]=r,(e=this.callbacksQueue[t])?(delete this.callbacksQueue[t],this.dispatch(t,e)):void 0},t.prototype.dispatch=function(t,r){return this.callbacks[t]?this.callbacks[t]({data:r}):this.callbacksQueue[t]=r},t.prototype.handleRequest=function(t){return this.dispatch("message",t)},t.prototype.terminate=function(){},t}()}.call(this),function(){var t,r={}.hasOwnProperty,e=function(t,e){function n(){this.constructor=t}for(var o in e)r.call(e,o)&&(t[o]=e[o]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};this.Architect.AjaxWorker=function(r){function n(){return t=n.__super__.constructor.apply(this,arguments)}return e(n,r),n.prototype.postMessage=function(t){var r,e=this;return r=new XMLHttpRequest,r.open("GET",t),r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.onreadystatechange=function(){return 4===r.readyState&&200===r.status?e.handleRequest(r.responseText):void 0},r.send()},n}(this.Architect.Worker)}.call(this),function(){var t={}.hasOwnProperty,r=function(r,e){function n(){this.constructor=r}for(var o in e)t.call(e,o)&&(r[o]=e[o]);return n.prototype=e.prototype,r.prototype=new n,r.__super__=e.prototype,r};this.Architect.JSONPWorker=function(t){function e(){e.__super__.constructor.call(this),window.jsonpID||(window.jsonpID=0)}return r(e,t),e.prototype.postMessage=function(t){var r,e,n=this;return e=document.createElement("script"),r="architect_jsonp"+ ++window.jsonpID,window[r]=function(t){return delete window[r],document.head.removeChild(e),n.handleRequest(t)},e.src=this.appendQuery(t,"callback="+r),document.head.appendChild(e)},e.prototype.appendQuery=function(t,r){return(t+"&"+r).replace(/[&?]{1,2}/,"?")},e}(this.Architect.Worker)}.call(this),function(){var t,r={}.hasOwnProperty,e=function(t,e){function n(){this.constructor=t}for(var o in e)r.call(e,o)&&(t[o]=e[o]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};this.Architect.ProxyWorker=function(r){function n(){return t=n.__super__.constructor.apply(this,arguments)}return e(n,r),n.prototype.postMessage=function(t){return this.handleRequest(t)},n}(this.Architect.Worker)}.call(this),function(){var t,r,e,n=this;this.Architect.SUPPORT_WORKER=!!window.Worker,this.Architect.WORKERS={proxy:{polyfill:this.Architect.ProxyWorker,workerPath:"architect/proxy_worker.min.js"},ajax:{polyfill:this.Architect.AjaxWorker,workerPath:"architect/ajax_worker.min.js"},jsonp:{polyfill:this.Architect.JSONPWorker,workerPath:"architect/jsonp_worker.min.js"}},t=function(t){return this.Architect.workersPath?""+this.Architect.workersPath+"/"+t+"_worker.min.js":this.Architect.WORKERS[t].workerPath},e=function(r){return this.Architect.SUPPORT_WORKER?new Worker(t(r)):new this.Architect.WORKERS[r].polyfill},this.Architect.setupWorkersPath=function(t){return n.Architect.workersPath=t.replace(/\/$/,"")},this.Architect.work=function(t,r,n){var o;return o=e(r),o.postMessage(t),o.addEventListener("message",function(t){return o.terminate(),n(t.data)})},this.Architect.proxy=function(t,r){return n.Architect.work(t,"proxy",r)},this.Architect.ajax=function(t,r){return n.Architect.work(t,"ajax",r)},this.Architect.jsonp=function(t,r){return n.Architect.work(t,"jsonp",r)},r={},this.Architect.workOn=function(t,n,o,c){var i,s,a=this;return this.workOnCallback=c,i=!!r[t],s=r[t]||(r[t]=e(o)),s.postMessage(n),i?void 0:s.addEventListener("message",function(t){return a.workOnCallback(t.data)})},this.Architect.endJob=function(t){var e;if(e=r[t])return e.terminate(),delete r[t]},this.Architect.proxyOn=function(t,r,e){return n.Architect.workOn(t,r,"proxy",e)},this.Architect.ajaxOn=function(t,r,e){return n.Architect.workOn(t,r,"ajax",e)},this.Architect.jsonpOn=function(t,r,e){return n.Architect.workOn(t,r,"jsonp",e)},this.Architect.workFrom=function(t,r,e,o){var c;return null==e&&(e=null),void 0===o&&(o=e,e=null),n.Architect.SUPPORT_WORKER?(c=new Worker(t),c.postMessage(r),c.addEventListener("message",function(t){return c.terminate(),o(t.data)})):e?o(e(r)):console.warn("No fallback provided for "+t)}}.call(this);
|
@@ -1 +1,10 @@
|
|
1
|
-
|
1
|
+
/*
|
2
|
+
* Architect v0.1.0
|
3
|
+
* http://architectjs.org
|
4
|
+
*
|
5
|
+
* Copyright 2013, Etienne Lemay http://heliom.ca
|
6
|
+
* Released under the MIT license
|
7
|
+
*
|
8
|
+
* Date: 2013-12-09 22:51:38 -0500
|
9
|
+
*/
|
10
|
+
(function(){var e;e=function(e){return postMessage(e)},addEventListener("message",function(t){var n;return n=new XMLHttpRequest,n.open("GET",t.data),n.setRequestHeader("X-Requested-With","XMLHttpRequest"),n.onreadystatechange=function(){return 4===n.readyState&&200===n.status?e(n.responseText):void 0},n.send()})}).call(this);
|
@@ -1 +1,10 @@
|
|
1
|
-
|
1
|
+
/*
|
2
|
+
* Architect v0.1.0
|
3
|
+
* http://architectjs.org
|
4
|
+
*
|
5
|
+
* Copyright 2013, Etienne Lemay http://heliom.ca
|
6
|
+
* Released under the MIT license
|
7
|
+
*
|
8
|
+
* Date: 2013-12-09 22:51:38 -0500
|
9
|
+
*/
|
10
|
+
(function(){var e;self.handleRequest=function(e){return postMessage(e)},e=function(e,t){return(e+"&"+t).replace(/[&?]{1,2}/,"?")},addEventListener("message",function(t){var n;return n=e(t.data,"callback=handleRequest"),importScripts(n)})}).call(this);
|
@@ -1 +1,10 @@
|
|
1
|
-
|
1
|
+
/*
|
2
|
+
* Architect v0.1.0
|
3
|
+
* http://architectjs.org
|
4
|
+
*
|
5
|
+
* Copyright 2013, Etienne Lemay http://heliom.ca
|
6
|
+
* Released under the MIT license
|
7
|
+
*
|
8
|
+
* Date: 2013-12-09 22:51:38 -0500
|
9
|
+
*/
|
10
|
+
(function(){addEventListener("message",function(e){return postMessage(e.data)})}).call(this);
|
data/test/index.html
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>QUnit Example</title>
|
6
|
+
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.12.0.css">
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<div id="qunit"></div>
|
10
|
+
<div id="qunit-fixture"></div>
|
11
|
+
|
12
|
+
<script src="http://code.jquery.com/qunit/qunit-1.12.0.js"></script>
|
13
|
+
<script src="../static/architect.min.js"></script>
|
14
|
+
<script>Architect.setupWorkersPath('../static/workers')</script>
|
15
|
+
|
16
|
+
<script src="./unit/architect_test.js"></script>
|
17
|
+
<script src="./unit/architect/polyfill_test.js"></script>
|
18
|
+
</body>
|
19
|
+
</html>
|
data/test/runner.js
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
/*
|
2
|
+
* QtWebKit-powered headless test runner using PhantomJS
|
3
|
+
*
|
4
|
+
* PhantomJS binaries: http://phantomjs.org/download.html
|
5
|
+
* Requires PhantomJS 1.6+ (1.7+ recommended)
|
6
|
+
*
|
7
|
+
* Run with:
|
8
|
+
* phantomjs runner.js [url-of-your-qunit-testsuite]
|
9
|
+
*
|
10
|
+
* e.g.
|
11
|
+
* phantomjs runner.js http://localhost/qunit/test/index.html
|
12
|
+
*/
|
13
|
+
|
14
|
+
/*global phantom:false, require:false, console:false, window:false, QUnit:false */
|
15
|
+
|
16
|
+
(function() {
|
17
|
+
'use strict';
|
18
|
+
|
19
|
+
var url, page, timeout,
|
20
|
+
args = require('system').args;
|
21
|
+
|
22
|
+
// arg[0]: scriptName, args[1...]: arguments
|
23
|
+
if (args.length < 2 || args.length > 3) {
|
24
|
+
console.error('Usage:\n phantomjs runner.js [url-of-your-qunit-testsuite] [timeout-in-seconds]');
|
25
|
+
phantom.exit(1);
|
26
|
+
}
|
27
|
+
|
28
|
+
url = args[1];
|
29
|
+
page = require('webpage').create();
|
30
|
+
if (args[2] !== undefined) {
|
31
|
+
timeout = parseInt(args[2], 10);
|
32
|
+
}
|
33
|
+
|
34
|
+
// Route `console.log()` calls from within the Page context to the main Phantom context (i.e. current `this`)
|
35
|
+
page.onConsoleMessage = function(msg) {
|
36
|
+
console.log(msg);
|
37
|
+
};
|
38
|
+
|
39
|
+
page.onInitialized = function() {
|
40
|
+
page.evaluate(addLogging);
|
41
|
+
};
|
42
|
+
|
43
|
+
page.onCallback = function(message) {
|
44
|
+
var result,
|
45
|
+
failed;
|
46
|
+
|
47
|
+
if (message) {
|
48
|
+
if (message.name === 'QUnit.done') {
|
49
|
+
result = message.data;
|
50
|
+
failed = !result || result.failed;
|
51
|
+
|
52
|
+
phantom.exit(failed ? 1 : 0);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
};
|
56
|
+
|
57
|
+
page.open(url, function(status) {
|
58
|
+
if (status !== 'success') {
|
59
|
+
console.error('Unable to access network: ' + status);
|
60
|
+
phantom.exit(1);
|
61
|
+
} else {
|
62
|
+
// Cannot do this verification with the 'DOMContentLoaded' handler because it
|
63
|
+
// will be too late to attach it if a page does not have any script tags.
|
64
|
+
var qunitMissing = page.evaluate(function() { return (typeof QUnit === 'undefined' || !QUnit); });
|
65
|
+
if (qunitMissing) {
|
66
|
+
console.error('The `QUnit` object is not present on this page.');
|
67
|
+
phantom.exit(1);
|
68
|
+
}
|
69
|
+
|
70
|
+
// Set a timeout on the test running, otherwise tests with async problems will hang forever
|
71
|
+
if (typeof timeout === 'number') {
|
72
|
+
setTimeout(function() {
|
73
|
+
console.error('The specified timeout of ' + timeout + ' seconds has expired. Aborting...');
|
74
|
+
phantom.exit(1);
|
75
|
+
}, timeout * 1000);
|
76
|
+
}
|
77
|
+
|
78
|
+
// Do nothing... the callback mechanism will handle everything!
|
79
|
+
}
|
80
|
+
});
|
81
|
+
|
82
|
+
function addLogging() {
|
83
|
+
window.document.addEventListener('DOMContentLoaded', function() {
|
84
|
+
var currentTestAssertions = [];
|
85
|
+
|
86
|
+
QUnit.log(function(details) {
|
87
|
+
var response;
|
88
|
+
|
89
|
+
// Ignore passing assertions
|
90
|
+
if (details.result) {
|
91
|
+
return;
|
92
|
+
}
|
93
|
+
|
94
|
+
response = details.message || '';
|
95
|
+
|
96
|
+
if (typeof details.expected !== 'undefined') {
|
97
|
+
if (response) {
|
98
|
+
response += ', ';
|
99
|
+
}
|
100
|
+
|
101
|
+
response += 'expected: ' + details.expected + ', but was: ' + details.actual;
|
102
|
+
}
|
103
|
+
|
104
|
+
if (details.source) {
|
105
|
+
response += "\n" + details.source;
|
106
|
+
}
|
107
|
+
|
108
|
+
currentTestAssertions.push('Failed assertion: ' + response);
|
109
|
+
});
|
110
|
+
|
111
|
+
QUnit.testDone(function(result) {
|
112
|
+
var i,
|
113
|
+
len,
|
114
|
+
name = result.module + ': ' + result.name;
|
115
|
+
|
116
|
+
if (result.failed) {
|
117
|
+
console.log('Test failed: ' + name);
|
118
|
+
|
119
|
+
for (i = 0, len = currentTestAssertions.length; i < len; i++) {
|
120
|
+
console.log(' ' + currentTestAssertions[i]);
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
currentTestAssertions.length = 0;
|
125
|
+
});
|
126
|
+
|
127
|
+
QUnit.done(function(result) {
|
128
|
+
console.log('Took ' + result.runtime + 'ms to run ' + result.total + ' tests. ' + result.passed + ' passed, ' + result.failed + ' failed.');
|
129
|
+
|
130
|
+
if (typeof window.callPhantom === 'function') {
|
131
|
+
window.callPhantom({
|
132
|
+
'name': 'QUnit.done',
|
133
|
+
'data': result
|
134
|
+
});
|
135
|
+
}
|
136
|
+
});
|
137
|
+
}, false);
|
138
|
+
}
|
139
|
+
})();
|
@@ -0,0 +1,54 @@
|
|
1
|
+
// Helpers
|
2
|
+
var disableWorkers = function() {
|
3
|
+
Architect.SUPPORT_WORKER = false
|
4
|
+
}
|
5
|
+
|
6
|
+
var makeSureWorkersAreDisabled = function() {
|
7
|
+
ok(Architect.SUPPORT_WORKER === false, 'Workers are disabled')
|
8
|
+
}
|
9
|
+
|
10
|
+
// Default Workers
|
11
|
+
asyncTest('Proxy Polyfill', function() {
|
12
|
+
disableWorkers()
|
13
|
+
makeSureWorkersAreDisabled()
|
14
|
+
|
15
|
+
Architect.proxy('Foo', function(data) {
|
16
|
+
ok(data === 'Foo')
|
17
|
+
start()
|
18
|
+
})
|
19
|
+
})
|
20
|
+
|
21
|
+
asyncTest('Ajax Polyfill', function() {
|
22
|
+
disableWorkers()
|
23
|
+
makeSureWorkersAreDisabled()
|
24
|
+
|
25
|
+
Architect.ajax('https://api.github.com/users/etiennelem', function(data) {
|
26
|
+
ok(JSON.parse(data).login === 'EtienneLem')
|
27
|
+
start()
|
28
|
+
})
|
29
|
+
})
|
30
|
+
|
31
|
+
asyncTest('JSONP Polyfill', function() {
|
32
|
+
disableWorkers()
|
33
|
+
makeSureWorkersAreDisabled()
|
34
|
+
|
35
|
+
Architect.jsonp('https://api.github.com/users/etiennelem', function(data) {
|
36
|
+
ok(data.data.login === 'EtienneLem')
|
37
|
+
start()
|
38
|
+
})
|
39
|
+
})
|
40
|
+
|
41
|
+
// Custom Workers
|
42
|
+
asyncTest('Custom Fallback', function() {
|
43
|
+
disableWorkers()
|
44
|
+
makeSureWorkersAreDisabled()
|
45
|
+
|
46
|
+
var foozleWorkerFallback = function(data) {
|
47
|
+
return (data + 'zle_doo').toUpperCase()
|
48
|
+
}
|
49
|
+
|
50
|
+
Architect.workFrom('./fixture/foozle_worker.js', 'foo', foozleWorkerFallback, function(data) {
|
51
|
+
ok(data === 'FOOZLE_DOO')
|
52
|
+
start()
|
53
|
+
})
|
54
|
+
})
|
@@ -0,0 +1,49 @@
|
|
1
|
+
// Config
|
2
|
+
test('Worker Support', function() {
|
3
|
+
ok(Architect.SUPPORT_WORKER === true)
|
4
|
+
})
|
5
|
+
|
6
|
+
test('Custom Workers Path', function() {
|
7
|
+
initialWorkerPath = Architect.workersPath
|
8
|
+
|
9
|
+
Architect.setupWorkersPath('fake/path')
|
10
|
+
ok(Architect.workersPath === 'fake/path', 'Custom path')
|
11
|
+
|
12
|
+
Architect.setupWorkersPath('./fake/path')
|
13
|
+
ok(Architect.workersPath === './fake/path', 'Relative path')
|
14
|
+
|
15
|
+
Architect.setupWorkersPath('fake/path/')
|
16
|
+
ok(Architect.workersPath === 'fake/path', 'Removes trailing slash')
|
17
|
+
|
18
|
+
Architect.setupWorkersPath(initialWorkerPath)
|
19
|
+
})
|
20
|
+
|
21
|
+
// Default Workers
|
22
|
+
asyncTest('Proxy Worker', function() {
|
23
|
+
Architect.proxy('Foo', function(data) {
|
24
|
+
ok(data === 'Foo')
|
25
|
+
start()
|
26
|
+
})
|
27
|
+
})
|
28
|
+
|
29
|
+
asyncTest('Ajax Worker', function() {
|
30
|
+
Architect.ajax('https://api.github.com/users/etiennelem', function(data) {
|
31
|
+
ok(JSON.parse(data).login === 'EtienneLem')
|
32
|
+
start()
|
33
|
+
})
|
34
|
+
})
|
35
|
+
|
36
|
+
asyncTest('JSONP Worker', function() {
|
37
|
+
Architect.jsonp('https://api.github.com/users/etiennelem', function(data) {
|
38
|
+
ok(data.data.login === 'EtienneLem')
|
39
|
+
start()
|
40
|
+
})
|
41
|
+
})
|
42
|
+
|
43
|
+
// Custom Workers
|
44
|
+
asyncTest('Custom Worker', function() {
|
45
|
+
Architect.workFrom('./fixture/foozle_worker.js', 'foo', function(data) {
|
46
|
+
ok(data === 'FOOZLE')
|
47
|
+
start()
|
48
|
+
})
|
49
|
+
})
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: architect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Etienne Lemay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coffee-rails
|
@@ -74,29 +74,37 @@ executables: []
|
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
+
- .gitignore
|
78
|
+
- CHANGELOG.md
|
79
|
+
- Gemfile
|
80
|
+
- MIT-LICENSE
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- app/assets/javascripts/architect.coffee.erb
|
77
84
|
- app/assets/javascripts/architect/version.coffee.erb
|
78
85
|
- app/assets/javascripts/architect/worker.coffee
|
79
86
|
- app/assets/javascripts/architect/workers/ajax_worker.coffee
|
80
87
|
- app/assets/javascripts/architect/workers/jsonp_worker.coffee
|
81
88
|
- app/assets/javascripts/architect/workers/proxy_worker.coffee
|
82
|
-
- app/assets/javascripts/architect.coffee.erb
|
83
89
|
- app/assets/javascripts/workers/ajax_worker.coffee
|
84
90
|
- app/assets/javascripts/workers/jsonp_worker.coffee
|
85
91
|
- app/assets/javascripts/workers/proxy_worker.coffee
|
92
|
+
- architect.gemspec
|
93
|
+
- lib/architect.rb
|
86
94
|
- lib/architect/engine.rb
|
87
95
|
- lib/architect/helpers.rb
|
88
96
|
- lib/architect/version.rb
|
89
|
-
- lib/architect.rb
|
90
97
|
- lib/tasks/task_helpers.rb
|
91
98
|
- static/architect.min.js
|
92
99
|
- static/workers/ajax_worker.min.js
|
93
100
|
- static/workers/jsonp_worker.min.js
|
94
101
|
- static/workers/proxy_worker.min.js
|
95
|
-
-
|
96
|
-
-
|
97
|
-
-
|
98
|
-
-
|
99
|
-
|
102
|
+
- test/fixture/foozle_worker.js
|
103
|
+
- test/index.html
|
104
|
+
- test/runner.js
|
105
|
+
- test/unit/architect/polyfill_test.js
|
106
|
+
- test/unit/architect_test.js
|
107
|
+
homepage: http://architectjs.org
|
100
108
|
licenses:
|
101
109
|
- MIT
|
102
110
|
metadata: {}
|
@@ -120,4 +128,9 @@ rubygems_version: 2.0.0
|
|
120
128
|
signing_key:
|
121
129
|
specification_version: 4
|
122
130
|
summary: Your web workers’ supervisor
|
123
|
-
test_files:
|
131
|
+
test_files:
|
132
|
+
- test/fixture/foozle_worker.js
|
133
|
+
- test/index.html
|
134
|
+
- test/runner.js
|
135
|
+
- test/unit/architect/polyfill_test.js
|
136
|
+
- test/unit/architect_test.js
|