Commits

Kenneth Jørgensen committed b9339e2 Merge

Merge

Comments (0)

Files changed (18)

 calamity\.js
 calamity-min\.js
 _SpecRunner\.html
+npm-debug\.log
 
 5ca1f7c7ab28e536696d01817876d10e5f7bab28 0.1.1
 34915aff1ee6f0da00999c1268f9994de58228d6 0.2.0
 4c91e6b4f82badc5e801f0624973ac97036dd6fc 0.3.0
+e1bd79dba6c7c269bcb6b183e223ec28e345bc40 0.3.1
 # Changelog
 
+## 0.3.1 (2013-03-19)
+* *Fix:* Added AMD load header. [pull/1](https://bitbucket.org/kennethjor/calamity/pull-request/1)
+
 ## 0.3.0 (2013-01-29)
 * *API change:* Removed initial underscore from `_trigger()`, `_subscribe()`, and `_publish()` on `ProxyMixin` and `EmitterMixin`. It makes assumptions about code style.
 * *Fix:* Browser initialisation.
+var exec = require("child_process").exec;
+
+module.exports = function(grunt) {
+	// Project configuration.
+	grunt.initConfig({
+		pkg: grunt.file.readJSON("package.json"),
+
+		coffee: {
+			// Core compile
+			core: {
+				files: {
+					"build/calamity.js": ["src/core/*.coffee"]
+				},
+				options: {
+					bare: true
+				}
+			},
+			// Compile the test files.
+			test: {
+				expand: true,
+				cwd: "test",
+				src: ["**/*.coffee"],
+				dest: "build/test",
+				ext: ".js"
+			},
+			// Compile the Jasmine specs.
+			spec: {
+				expand: true,
+				cwd: "spec",
+				src: ["**/*.coffee"],
+				dest: "build/spec",
+				ext: ".js"
+			}
+		},
+
+		concat: {
+			// Assembles the core distribution files.
+			core: {
+				options: {
+					banner:
+						"/*! <%= pkg.fullname %> <%= pkg.version %> - MIT license */\n" +
+						"(function(){\n",
+					footer: "}).call(this);",
+					process: true
+				},
+				src: [
+					"src/init/init.js",
+					"<%= _.keys(coffee.core.files)[0] %>"
+				],
+				dest: "<%= pkg.name %>.js"
+			}
+		},
+
+		uglify: {
+			core: {
+				options: {
+					preserveComments: "some"
+				},
+				files: {
+					"calamity-min.js": "calamity.js"
+				}
+			}
+		},
+
+		nodeunit: {
+			all: ["build/test/**/*.js"]
+		},
+
+		watch: {
+			files: [
+				"src/**",
+				"test/**",
+				"spec/**"
+			],
+			tasks: "default"
+		}
+	});
+
+	// Jessie Jasmine runner.
+	grunt.registerTask("jessie", "Runs Jasmine with Jessie.", function() {
+		done = this.async();
+		command = "./node_modules/jessie/bin/jessie build/spec"
+		exec(command, function(err, stdout, stderr) {
+			console.log(stdout);
+			if (err) {
+				grunt.warn(err);
+				done(false);
+			}
+			else {
+				done(true);
+			}
+		});
+	});
+
+	// Load grunt plugins.
+	grunt.loadNpmTasks("grunt-contrib-coffee");
+	grunt.loadNpmTasks("grunt-contrib-concat");
+	grunt.loadNpmTasks("grunt-contrib-uglify");
+	grunt.loadNpmTasks("grunt-contrib-nodeunit");
+
+	// Default task.
+	grunt.registerTask("default", ["coffee", "concat", "uglify", "nodeunit", "jessie"]);
+};
-# CalamityJS
+# Calamity
 Calamity is an event bus library for use in event-driven architectures.
-With Calamity you can easily attach global and local event functionality to your classes and prototypes.
-It is [hosted on BitBucket][bitbucket].
+Using Calamity you can easily drive your application through a global event bus, or simply add event functionality to objects.
 
 # Installation
 Install via `npm`:
 
     npm install calamity
 
-Or [download directly][download] from bitbucket.
-
 # Usage
 
 The two primary methods in Calamity are `Calamity.proxy()` and `Calamity.emitter()`.
 ## Global event bus with `proxy()`
 This example CoffeeScript code will create an object which is aware of a global event bus.
 
+    :::coffeescript
     Calamity = require "calamity"
     class Foo
     	Calamity.proxy @prototype
 
     	constructor: () ->
-    		@subscribe "address", @.handler
+    		@subscribe "address", @handler
 
     	handler: (msg) ->
-    		# Proxy automatically handles this.
+    		# Proxy automatically handles binding to this.
     		@data = msg.data
 
-Now, whenever any object publishes a message to the `foo:bar` address, handler will be called and you can react to it.
+Now, whenever any object publishes a message to the `foo:bar` address, handler will be called and you can react on it.
 
 ## Local event bus with `emitter()`
 
-    Calamity.emitter @prototype
+    :::coffeescript
+    Calamity = require "calamity"
+    class Foo
+    	Calamity.emitter @prototype
 
-# Compiling
-To compile Calamity yourself, first check out the repo
+    	constructor: () ->
+    		@on "address", @handler
 
-    hg clone ssh://hg@bitbucket.org/kennethjor/calamityjs
+    	handler: (msg) ->
+    		# Proxy automatically handles binding to this.
+    		@data = msg.data
 
-Install required tools and libraries:
-
-* [PhantomJS][phantomjs]
-* `sudo npm install -g grunt coffee-script`
-* `npm install`
-
-Run a full compile
-
-    grunt
-
-When developing, executing watch immediately after the compile is very handy
-
-    grunt default watch
-
-## Documentation
-To build the documentation you need to install Pygments and docco
-
-    sudo easy_install Pygments
-    sudo npm install -g docco
-
-Then you can generate the docs
-
-    ./docs.sh
+This code is very similar to the global events, except this will create an event bus local to a particular instance.
+This allows you to create localised events using `on(address, handler)` and `trigger(address, data)`.
 
 # License
-CalamityJS is licensed and freely distributed under the [MIT License][mit]
+Calamity is licensed and freely distributed under the [MIT License][mit]
 
-[bitbucket]: https://bitbucket.org/kennethjor/calamityjs
-[download]: https://bitbucket.org/kennethjor/calamityjs/downloads "Download from bitbucket.org"
 [mit]: https://bitbucket.org/kennethjor/calamityjs/raw/default/LICENSE "MIT License"
-[phantomjs]: http://phantomjs.org/ "PhantomJS"

docs.sh

-#!/usr/bin/env bash
-set -e
-docco build/core/calamity.coffee

docs/calamity.html

-<!DOCTYPE html>  <html> <head>   <title>calamity.coffee</title>   <meta http-equiv="content-type" content="text/html; charset=UTF-8">   <link rel="stylesheet" media="all" href="docco.css" /> </head> <body>   <div id="container">     <div id="background"></div>          <table cellpadding="0" cellspacing="0">       <thead>         <tr>           <th class="docs">             <h1>               calamity.coffee             </h1>           </th>           <th class="code">           </th>         </tr>       </thead>       <tbody>                               <tr id="section-1">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-1">&#182;</a>               </div>               <h1>EmitterMixin</h1>
-
-<p>Mixin class for attaching an instance-local EventBus to objects.
-It adds the <code>on()</code>, <code>off()</code>, and <code>_trigger()</code> methods to the object.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">EmitterMixin = </span><span class="k">class</span> <span class="nx">C</span><span class="p">.</span><span class="nx">EmitterMixin</span></pre></div>             </td>           </tr>                               <tr id="section-2">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-2">&#182;</a>               </div>               <h2><code>on()</code></h2>
-
-<p>Register a handler to an address.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kc">on</span><span class="o">:</span> <span class="nf">(address, handler, context) -&gt;</span>
-    <span class="nx">context</span> <span class="o">or=</span> <span class="nx">@</span>
-    <span class="k">return</span> <span class="nx">getEmitterBus</span><span class="p">(</span><span class="nx">@</span><span class="p">).</span><span class="nx">subscribe</span><span class="p">(</span><span class="nx">address</span><span class="p">,</span> <span class="nx">handler</span><span class="p">,</span> <span class="nx">context</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-3">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-3">&#182;</a>               </div>               <h2><code>off()</code></h2>
-
-<p>Unregisters a handler from an address.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="kc">off</span><span class="o">:</span> <span class="nf">(address, handler, context) -&gt;</span>
-    <span class="k">return</span> <span class="nx">unless</span> <span class="nx">hasEmitterBus</span><span class="p">(</span><span class="nx">@</span><span class="p">)</span>
-    <span class="nx">context</span> <span class="o">or=</span> <span class="nx">@</span>
-    <span class="k">return</span> <span class="nx">getEmitterBus</span><span class="p">(</span><span class="nx">@</span><span class="p">).</span><span class="nx">unsubscribe</span><span class="p">(</span><span class="nx">address</span><span class="p">,</span> <span class="nx">handler</span><span class="p">,</span> <span class="nx">context</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-4">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-4">&#182;</a>               </div>               <h2><code>_trigger()</code></h2>
-
-<p>Publishes an event to an address.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">trigger: </span><span class="nf">(address, data, reply) -&gt;</span>
-    <span class="k">return</span> <span class="nx">unless</span> <span class="nx">hasEmitterBus</span><span class="p">(</span><span class="nx">@</span><span class="p">)</span>
-    <span class="k">return</span> <span class="nx">getEmitterBus</span><span class="p">(</span><span class="nx">@</span><span class="p">).</span><span class="nx">publish</span><span class="p">(</span><span class="nx">address</span><span class="p">,</span> <span class="nx">data</span><span class="p">,</span> <span class="nx">reply</span><span class="p">)</span></pre></div>             </td>           </tr>                               <tr id="section-5">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-5">&#182;</a>               </div>               <p>Private statis function for checking is the object has an emitter bus.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">hasEmitterBus = </span><span class="nf">(obj) -&gt;</span>
-  <span class="k">return</span> <span class="kc">false</span> <span class="nx">unless</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">_calamity</span>
-  <span class="k">return</span> <span class="kc">false</span> <span class="nx">unless</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">_calamity</span><span class="p">.</span><span class="nx">emitter</span>
-  <span class="k">return</span> <span class="kc">false</span> <span class="nx">unless</span> <span class="nx">obj</span><span class="p">.</span><span class="nx">_calamity</span><span class="p">.</span><span class="nx">emitter</span><span class="p">.</span><span class="nx">bus</span>
-  <span class="k">return</span> <span class="kc">true</span></pre></div>             </td>           </tr>                               <tr id="section-6">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-6">&#182;</a>               </div>               <p>Private static function for preparing an on-demand event bus for an object.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">getEmitterBus = </span><span class="nf">(obj) -&gt;</span>
-  <span class="nv">calamity = </span><span class="p">(</span><span class="nx">obj</span><span class="p">.</span><span class="nx">_calamity</span> <span class="o">or=</span> <span class="p">{})</span>
-  <span class="nv">emitter = </span><span class="p">(</span><span class="nx">calamity</span><span class="p">.</span><span class="nx">emitter</span> <span class="o">or=</span> <span class="p">{})</span>
-  <span class="k">return</span> <span class="nx">emitter</span><span class="p">.</span><span class="nx">bus</span> <span class="o">or=</span> <span class="k">new</span> <span class="nx">EventBus</span><span class="p">()</span></pre></div>             </td>           </tr>                               <tr id="section-7">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-7">&#182;</a>               </div>               <h2><code>Calamity.emitter()</code></h2>
-
-<p>Adds emitter functionality.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">C.emitter = </span><span class="nf">(obj) -&gt;</span>
-  <span class="nx">_</span><span class="p">.</span><span class="nx">extend</span> <span class="nx">obj</span><span class="p">,</span> <span class="nx">EmitterMixin</span><span class="p">.</span><span class="nx">prototype</span></pre></div>             </td>           </tr>                               <tr id="section-8">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-8">&#182;</a>               </div>               <h1>EventBridge</h1>
-
-<p>Bridge for transfering events between two <code>EventBus</code> instances.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">EventBridge = </span><span class="k">class</span> <span class="nx">C</span><span class="p">.</span><span class="nx">EventBridge</span></pre></div>             </td>           </tr>                               <tr id="section-9">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-9">&#182;</a>               </div>               <p>Constructor.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">constructor: </span><span class="nf">() -&gt;</span>
-    <span class="vi">@_busses = </span><span class="p">[]</span>
-    <span class="k">return</span></pre></div>             </td>           </tr>                               <tr id="section-10">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-10">&#182;</a>               </div>               <h2><code>connect()</code></h2>
-
-<p>Connects this bridge to an event bus.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">connect: </span><span class="nf">(bus) -&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-11">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-11">&#182;</a>               </div>               <p>Add to internal list.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@_busses</span><span class="p">.</span><span class="nx">push</span> <span class="nx">bus</span></pre></div>             </td>           </tr>                               <tr id="section-12">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-12">&#182;</a>               </div>               <p>Register handler on bus.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">bus</span><span class="p">.</span><span class="nx">subscribe</span> <span class="s">&quot;*&quot;</span><span class="p">,</span> <span class="nx">_</span><span class="p">.</span><span class="nx">bind</span><span class="p">(</span><span class="nx">@handler</span><span class="p">,</span> <span class="nx">@</span><span class="p">)</span>
-
-    <span class="k">return</span> <span class="nx">@</span></pre></div>             </td>           </tr>                               <tr id="section-13">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-13">&#182;</a>               </div>               <h2><code>handler()</code></h2>
-
-<p>Default noop handler.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">handler: </span><span class="nf">(msg) -&gt;</span>
-    <span class="k">return</span></pre></div>             </td>           </tr>                               <tr id="section-14">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-14">&#182;</a>               </div>               <h1>EventBus</h1>
-
-<p>Manages passing events from publishers to subscribers.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">EventBus = </span><span class="k">class</span> <span class="nx">C</span><span class="p">.</span><span class="nx">EventBus</span>
-  <span class="nv">constructor: </span><span class="o">-&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-15">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-15">&#182;</a>               </div>               <p>Generate ID.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="vi">@id = </span><span class="nx">util</span><span class="p">.</span><span class="nx">genId</span><span class="p">()</span></pre></div>             </td>           </tr>                               <tr id="section-16">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-16">&#182;</a>               </div>               <p>Registered subscriptions container.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="vi">@_subscriptions = </span><span class="p">{}</span></pre></div>             </td>           </tr>                               <tr id="section-17">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-17">&#182;</a>               </div>               <h2><code>subscribe()</code></h2>
-
-<p>Register a handler to an address.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">subscribe: </span><span class="nf">(address, handler, context) -&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-18">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-18">&#182;</a>               </div>               <p>Initialize subscriptions container for this address.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">unless</span> <span class="nx">@_subscriptions</span><span class="p">[</span><span class="nx">address</span><span class="p">]</span>
-      <span class="nx">@_subscriptions</span><span class="p">[</span><span class="nx">address</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span></pre></div>             </td>           </tr>                               <tr id="section-19">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-19">&#182;</a>               </div>               <p>Create subscription.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nv">sub = </span><span class="k">new</span> <span class="nx">Subscription</span> <span class="nx">address</span><span class="p">,</span> <span class="nx">handler</span><span class="p">,</span> <span class="nx">context</span><span class="p">,</span> <span class="nx">@</span></pre></div>             </td>           </tr>                               <tr id="section-20">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-20">&#182;</a>               </div>               <p>Add to list.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@_subscriptions</span><span class="p">[</span><span class="nx">address</span><span class="p">].</span><span class="nx">push</span> <span class="nx">sub</span></pre></div>             </td>           </tr>                               <tr id="section-21">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-21">&#182;</a>               </div>               <p>Return subscription.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="k">return</span> <span class="nx">sub</span></pre></div>             </td>           </tr>                               <tr id="section-22">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-22">&#182;</a>               </div>               <h2><code>unsubscribe()</code></h2>
-
-<p>Unsubscribes a handler.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">unsubscribe: </span><span class="nf">(address, handler) -&gt;</span>
-    <span class="nv">sub = </span><span class="nx">address</span></pre></div>             </td>           </tr>                               <tr id="section-23">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-23">&#182;</a>               </div>               <p>Search by subscription.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="k">if</span> <span class="nx">sub</span> <span class="k">instanceof</span> <span class="nx">Subscription</span></pre></div>             </td>           </tr>                               <tr id="section-24">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-24">&#182;</a>               </div>               <p>Check address.</p>             </td>             <td class="code">               <div class="highlight"><pre>      <span class="nv">address = </span><span class="nx">sub</span><span class="p">.</span><span class="nx">address</span>
-      <span class="k">return</span> <span class="nx">unless</span> <span class="nx">@_subscriptions</span><span class="p">[</span><span class="nx">address</span><span class="p">]</span>
-      <span class="k">for</span> <span class="nx">s</span><span class="p">,</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">@_subscriptions</span><span class="p">[</span><span class="nx">address</span><span class="p">]</span>
-        <span class="k">if</span> <span class="nx">s</span> <span class="o">is</span> <span class="nx">sub</span>
-          <span class="nx">@_subscriptions</span><span class="p">[</span><span class="nx">address</span><span class="p">].</span><span class="nx">splice</span> <span class="nx">i</span></pre></div>             </td>           </tr>                               <tr id="section-25">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-25">&#182;</a>               </div>               <p>Otherwise search by address and handler.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="k">else</span></pre></div>             </td>           </tr>                               <tr id="section-26">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-26">&#182;</a>               </div>               <p>Check for address.</p>             </td>             <td class="code">               <div class="highlight"><pre>      <span class="k">return</span> <span class="nx">unless</span> <span class="nx">@_subscriptions</span><span class="p">[</span><span class="nx">address</span><span class="p">]</span>
-      <span class="k">for</span> <span class="nx">s</span><span class="p">,</span> <span class="nx">i</span> <span class="k">in</span> <span class="nx">@_subscriptions</span><span class="p">[</span><span class="nx">address</span><span class="p">]</span>
-        <span class="k">if</span> <span class="nx">s</span><span class="p">.</span><span class="nx">address</span> <span class="o">is</span> <span class="nx">address</span> <span class="o">and</span> <span class="nx">s</span><span class="p">.</span><span class="nx">handler</span> <span class="o">is</span> <span class="nx">handler</span>
-          <span class="nx">@_subscriptions</span><span class="p">[</span><span class="nx">address</span><span class="p">].</span><span class="nx">splice</span> <span class="nx">i</span>
-    <span class="k">return</span></pre></div>             </td>           </tr>                               <tr id="section-27">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-27">&#182;</a>               </div>               <h2><code>publish()</code></h2>
-
-<p>Publishes an event to an address.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">publish: </span><span class="nf">(address, data, reply) -&gt;</span>
-    <span class="nv">msg = </span><span class="nx">@_createMessage</span> <span class="nx">address</span><span class="p">,</span> <span class="nx">data</span><span class="p">,</span> <span class="nx">reply</span>
-    <span class="nv">address = </span><span class="nx">msg</span><span class="p">.</span><span class="nx">address</span></pre></div>             </td>           </tr>                               <tr id="section-28">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-28">&#182;</a>               </div>               <p>Check if message has already been processed by this bus.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="k">return</span> <span class="nx">@</span> <span class="k">if</span> <span class="nx">msg</span><span class="p">.</span><span class="nx">sawBus</span> <span class="nx">@</span></pre></div>             </td>           </tr>                               <tr id="section-29">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-29">&#182;</a>               </div>               <p>Register this bus on the event</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">msg</span><span class="p">.</span><span class="nx">addBus</span> <span class="nx">@</span></pre></div>             </td>           </tr>                               <tr id="section-30">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-30">&#182;</a>               </div>               <p>Publish to target address.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@_publishAddress</span> <span class="nx">address</span><span class="p">,</span> <span class="nx">msg</span></pre></div>             </td>           </tr>                               <tr id="section-31">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-31">&#182;</a>               </div>               <p>Publish to wildcard address.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">@_publishAddress</span> <span class="s">&quot;*&quot;</span><span class="p">,</span> <span class="nx">msg</span>
-
-    <span class="k">return</span> <span class="nx">@</span></pre></div>             </td>           </tr>                               <tr id="section-32">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-32">&#182;</a>               </div>               <p>Utility function for creating messages.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">_createMessage: </span><span class="nf">(address, data, reply) -&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-33">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-33">&#182;</a>               </div>               <p>Construct new EventMessage is necesarry.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nv">msg = </span><span class="nx">address</span>
-    <span class="nx">unless</span> <span class="nx">msg</span> <span class="k">instanceof</span> <span class="nx">EventMessage</span>
-      <span class="nv">msg = </span><span class="k">new</span> <span class="nx">EventMessage</span> <span class="nx">address</span><span class="p">,</span> <span class="nx">data</span><span class="p">,</span> <span class="nx">reply</span>
-    <span class="k">return</span> <span class="nx">msg</span></pre></div>             </td>           </tr>                               <tr id="section-34">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-34">&#182;</a>               </div>               <p>Publishes a message to an address.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">_publishAddress: </span><span class="nf">(address, msg) -&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-35">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-35">&#182;</a>               </div>               <p>Check if we have subscriptions at all for this address.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="k">return</span> <span class="nx">unless</span> <span class="nx">@_subscriptions</span><span class="p">[</span><span class="nx">address</span><span class="p">]</span></pre></div>             </td>           </tr>                               <tr id="section-36">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-36">&#182;</a>               </div>               <p>Send message to all subscriptions.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="k">for</span> <span class="nx">subscription</span> <span class="k">in</span> <span class="nx">@_subscriptions</span><span class="p">[</span><span class="nx">address</span><span class="p">]</span>
-      <span class="nx">subscription</span><span class="p">.</span><span class="nx">trigger</span> <span class="nx">msg</span>
-    <span class="k">return</span></pre></div>             </td>           </tr>                               <tr id="section-37">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-37">&#182;</a>               </div>               <h1>EventMessage</h1>
-
-<p>Represents a single message in the system.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">EventMessage = </span><span class="k">class</span> <span class="nx">C</span><span class="p">.</span><span class="nx">EventMessage</span></pre></div>             </td>           </tr>                               <tr id="section-38">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-38">&#182;</a>               </div>               <p>Constructor.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">constructor: </span><span class="nf">(@address, @data, @_replyHandler) -&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-39">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-39">&#182;</a>               </div>               <p>Generate ID.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="vi">@id = </span><span class="nx">util</span><span class="p">.</span><span class="nx">genId</span><span class="p">()</span></pre></div>             </td>           </tr>                               <tr id="section-40">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-40">&#182;</a>               </div>               <p>Remebered busses container.
-This will store the ID of every bus the event has seen, to prevent repeated execution.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="vi">@_busses = </span><span class="p">[]</span></pre></div>             </td>           </tr>                               <tr id="section-41">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-41">&#182;</a>               </div>               <p>Check reply handler.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">unless</span> <span class="nx">_</span><span class="p">.</span><span class="nx">isUndefined</span><span class="p">(</span><span class="nx">@_replyHandler</span><span class="p">)</span> <span class="o">or</span> <span class="nx">_</span><span class="p">.</span><span class="nx">isFunction</span><span class="p">(</span><span class="nx">@_replyHandler</span><span class="p">)</span>
-      <span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span> <span class="s">&quot;Reply must be a function&quot;</span></pre></div>             </td>           </tr>                               <tr id="section-42">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-42">&#182;</a>               </div>               <h2><code>reply()</code></h2>
-
-<p>Executes the reply handler, if this message has one.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">reply: </span><span class="nf">(data) -&gt;</span>
-    <span class="k">if</span> <span class="nx">_</span><span class="p">.</span><span class="nx">isFunction</span><span class="p">(</span><span class="nx">@_replyHandler</span><span class="p">)</span>
-      <span class="nv">replyHandler = </span><span class="nx">@_replyHandler</span>
-      <span class="nx">_</span><span class="p">.</span><span class="nx">defer</span> <span class="o">-&gt;</span>
-        <span class="nx">replyHandler</span><span class="p">(</span><span class="nx">data</span><span class="p">)</span>
-        <span class="k">return</span>
-    <span class="k">return</span> <span class="nx">@</span></pre></div>             </td>           </tr>                               <tr id="section-43">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-43">&#182;</a>               </div>               <h2><code>addBus()</code></h2>
-
-<p>Adds a bus to the internal list.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">addBus: </span><span class="nf">(bus) -&gt;</span>
-    <span class="k">return</span> <span class="nx">@</span> <span class="k">if</span> <span class="nx">@sawBus</span><span class="p">(</span><span class="nx">bus</span><span class="p">)</span>
-    <span class="nx">@_busses</span><span class="p">.</span><span class="nx">push</span> <span class="nx">bus</span><span class="p">.</span><span class="nx">id</span>
-    <span class="k">return</span> <span class="nx">@</span></pre></div>             </td>           </tr>                               <tr id="section-44">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-44">&#182;</a>               </div>               <h2><code>sawBus()</code></h2>
-
-<p>Returns true if this message has been processed by the supplied bus.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">sawBus: </span><span class="nf">(bus) -&gt;</span>
-    <span class="k">return</span> <span class="nx">_</span><span class="p">.</span><span class="nx">contains</span> <span class="nx">@_busses</span><span class="p">,</span> <span class="nx">bus</span><span class="p">.</span><span class="nx">id</span></pre></div>             </td>           </tr>                               <tr id="section-45">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-45">&#182;</a>               </div>               <h2><code>serialize()</code></h2>
-
-<p>Serializes the message as JSON.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">serialize: </span><span class="o">-&gt;</span>
-    <span class="k">return</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">stringify</span> <span class="nx">@</span></pre></div>             </td>           </tr>                               <tr id="section-46">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-46">&#182;</a>               </div>               <h2><code>deserialize()</code></h2>
-
-<p>Desrialises a message from JSON.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">EventMessage.deserialize = </span><span class="nf">(json) -&gt;</span>
-  <span class="k">return</span> <span class="kc">undefined</span></pre></div>             </td>           </tr>                               <tr id="section-47">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-47">&#182;</a>               </div>               <h1>MemoryEventBridge</h1>
-
-<p><code>EventBridge</code> implementation which ties to <code>EventBus</code> instances together directly in memory.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">MemoryEventBridge = </span><span class="k">class</span> <span class="nx">C</span><span class="p">.</span><span class="nx">MemoryEventBridge</span> <span class="k">extends</span> <span class="nx">EventBridge</span></pre></div>             </td>           </tr>                               <tr id="section-48">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-48">&#182;</a>               </div>               <h2><code>handler()</code></h2>
-
-<p>Repeating handler implementation.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">handler: </span><span class="nf">(msg) -&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-49">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-49">&#182;</a>               </div>               <pre><code>console.log msg.serialize() + "\n\n"
-</code></pre>
-
-<p>Pass msg onto all connected busses</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="k">for</span> <span class="nx">bus</span> <span class="k">in</span> <span class="nx">@_busses</span>
-      <span class="nx">bus</span><span class="p">.</span><span class="nx">publish</span> <span class="nx">msg</span>
-    <span class="k">return</span></pre></div>             </td>           </tr>                               <tr id="section-50">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-50">&#182;</a>               </div>               <h1>ProxyMixin</h1>
-
-<p>Mixin class for attaching global <code>EventBus</code> handling to objects.
-It adds the <code>_subscribe()</code> and <code>_publish()</code> methods to the class, which automatically sets the context of any handler
-to <code>this</code>.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">ProxyMixin = </span><span class="k">class</span> <span class="nx">C</span><span class="p">.</span><span class="nx">ProxyMixin</span></pre></div>             </td>           </tr>                               <tr id="section-51">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-51">&#182;</a>               </div>               <h2><code>_subscribe()</code></h2>
-
-<p>Register a handler to an address with.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">subscribe: </span><span class="nf">(address, handler) -&gt;</span>
-    <span class="k">return</span> <span class="nx">@_calamity</span><span class="p">.</span><span class="nx">proxy</span><span class="p">.</span><span class="nx">bus</span><span class="p">.</span><span class="nx">subscribe</span> <span class="nx">address</span><span class="p">,</span> <span class="nx">handler</span><span class="p">,</span> <span class="nx">@</span></pre></div>             </td>           </tr>                               <tr id="section-52">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-52">&#182;</a>               </div>               <h2><code>_publish()</code></h2>
-
-<p>Publishes an event to an address.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">publish: </span><span class="nf">(address, data, reply) -&gt;</span>
-    <span class="k">return</span> <span class="nx">@_calamity</span><span class="p">.</span><span class="nx">proxy</span><span class="p">.</span><span class="nx">bus</span><span class="p">.</span><span class="nx">publish</span> <span class="nx">address</span><span class="p">,</span> <span class="nx">data</span><span class="p">,</span> <span class="nx">reply</span></pre></div>             </td>           </tr>                               <tr id="section-53">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-53">&#182;</a>               </div>               <p>We automatically construct a default global bus when needed.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">PROXY_GLOBAL_BUS = </span><span class="kc">null</span></pre></div>             </td>           </tr>                               <tr id="section-54">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-54">&#182;</a>               </div>               <h2><code>Calamity.proxy()</code></h2>
-
-<p>Adds proxy functionality.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">C.proxy = </span><span class="nf">(obj, bus) -&gt;</span></pre></div>             </td>           </tr>                               <tr id="section-55">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-55">&#182;</a>               </div>               <p>Prepare bus.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nx">unless</span> <span class="nx">bus</span> <span class="k">instanceof</span> <span class="nx">EventBus</span>
-    <span class="nx">PROXY_GLOBAL_BUS</span> <span class="o">or=</span> <span class="k">new</span> <span class="nx">EventBus</span><span class="p">()</span>
-    <span class="nv">bus = </span><span class="nx">PROXY_GLOBAL_BUS</span></pre></div>             </td>           </tr>                               <tr id="section-56">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-56">&#182;</a>               </div>               <p>Attach bus.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">c = </span><span class="p">(</span><span class="nx">obj</span><span class="p">.</span><span class="nx">_calamity</span> <span class="o">or=</span> <span class="p">{})</span>
-  <span class="nv">c.proxy =</span>
-    <span class="nv">bus: </span><span class="nx">bus</span></pre></div>             </td>           </tr>                               <tr id="section-57">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-57">&#182;</a>               </div>               <p>Extend.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nx">_</span><span class="p">.</span><span class="nx">extend</span> <span class="nx">obj</span><span class="p">,</span> <span class="nx">ProxyMixin</span><span class="p">.</span><span class="nx">prototype</span></pre></div>             </td>           </tr>                               <tr id="section-58">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-58">&#182;</a>               </div>               <h1>Subscription</h1>
-
-<p>Represents a subscription of a handler to an address on an bus.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">Subscription = </span><span class="k">class</span> <span class="nx">C</span><span class="p">.</span><span class="nx">Subscription</span></pre></div>             </td>           </tr>                               <tr id="section-59">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-59">&#182;</a>               </div>               <p>Constructor.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">constructor: </span><span class="nf">(@address, @handler, @context, @bus) -&gt;</span>
-    <span class="vi">@id = </span><span class="nx">util</span><span class="p">.</span><span class="nx">genId</span><span class="p">()</span>
-    <span class="vi">@active = </span><span class="kc">true</span>
-    <span class="k">return</span></pre></div>             </td>           </tr>                               <tr id="section-60">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-60">&#182;</a>               </div>               <h2><code>unsubscribe()</code></h2>
-
-<p>Shorthand for unsubscribing.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">unsubscribe: </span><span class="o">-&gt;</span>
-    <span class="k">return</span> <span class="nx">unless</span> <span class="nx">@_active</span>
-    <span class="nx">@bus</span><span class="p">.</span><span class="nx">unsubscribe</span> <span class="nx">@</span>
-    <span class="vi">@active = </span><span class="kc">false</span>
-    <span class="k">return</span> <span class="nx">@</span></pre></div>             </td>           </tr>                               <tr id="section-61">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-61">&#182;</a>               </div>               <h2><code>trigger()</code></h2>
-
-<p>Fires the handler with the supplied message.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">trigger: </span><span class="nf">(msg) -&gt;</span>
-    <span class="k">return</span> <span class="nx">@</span> <span class="nx">unless</span> <span class="nx">@active</span></pre></div>             </td>           </tr>                               <tr id="section-62">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-62">&#182;</a>               </div>               <p>Bind handler.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nv">bound = </span><span class="nx">_</span><span class="p">.</span><span class="nx">bind</span> <span class="nx">@handler</span><span class="p">,</span> <span class="nx">@context</span></pre></div>             </td>           </tr>                               <tr id="section-63">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-63">&#182;</a>               </div>               <p>Execute.</p>             </td>             <td class="code">               <div class="highlight"><pre>    <span class="nx">_</span><span class="p">.</span><span class="nx">defer</span> <span class="o">-&gt;</span>
-      <span class="nx">bound</span> <span class="nx">msg</span>
-      <span class="k">return</span>
-
-    <span class="k">return</span> <span class="nx">@</span></pre></div>             </td>           </tr>                               <tr id="section-64">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-64">&#182;</a>               </div>               <h1>util</h1>
-
-<p>A set of utilities used inside Calamity.</p>             </td>             <td class="code">               <div class="highlight"><pre></pre></div>             </td>           </tr>                               <tr id="section-65">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-65">&#182;</a>               </div>               <p>Import Math functions.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">random = </span><span class="nb">Math</span><span class="p">.</span><span class="nx">random</span>
-<span class="nv">floor = </span><span class="nb">Math</span><span class="p">.</span><span class="nx">floor</span></pre></div>             </td>           </tr>                               <tr id="section-66">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-66">&#182;</a>               </div>               <p>Hexadecimals.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">HEX = </span><span class="s">&quot;0123456789abcdef&quot;</span><span class="p">.</span><span class="nx">split</span> <span class="s">&quot;&quot;</span></pre></div>             </td>           </tr>                               <tr id="section-67">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-67">&#182;</a>               </div>               <p>Generic utility functions.</p>             </td>             <td class="code">               <div class="highlight"><pre><span class="nv">util = C.util =</span></pre></div>             </td>           </tr>                               <tr id="section-68">             <td class="docs">               <div class="pilwrap">                 <a class="pilcrow" href="#section-68">&#182;</a>               </div>               <p>Generates a 128 bit ID.</p>             </td>             <td class="code">               <div class="highlight"><pre>  <span class="nv">genId: </span><span class="o">-&gt;</span>
-    <span class="nv">id = </span><span class="s">&quot;&quot;</span>
-    <span class="k">for</span> <span class="nx">i</span> <span class="k">in</span> <span class="p">[</span><span class="mi">1</span><span class="p">..</span><span class="mi">32</span><span class="p">]</span>
-      <span class="nx">id</span> <span class="o">+=</span> <span class="nx">HEX</span><span class="p">[</span><span class="nx">floor</span><span class="p">(</span><span class="nx">random</span><span class="p">()</span> <span class="o">*</span> <span class="nx">HEX</span><span class="p">.</span><span class="nx">length</span><span class="p">)]</span>
-    <span class="k">return</span> <span class="nx">id</span>
-
-</pre></div>             </td>           </tr>                </tbody>     </table>   </div> </body> </html> 

docs/docco.css

-/*--------------------- Layout and Typography ----------------------------*/
-body {
-  font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
-  font-size: 15px;
-  line-height: 22px;
-  color: #252519;
-  margin: 0; padding: 0;
-}
-a {
-  color: #261a3b;
-}
-  a:visited {
-    color: #261a3b;
-  }
-p {
-  margin: 0 0 15px 0;
-}
-h1, h2, h3, h4, h5, h6 {
-  margin: 0px 0 15px 0;
-}
-  h1 {
-    margin-top: 40px;
-  }
-hr {
-    border: 0 none;
-    border-top: 1px solid #e5e5ee;
-    height: 1px;
-    margin: 20px 0;
-}
-#container {
-  position: relative;
-}
-#background {
-  position: fixed;
-  top: 0; left: 525px; right: 0; bottom: 0;
-  background: #f5f5ff;
-  border-left: 1px solid #e5e5ee;
-  z-index: -1;
-}
-#jump_to, #jump_page {
-  background: white;
-  -webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
-  -webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px;
-  font: 10px Arial;
-  text-transform: uppercase;
-  cursor: pointer;
-  text-align: right;
-}
-#jump_to, #jump_wrapper {
-  position: fixed;
-  right: 0; top: 0;
-  padding: 5px 10px;
-}
-  #jump_wrapper {
-    padding: 0;
-    display: none;
-  }
-    #jump_to:hover #jump_wrapper {
-      display: block;
-    }
-    #jump_page {
-      padding: 5px 0 3px;
-      margin: 0 0 25px 25px;
-    }
-      #jump_page .source {
-        display: block;
-        padding: 5px 10px;
-        text-decoration: none;
-        border-top: 1px solid #eee;
-      }
-        #jump_page .source:hover {
-          background: #f5f5ff;
-        }
-        #jump_page .source:first-child {
-        }
-table td {
-  border: 0;
-  outline: 0;
-}
-  td.docs, th.docs {
-    max-width: 450px;
-    min-width: 450px;
-    min-height: 5px;
-    padding: 10px 25px 1px 50px;
-    overflow-x: hidden;
-    vertical-align: top;
-    text-align: left;
-  }
-    .docs pre {
-      margin: 15px 0 15px;
-      padding-left: 15px;
-    }
-    .docs p tt, .docs p code {
-      background: #f8f8ff;
-      border: 1px solid #dedede;
-      font-size: 12px;
-      padding: 0 0.2em;
-    }
-    .pilwrap {
-      position: relative;
-    }
-      .pilcrow {
-        font: 12px Arial;
-        text-decoration: none;
-        color: #454545;
-        position: absolute;
-        top: 3px; left: -20px;
-        padding: 1px 2px;
-        opacity: 0;
-        -webkit-transition: opacity 0.2s linear;
-      }
-        td.docs:hover .pilcrow {
-          opacity: 1;
-        }
-  td.code, th.code {
-    padding: 14px 15px 16px 25px;
-    width: 100%;
-    vertical-align: top;
-    background: #f5f5ff;
-    border-left: 1px solid #e5e5ee;
-  }
-    pre, tt, code {
-      font-size: 12px; line-height: 18px;
-      font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace;
-      margin: 0; padding: 0;
-    }
-
-
-/*---------------------- Syntax Highlighting -----------------------------*/
-td.linenos { background-color: #f0f0f0; padding-right: 10px; }
-span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
-body .hll { background-color: #ffffcc }
-body .c { color: #408080; font-style: italic }  /* Comment */
-body .err { border: 1px solid #FF0000 }         /* Error */
-body .k { color: #954121 }                      /* Keyword */
-body .o { color: #666666 }                      /* Operator */
-body .cm { color: #408080; font-style: italic } /* Comment.Multiline */
-body .cp { color: #BC7A00 }                     /* Comment.Preproc */
-body .c1 { color: #408080; font-style: italic } /* Comment.Single */
-body .cs { color: #408080; font-style: italic } /* Comment.Special */
-body .gd { color: #A00000 }                     /* Generic.Deleted */
-body .ge { font-style: italic }                 /* Generic.Emph */
-body .gr { color: #FF0000 }                     /* Generic.Error */
-body .gh { color: #000080; font-weight: bold }  /* Generic.Heading */
-body .gi { color: #00A000 }                     /* Generic.Inserted */
-body .go { color: #808080 }                     /* Generic.Output */
-body .gp { color: #000080; font-weight: bold }  /* Generic.Prompt */
-body .gs { font-weight: bold }                  /* Generic.Strong */
-body .gu { color: #800080; font-weight: bold }  /* Generic.Subheading */
-body .gt { color: #0040D0 }                     /* Generic.Traceback */
-body .kc { color: #954121 }                     /* Keyword.Constant */
-body .kd { color: #954121; font-weight: bold }  /* Keyword.Declaration */
-body .kn { color: #954121; font-weight: bold }  /* Keyword.Namespace */
-body .kp { color: #954121 }                     /* Keyword.Pseudo */
-body .kr { color: #954121; font-weight: bold }  /* Keyword.Reserved */
-body .kt { color: #B00040 }                     /* Keyword.Type */
-body .m { color: #666666 }                      /* Literal.Number */
-body .s { color: #219161 }                      /* Literal.String */
-body .na { color: #7D9029 }                     /* Name.Attribute */
-body .nb { color: #954121 }                     /* Name.Builtin */
-body .nc { color: #0000FF; font-weight: bold }  /* Name.Class */
-body .no { color: #880000 }                     /* Name.Constant */
-body .nd { color: #AA22FF }                     /* Name.Decorator */
-body .ni { color: #999999; font-weight: bold }  /* Name.Entity */
-body .ne { color: #D2413A; font-weight: bold }  /* Name.Exception */
-body .nf { color: #0000FF }                     /* Name.Function */
-body .nl { color: #A0A000 }                     /* Name.Label */
-body .nn { color: #0000FF; font-weight: bold }  /* Name.Namespace */
-body .nt { color: #954121; font-weight: bold }  /* Name.Tag */
-body .nv { color: #19469D }                     /* Name.Variable */
-body .ow { color: #AA22FF; font-weight: bold }  /* Operator.Word */
-body .w { color: #bbbbbb }                      /* Text.Whitespace */
-body .mf { color: #666666 }                     /* Literal.Number.Float */
-body .mh { color: #666666 }                     /* Literal.Number.Hex */
-body .mi { color: #666666 }                     /* Literal.Number.Integer */
-body .mo { color: #666666 }                     /* Literal.Number.Oct */
-body .sb { color: #219161 }                     /* Literal.String.Backtick */
-body .sc { color: #219161 }                     /* Literal.String.Char */
-body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */
-body .s2 { color: #219161 }                     /* Literal.String.Double */
-body .se { color: #BB6622; font-weight: bold }  /* Literal.String.Escape */
-body .sh { color: #219161 }                     /* Literal.String.Heredoc */
-body .si { color: #BB6688; font-weight: bold }  /* Literal.String.Interpol */
-body .sx { color: #954121 }                     /* Literal.String.Other */
-body .sr { color: #BB6688 }                     /* Literal.String.Regex */
-body .s1 { color: #219161 }                     /* Literal.String.Single */
-body .ss { color: #19469D }                     /* Literal.String.Symbol */
-body .bp { color: #954121 }                     /* Name.Builtin.Pseudo */
-body .vc { color: #19469D }                     /* Name.Variable.Class */
-body .vg { color: #19469D }                     /* Name.Variable.Global */
-body .vi { color: #19469D }                     /* Name.Variable.Instance */
-body .il { color: #666666 }                     /* Literal.Number.Integer.Long */

docs/messages.md

-# Messages, Events, Commands, Futures, and Progresses.
-
-## Message
-`Message` is the base class for message passing.
-
-## Event
-`Event` is the first addition to `Message`.
-It's the most commonly used class, and represents something which happened in the past:
-e.g. A button click, a model change, or the result of a command.
-
-## Command
-`Command` is the second addition to `Message`.
-It represents a desired action and is used to convey intent from one part of the application to the other.
-They are used to keep everything loosely coupled, but still allow non-idempotent communication.
-
-## Future
-`Future` is an addition to `Command`.
-When a `Command` is sent to the bus, a`Future` object is returned.
-This object is used to manage message handler for when an event comes back from a command.
-
-## Progress
-`Progress` is the third extension to `Message`.
-It is used to represent the status of an existing command, as it is being executed.
-Command executors can use this to report back about the status if a long running job.
-Completion notification should be done using normal `Events`.

grunt.js

-module.exports = function(grunt) {
-
-	// Project configuration.
-	grunt.initConfig({
-		pkg: '<json:package.json>',
-		meta: {
-			banner: "/*! <%= pkg.fullname %> <%= pkg.version %> - MIT license */",
-			wrapperVersion: "C.VERSION = \"<%= pkg.version %>\";",
-			wrapperStart: "(function(){",
-			wrapperEnd: "}).call(this);"
-		},
-
-		coffee: {
-			// Initial precompile to catch compile errors properly.
-			core_first: {
-				files: {
-					"build/core/*.js": ["src/core/*.coffee"]
-				},
-				options: {
-					bare: true
-				}
-			},
-			// Second compile of concatenated coffee files for more minimizes output.
-			core_second: {
-				files: {
-					"build/core/calamity.js": ["build/core/<%= pkg.name %>.coffee"]
-				},
-				options: {
-					bare: true
-				}
-			},
-			// Compile the core test coffee files.
-			core_test: {
-				files: {
-					"build/test/core/*.js": ["test/core/*.coffee"]
-				}
-			}
-		},
-
-		// Build Jasmine core specs for the browser
-		browserify: {
-			"build/spec.js": {
-				entries: ["spec/core/*.coffee"]
-			}
-		},
-
-		// Execute Jasmine specs
-		jasmine : {
-			src: [
-				"node_modules/sinon/lib/sinon.js",
-				"node_modules/sinon/lib/sinon/spy.js",
-				"lib/jasmine-sinon.js"
-			],
-			specs : "build/spec.js",
-			timeout : 500,
-			verbose: true,
-			junit : {
-				output : "build/spec/"
-			},
-			phantomjs : {
-				"ignore-ssl-errors" : true
-			}
-		},
-
-		concat: {
-			// Assembles the core coffee files in prep for full compile.
-			core_coffee: {
-				src: "src/core/*.coffee",
-				dest: "build/core/<%= pkg.name %>.coffee"
-			},
-			// Assembles the core distribution files.
-			core_dist: {
-				src: [
-					"<banner>",
-					"<banner:meta.wrapperStart>",
-					"src/init/init.js",
-					"<banner:meta.wrapperVersion>",
-					"<%= _.keys(coffee.core_second.files)[0] %>",
-					"<banner:meta.wrapperEnd>"
-				],
-				dest: "<%= pkg.name %>.js"
-			}
-		},
-		min: {
-			// Minimizes the core distribution files.
-			core: {
-				src: [
-					"<banner>",
-					"<config:concat.core_dist.dest>"
-				],
-				dest: "<%= pkg.name %>-min.js"
-			}
-		},
-
-		test: {
-			files : [
-				// Core tests.
-				"<%= _.keys(coffee.core_test.files) %>"
-			]
-		},
-
-		watch: {
-			files: [
-				"src/**",
-				"test/**"
-			],
-			tasks: "default"
-		}
-	});
-
-	// Load grunt plugins.
-	grunt.loadNpmTasks("grunt-contrib-coffee");
-	grunt.loadNpmTasks("grunt-jasmine-runner");
-//	grunt.loadNpmTasks("grunt-jasmine-node");
-	grunt.loadNpmTasks("grunt-browserify");
-
-	// Core compile.
-	grunt.registerTask("compile-core", "coffee:core_first concat:core_coffee coffee:core_second");
-	grunt.registerTask("dist-core", "concat:core_dist min:core");
-	grunt.registerTask("test-core", "coffee:core_test test"); // will go away once ported to jasmine
-	grunt.registerTask("spec-phantomjs", "browserify jasmine");
-	grunt.registerTask("build-core", "compile-core dist-core test-core spec-phantomjs");
-	// Default task.
-	grunt.registerTask("default", "build-core");
-
-};
 {
-	"fullname": "CalamityJS",
+	"fullname": "Calamity",
 	"name": "calamity",
-	"version": "0.3.0",
+	"version": "0.3.1",
 	"description": "An event bus library for event-driven applications.",
 	"keywords": ["events", "pubsub"],
-	"homepage": "https://bitbucket.org/kennethjor/calamityjs",
-	"bugs": "https://bitbucket.org/kennethjor/calamityjs/issues",
+	"homepage": "https://bitbucket.org/kennethjor/calamity",
+	"bugs": "https://bitbucket.org/kennethjor/calamity/issues",
 	"author": "Kenneth Jorgensen <kennethjor@gmail.com> (http://kennethjorgensen.com/)",
 	"main": "calamity.js",
 	"repository": {
 		"type": "hg",
-		"url": "ssh://hg@bitbucket.org/kennethjor/calamityjs"
+		"url": "ssh://hg@bitbucket.org/kennethjor/calamity"
 	},
 	"licenses": [
 		{
 			"type" : "MIT",
-			"url" : "https://bitbucket.org/kennethjor/calamityjs/raw/default/LICENSE"
+			"url" : "https://bitbucket.org/kennethjor/calamity/raw/default/LICENSE"
 		}
 	],
 	"dependencies": {
-        "underscore": "~ 1.4.3"
+		"underscore": "~ 1.4.4"
 	},
 	"devDependencies": {
-		"grunt-contrib-coffee": "~ 0.3.2",
+		"grunt": "~ 0.4",
+		"grunt-contrib-concat": "~ 0.1.3",
+		"grunt-contrib-coffee": "~ 0.6.0",
+		"grunt-contrib-uglify": "~ 0.2.0",
+		"grunt-contrib-nodeunit": "~ 0.1.2",
+		"grunt-contrib-watch": "~ 0.3.1",
 		"async": "~ 0.1.22",
-		"grunt-browserify": "~ 0.1.2",
-		"grunt-jasmine-runner": "~ 0.6.0",
-		"sinon": "~ 1.5.2"
-	},
-	"scripts": {
-		"prepublish": "grunt && ./docs.sh"
+		"jessie": "~ 0.4.2",
+		"sinon": "~ 1.6.0",
+		"doxx": "~ 0.5.9"
 	},
 	"files": [
 		"calamity.js",
 		"package.json",
 		"LICENSE",
 		"README.md",
-		"CHANGELOG.md",
-		"docs"
+		"CHANGELOG.md"
 	]
 }

spec/core/EventBusSpec.coffee

-C = require "../../../calamity.js"
+C = require "../../../calamity"
+sinon = require "sinon"
 
 describe "EventBus", ->
 	bus = null
 			bus.publish "address/1"
 		waits 10
 		runs ->
-			expect(handler11).toHaveBeenCalledOnce()
-			expect(handler12).toHaveBeenCalledOnce()
-			expect(handler2).not.toHaveBeenCalled()
+			expect(handler11.callCount).toBe 1
+			expect(handler12.callCount).toBe 1
+			expect(handler2.called).toBe false
 
 			bus.publish "address/2"
 		waits 10
 		runs ->
-			expect(handler11).toHaveBeenCalledOnce()
-			expect(handler12).toHaveBeenCalledOnce()
-			expect(handler2).toHaveBeenCalledOnce()
+			expect(handler11.callCount).toBe 1
+			expect(handler12.callCount).toBe 1
+			expect(handler2.called).toBe true
 
 	it "should send correct message to handlers", ->
 		msg = null
 }
 
 // Init Calamity object.
-var C = {};
+var C = {version: "<%= pkg.version %>"};
 
-// This wrapper is brutally stolen from Underscore 1.4.2.
-// https://raw.github.com/documentcloud/underscore/master/underscore.js
 var root = this
-if (typeof exports !== 'undefined') {
-	if (typeof module !== 'undefined' && module.exports) {
+// CommonJS
+if (typeof exports !== "undefined") {
+	if (typeof module !== "undefined" && module.exports) {
 		exports = module.exports = C;
 	}
 	exports.C = C;
-} else {
+}
+// AMD
+else if (typeof define === "function" && define.amd) {
+    define(['calamity'], C);
+}
+// Browser
+else {
 	root['Calamity'] = C;
 }

test/core/EmitterMixinTest.coffee

-calamity = require "../../../calamity.js"
+calamity = require "../../../calamity"
 async = require "async"
 
 # Test class with the emitter mixin applied.

test/core/EventBusTest.coffee

-calamity = require "../../../calamity.js"
+calamity = require "../../../calamity"
 async = require "async"
 
 bus = null

test/core/EventMessageTest.coffee

-calamity = require "../../../calamity.js"
+calamity = require "../../../calamity"
 async = require "async"
 
 msg = null

test/core/MemoryEventBridgeTest.coffee

-calamity = require "../../../calamity.js"
+calamity = require "../../../calamity"
 async = require "async"
 
 bus = null

test/core/ProxyMixinTest.coffee

-calamity = require "../../../calamity.js"
+calamity = require "../../../calamity"
 async = require "async"
 
 # Proxy using the default global bus.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.