architect 0.0.6 → 0.0.7
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +12 -3
- data/Rakefile +5 -0
- data/app/assets/javascripts/architect.coffee.erb +13 -1
- data/lib/architect/version.rb +1 -1
- data/static/architect.min.js +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bec81cd66ce034cb54efbab4035fd141a0ee8d5
|
4
|
+
data.tar.gz: a002476eafc68ddb9ebf222bbd318ef25e54cafb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 096b8f8d8d97127b6e25e9a50fcee3b6fdd370b10f4d82ba502bba5d68e031c5dd2b388bf1b2fcccea2d4666ab09c58865488554c4f7b4ff8dfd13d04c97446a
|
7
|
+
data.tar.gz: fe231e602cb01f153b0ff66d20b8eba440cecd4682bc48750606607390cf9dec7a80281e72fbb3f3a51dfa782dd67a52c1e5f20f443b3382c0547b3861d83bb2
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -156,6 +156,15 @@ Architect.workFrom('workers/foozle.js', 'foo', foozleFallback, function(data) {
|
|
156
156
|
### Other
|
157
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.
|
158
158
|
|
159
|
-
|
160
|
-
|
161
|
-
|
159
|
+
#### Custom path
|
160
|
+
You can also specify any path you want to serve the workers from.
|
161
|
+
|
162
|
+
```js
|
163
|
+
Architect.setupWorkersPath('fake/path')
|
164
|
+
Architect.proxy('Foo', function(data) {
|
165
|
+
// => Uses http://yourdomain.com/fake/path/proxy_worker.min.js
|
166
|
+
})
|
167
|
+
```
|
168
|
+
|
169
|
+
## Tests
|
170
|
+
Run the `rake test` task.
|
data/Rakefile
CHANGED
@@ -9,9 +9,17 @@
|
|
9
9
|
jsonp: { polyfill: @Architect.JSONPWorker, workerPath: '<%= Architect.worker_path("jsonp") %>' }
|
10
10
|
|
11
11
|
# Private methods
|
12
|
+
getWorkersPath = (type) ->
|
13
|
+
return @Architect.WORKERS[type].workerPath unless @Architect.workersPath
|
14
|
+
"#{@Architect.workersPath}/#{type}_worker.min.js"
|
15
|
+
|
12
16
|
spawnWorker = (type) ->
|
13
17
|
return new @Architect.WORKERS[type].polyfill unless @Architect.SUPPORT_WORKER
|
14
|
-
new Worker(
|
18
|
+
new Worker(getWorkersPath(type))
|
19
|
+
|
20
|
+
# Config
|
21
|
+
@Architect.setupWorkersPath = (path) =>
|
22
|
+
@Architect.workersPath = path.replace(/\/$/, '')
|
15
23
|
|
16
24
|
# Short-lived workers
|
17
25
|
@Architect.work = (data, type, callback) ->
|
@@ -49,6 +57,10 @@ jobs = {}
|
|
49
57
|
|
50
58
|
# Custom workers
|
51
59
|
@Architect.workFrom = (workerPath, data, fallback=null, callback) =>
|
60
|
+
if callback is undefined
|
61
|
+
callback = fallback
|
62
|
+
fallback = null
|
63
|
+
|
52
64
|
if @Architect.SUPPORT_WORKER
|
53
65
|
worker = new Worker(workerPath)
|
54
66
|
worker.postMessage(data)
|
data/lib/architect/version.rb
CHANGED
data/static/architect.min.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
!function(){this.Architect={},this.Architect.VERSION="0.0.
|
1
|
+
!function(){this.Architect={},this.Architect.VERSION="0.0.7"}.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.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);
|
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.0.7
|
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-08-
|
11
|
+
date: 2013-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coffee-rails
|