Permalink
Browse files

literate code

  • Loading branch information...
1 parent ecadfed commit 8c3cf26b02faa198e857829023041342bf68efa2 chrisdew committed Feb 4, 2011
View
@@ -0,0 +1,10 @@
+all: clean docs
+
+clean:
+ rm -rf docs
+
+docs:
+ docco lib/*.js test/*.js
+ google-chrome ./docs
+
+
View
@@ -8,7 +8,7 @@ BarricaneDB is a loose implementation of the [Prevalence](http://www.ibm.com/dev
Features
--------
* Fantastically fast.
-* Stupidly simple, thank you __defineSetter__ and friends.
+* Stupidly simple, thank you <code>__defineSetter__</code> and friends.
* ORM-less, just work with your objects directly.
* Snapshot plus transaction log gives persistance in event of an application crash.
View
@@ -0,0 +1,7 @@
+<!DOCTYPE html> <html> <head> <title>barricane-db.js</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> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="barricane-db.html"> barricane-db.js </a> <a class="source" href="bdb-disk-manager.html"> bdb-disk-manager.js </a> <a class="source" href="db.html"> db.js </a> <a class="source" href="disk-io.html"> disk-io.js </a> <a class="source" href="old-barricane-db.html"> old-barricane-db.js </a> <a class="source" href="serialisation.html"> serialisation.js </a> <a class="source" href="demo.html"> demo.js </a> <a class="source" href="hello_world.html"> hello_world.js </a> <a class="source" href="model.html"> model.js </a> <a class="source" href="old-disk-manager.html"> old-disk-manager.js </a> <a class="source" href="old-serialisation.html"> old-serialisation.js </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> barricane-db.js </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> <p>Copyright (c) 2010 Barricane Technology Ltd., All Rights Reserved.
+Released under the MIT open source licence.</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>This file is the entry point for the NPM barricane-db package.
+It only exports symbols required from other modules.</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">db_mod</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./db&#39;</span><span class="p">);</span>
+<span class="kd">var</span> <span class="nx">disk_io_mod</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./disk-io&#39;</span><span class="p">);</span>
+<span class="nx">exports</span><span class="p">.</span><span class="nx">DB</span> <span class="o">=</span> <span class="nx">db_mod</span><span class="p">.</span><span class="nx">DB</span><span class="p">;</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
View
@@ -0,0 +1,43 @@
+<!DOCTYPE html> <html> <head> <title>bdb-disk-manager.js</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> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="barricane-db.html"> barricane-db.js </a> <a class="source" href="bdb-disk-manager.html"> bdb-disk-manager.js </a> <a class="source" href="db.html"> db.js </a> <a class="source" href="disk-io.html"> disk-io.js </a> <a class="source" href="old-barricane-db.html"> old-barricane-db.js </a> <a class="source" href="serialisation.html"> serialisation.js </a> <a class="source" href="demo.html"> demo.js </a> <a class="source" href="hello_world.html"> hello_world.js </a> <a class="source" href="model.html"> model.js </a> <a class="source" href="old-disk-manager.html"> old-disk-manager.js </a> <a class="source" href="old-serialisation.html"> old-serialisation.js </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> bdb-disk-manager.js </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> <p>The DB Manager handles aspects such as loading DBs from disk and persistence.</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">bdb</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;../lib/old-barricane-db&#39;</span><span class="p">);</span>
+<span class="kd">var</span> <span class="nx">fs</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;fs&#39;</span><span class="p">);</span>
+
+<span class="kd">function</span> <span class="nx">BDBDiskManager</span><span class="p">(</span><span class="nx">options</span><span class="p">)</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">that</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
+
+ <span class="k">this</span><span class="p">.</span><span class="nx">options</span> <span class="o">=</span> <span class="nx">options</span><span class="p">;</span>
+ <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">options</span> <span class="o">===</span> <span class="kc">undefined</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">options</span> <span class="o">=</span> <span class="p">{};</span>
+ <span class="p">}</span>
+ <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">path</span> <span class="o">===</span> <span class="kc">undefined</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">path</span> <span class="o">=</span> <span class="s2">&quot;/tmp/&quot;</span><span class="p">;</span>
+ <span class="p">}</span>
+ <span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">name</span> <span class="o">===</span> <span class="kc">undefined</span><span class="p">)</span> <span class="p">{</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">name</span> <span class="o">=</span> <span class="s2">&quot;unnamed_db&quot;</span><span class="p">;</span>
+ <span class="p">}</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">db</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">bdb</span><span class="p">.</span><span class="nx">DB</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">);</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">txnlog</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">txnlogPath</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">path</span> <span class="o">+</span> <span class="s2">&quot;/&quot;</span> <span class="o">+</span> <span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">name</span> <span class="o">+</span> <span class="s2">&quot;.log&quot;</span><span class="p">;</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">snapshot</span> <span class="o">=</span> <span class="kc">null</span><span class="p">;</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">snapshotPath</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">path</span> <span class="o">+</span> <span class="s2">&quot;/&quot;</span> <span class="o">+</span> <span class="k">this</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">name</span> <span class="o">+</span> <span class="s2">&quot;.bdb&quot;</span><span class="p">;</span>
+
+ <span class="k">try</span> <span class="p">{</span> <span class="c1">// FIXME: do this properly</span>
+ <span class="nx">fs</span><span class="p">.</span><span class="nx">statSync</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">snapshotPath</span><span class="p">);</span>
+ <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;loadDB&quot;</span><span class="p">);</span>
+ <span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
+ <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s2">&quot;createDB&quot;</span><span class="p">);</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">snapshot_fd</span> <span class="o">=</span> <span class="nx">fs</span><span class="p">.</span><span class="nx">openSync</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">snapshotPath</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">);</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">txnlog_fd</span> <span class="o">=</span> <span class="nx">fs</span><span class="p">.</span><span class="nx">openSync</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">txnlogPath</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">);</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">db</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">write</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">arg</span><span class="p">)</span> <span class="p">{</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>console.log(arg);</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">fs</span><span class="p">.</span><span class="nx">write</span><span class="p">(</span><span class="nx">that</span><span class="p">.</span><span class="nx">txnlog_fd</span><span class="p">,</span> <span class="nx">arg</span><span class="p">);</span>
+ <span class="p">}</span>
+ <span class="nx">fs</span><span class="p">.</span><span class="nx">writeSync</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">snapshot_fd</span><span class="p">,</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">stringify</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">db</span><span class="p">));</span>
+ <span class="nx">fs</span><span class="p">.</span><span class="nx">closeSync</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">snapshot_fd</span><span class="p">);</span>
+ <span class="p">}</span>
+<span class="p">}</span>
+
+<span class="nx">BDBDiskManager</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">end</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
+ <span class="k">this</span><span class="p">.</span><span class="nx">db</span><span class="p">.</span><span class="nx">options</span><span class="p">.</span><span class="nx">write</span> <span class="o">=</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{};</span>
+ <span class="nx">fs</span><span class="p">.</span><span class="nx">closeSync</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">txnlog_fd</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> <p>this.txnlog.destroy();</p> </td> <td class="code"> <div class="highlight"><pre><span class="p">}</span>
+
+<span class="nx">exports</span><span class="p">.</span><span class="nx">BDBDiskManager</span> <span class="o">=</span> <span class="nx">BDBDiskManager</span><span class="p">;</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>
Oops, something went wrong.

0 comments on commit 8c3cf26

Please sign in to comment.