architect 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5d72efb3fd9592e10ff2e9a2653338a327a3752
4
- data.tar.gz: 25185539fe7650a62973f6938877c3b73ce99511
3
+ metadata.gz: 9bec81cd66ce034cb54efbab4035fd141a0ee8d5
4
+ data.tar.gz: a002476eafc68ddb9ebf222bbd318ef25e54cafb
5
5
  SHA512:
6
- metadata.gz: a4862a67359d4f0020c3d129565422fb188d0a00e3bf72ae6cd220925a16b780cff8764256cdbedcb7b15d37e5bb854ea624af97426875a229ddee7726b21314
7
- data.tar.gz: 609ffe41e38be243fc29e62e22fdcccc0c7568a39656d7aff6eb471ce8baa1ef86755684e75ae750935e672984fabce520ac512634f9a5352debbe10a652c242
6
+ metadata.gz: 096b8f8d8d97127b6e25e9a50fcee3b6fdd370b10f4d82ba502bba5d68e031c5dd2b388bf1b2fcccea2d4666ab09c58865488554c4f7b4ff8dfd13d04c97446a
7
+ data.tar.gz: fe231e602cb01f153b0ff66d20b8eba440cecd4682bc48750606607390cf9dec7a80281e72fbb3f3a51dfa782dd67a52c1e5f20f443b3382c0547b3861d83bb2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [v0.0.7](https://github.com/EtienneLem/architect/tree/v0.0.7)
2
+ - Serve your workers from any path
3
+ - Make `workFrom` fallback optional
4
+
1
5
  ## [v0.0.6](https://github.com/EtienneLem/architect/tree/v0.0.6)
2
6
  - Custom workers support
3
7
 
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
- ## Todo
160
- - Tests
161
- - Support Shared Workers [[See #3](https://github.com/EtienneLem/architect/issues/3)]
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
@@ -17,6 +17,11 @@ task :compile do
17
17
  compile('workers/jsonp_worker.js')
18
18
  end
19
19
 
20
+ desc 'Run tests'
21
+ task :test do
22
+ puts `phantomjs test/runner.js test/index.html`
23
+ end
24
+
20
25
  task :default => :compile
21
26
 
22
27
  def compile(file)
@@ -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(@Architect.WORKERS[type].workerPath)
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)
@@ -1,3 +1,3 @@
1
1
  module Architect
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
@@ -1 +1 @@
1
- !function(){this.Architect={},this.Architect.VERSION="0.0.6"}.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=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"}},r=function(t){return this.Architect.SUPPORT_WORKER?new Worker(this.Architect.WORKERS[t].workerPath):new this.Architect.WORKERS[t].polyfill},this.Architect.work=function(t,e,n){var o;return o=r(e),o.postMessage(t),o.addEventListener("message",function(t){return o.terminate(),n(t.data)})},this.Architect.proxy=function(t,r){return e.Architect.work(t,"proxy",r)},this.Architect.ajax=function(t,r){return e.Architect.work(t,"ajax",r)},this.Architect.jsonp=function(t,r){return e.Architect.work(t,"jsonp",r)},t={},this.Architect.workOn=function(e,n,o,c){var i,s,a=this;return this.workOnCallback=c,i=!!t[e],s=t[e]||(t[e]=r(o)),s.postMessage(n),i?void 0:s.addEventListener("message",function(t){return a.workOnCallback(t.data)})},this.Architect.endJob=function(r){var e;if(e=t[r])return e.terminate(),delete t[r]},this.Architect.proxyOn=function(t,r,n){return e.Architect.workOn(t,r,"proxy",n)},this.Architect.ajaxOn=function(t,r,n){return e.Architect.workOn(t,r,"ajax",n)},this.Architect.jsonpOn=function(t,r,n){return e.Architect.workOn(t,r,"jsonp",n)},this.Architect.workFrom=function(t,r,n,o){var c;return null==n&&(n=null),e.Architect.SUPPORT_WORKER?(c=new Worker(t),c.postMessage(r),c.addEventListener("message",function(t){return c.terminate(),o(t.data)})):n?o(n(r)):console.warn("No fallback provided for "+t)}}.call(this);
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.6
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-02 00:00:00.000000000 Z
11
+ date: 2013-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coffee-rails