Permalink
Browse files

Add coverage report and some doc updates

  • Loading branch information...
kriskowal committed Dec 23, 2012
1 parent 211557e commit 7fb7058907cc700523b425fbadc35efd20dcb3bc
Showing with 171 additions and 0 deletions.
  1. +127 −0 README.md
  2. +44 −0 coverage-report.js
View
127 README.md
@@ -10,8 +10,15 @@ Q-IO now subsumes all of [Q-HTTP][] and [Q-FS][].
[Q-HTTP]: https://github.com/kriskowal/q-http
[Q-FS]: https://github.com/kriskowal/q-fs
+The Q-IO package does not export a main module. You must reach in
+directly for `q-io/fs`, `q-io/http`, and `q-io/http-apps`.
+
## Filesystem
+```javascript
+var FS = require("q-io/fs");
+```
+
File system API for Q promises with method signatures patterned after
[CommonJS/Fileystem/A](http://wiki.commonjs.org/wiki/Filesystem/A) but
returning promises and promise streams.
@@ -130,10 +137,49 @@ Not yet implemented
Not yet implemented
+## Mock Filesystem
+
+Q-IO provides a mock filesystem interface. The mock filesystem has the
+same interface as the real one and has most of the same features, but
+operates on a purely in-memory, in-process, in-javascript filesystem.
+
+A mock filesystem can be created from a data structure. Objects are
+directories. Keys are paths. A buffer is a file’s contents. Anything
+else is coerced to a string, then to a buffer in the UTF-8 encoding.
+
+```javascript
+var MockFs = require("q-io/fs-mock");
+var mockFs = MockFs({
+ "a": {
+ "b": {
+ "c.txt": "Content of a/b/c.txt"
+ }
+ },
+ "a/b/d.txt": new Buffer("Content of a/b/d.txt", "utf-8")
+})
+```
+
+You can also instantiate a mock file system with the content of a
+subtree of a real file system. You receive a promise for the mock
+filesystem.
+
+```javascript
+var FS = require("q-io/fs");
+FS.mock(__dirname)
+.then(function (fs) {
+ //
+})
+.done();
+```
+
## HTTP
The HTTP module resembles [CommonJS/JSGI][].
+```javascript
+var HTTP = require("q-io/http");
+```
+
[CommonJS/JSGI]: http://wiki.commonjs.org/wiki/JSGI
### Server(app)
@@ -294,6 +340,87 @@ Writer instances have the following methods:
The `writer` module exports a function that accepts a Node writer and
returns a Q writer.
+# HTTP Applications
+
+The HTTP applications module provides a comprehensive set of JSGI-alike
+middleware.
+
+```javascript
+var Apps = require("q-io/http-apps");
+```
+
+# Coverage
+
+Use `npm run cover` to generate and view a coverage report of Q-IO.
+
+<table>
+ <thead>
+ <tr>
+ <th>File</th>
+ <th>Percentage</th>
+ <th>Missing</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>fs-boot.js</code></td>
+ <td>87%</td>
+ <td>41</td>
+ </tr>
+ <tr>
+ <td><code>fs.js</code></td>
+ <td>72%</td>
+ <td>100</td>
+ </tr>
+ <tr>
+ <td><code>reader.js</code></td>
+ <td>94%</td>
+ <td>8</td>
+ </tr>
+ <tr>
+ <td><code>writer.js</code></td>
+ <td>91%</td>
+ <td>8</td>
+ </tr>
+ <tr>
+ <td><code>fs-common.js</code></td>
+ <td>87%</td>
+ <td>52</td>
+ </tr>
+ <tr>
+ <td><code>fs-root.js</code></td>
+ <td>88%</td>
+ <td>11</td>
+ </tr>
+ <tr>
+ <td><code>fs-mock.js</code></td>
+ <td>91%</td>
+ <td>46</td>
+ </tr>
+ <tr>
+ <td><code>buffer-stream.js</code></td>
+ <td>89%</td>
+ <td>6</td>
+ </tr>
+ <tr>
+ <td><code>http.js</code></td>
+ <td>93%</td>
+ <td>25</td>
+ </tr>
+ <tr>
+ <td><code>http-apps.js</code></td>
+ <td>80%</td>
+ <td>286</td>
+ </tr>
+ <tr>
+ <td><code>http-cookie.js</code></td>
+ <td>79%</td>
+ <td>15</td>
+ </tr>
+ </tbody>
+</table>
+
+
---
Copyright 2009–2012 Kristopher Michael Kowal
View
@@ -0,0 +1,44 @@
+
+require("collections/shim");
+var Q = require("q");
+var FS = require("./fs");
+
+FS.listTree(".coverage_data", function (name, stat) {
+ return (/^\.coverage_data\/coveragefile/).test(name);
+})
+.then(function (list) {
+ return Q.all(list.map(function (file) {
+ return FS.read(file)
+ .then(function (content) {
+ return JSON.parse(content);
+ })
+ .then(function (coverage) {
+ console.log("<table>");
+ console.log(" <thead>");
+ console.log(" <tr>");
+ console.log(" <th>File</th>");
+ console.log(" <th>Percentage</th>");
+ console.log(" <th>Missing</th>");
+ console.log(" </tr>");
+ console.log(" </thead>");
+ console.log(" <tbody>");
+ Object.forEach(coverage.files, function (file, path) {
+ path = FS.relativeFromDirectory(__dirname, path);
+ if (/^spec/.test(path))
+ return;
+ console.log(" <tr>");
+ console.log(" <td><code>" + path + "</code></td>");
+ console.log(" <td>" + (file.stats.percentage * 100).toFixed(0) + "%</td>");
+ console.log(" <td>" + file.stats.missing + "</td>");
+ console.log(" </tr>");
+ });
+ console.log(" </tbody>");
+ console.log("</table>");
+ }, function (error) {
+ error.message = "Can't parse " + file + " because " + error.message;
+ throw error;
+ })
+ }))
+})
+.done()
+

0 comments on commit 7fb7058

Please sign in to comment.