Demo for query storing

Change-Id: I947bcac841992c3f6cfd01ab337c265b0d01cb70
diff --git a/node_modules/console-stream/.npmignore b/node_modules/console-stream/.npmignore
new file mode 100644
index 0000000..aa3fd4b
--- /dev/null
+++ b/node_modules/console-stream/.npmignore
@@ -0,0 +1,14 @@
+.DS_Store
+.monitor
+.*.swp
+.nodemonignore
+releases
+*.log
+*.err
+fleet.json
+public/browserify
+bin/*.json
+.bin
+build
+compile
+.lock-wscript
diff --git a/node_modules/console-stream/.testem.json b/node_modules/console-stream/.testem.json
new file mode 100644
index 0000000..633c2ba
--- /dev/null
+++ b/node_modules/console-stream/.testem.json
@@ -0,0 +1,14 @@
+{
+    "launchers": {
+        "node": {
+            "command": "npm test"
+        }
+    },
+    "src_files": [
+        "./**/*.js"
+    ],
+    "before_tests": "npm run build",
+    "on_exit": "rm test/static/bundle.js",
+    "test_page": "test/static/index.html",
+    "launch_in_dev": ["node", "phantomjs"]
+}
diff --git a/node_modules/console-stream/.travis.yml b/node_modules/console-stream/.travis.yml
new file mode 100644
index 0000000..ed178f6
--- /dev/null
+++ b/node_modules/console-stream/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+  - 0.8
+  - 0.9
diff --git a/node_modules/console-stream/LICENCE b/node_modules/console-stream/LICENCE
new file mode 100644
index 0000000..a23e08a
--- /dev/null
+++ b/node_modules/console-stream/LICENCE
@@ -0,0 +1,19 @@
+Copyright (c) 2012 Raynos.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
\ No newline at end of file
diff --git a/node_modules/console-stream/README.md b/node_modules/console-stream/README.md
new file mode 100644
index 0000000..c8f8c15
--- /dev/null
+++ b/node_modules/console-stream/README.md
@@ -0,0 +1,42 @@
+# console-stream
+
+[![build status][1]][2]
+
+[![browser support][3]][4]
+
+A writable stream that writes to the console
+
+Refactored out of [tape][5]
+
+## Example
+
+```js
+var ConsoleStream = require("console-stream")
+
+var stream = ConsoleStream()
+
+stream.write("one")
+stream.write("two\n")
+// console.log('onetwo')
+stream.write("three\nfour")
+// console.log('three')
+stream.end("five")
+// console.log('fourfive')
+```
+
+## Installation
+
+`npm install console-stream`
+
+## Contributors
+
+ - Raynos
+
+## MIT Licenced
+
+
+  [1]: https://secure.travis-ci.org/Raynos/console-stream.png
+  [2]: http://travis-ci.org/Raynos/console-stream
+  [3]: http://ci.testling.com/Raynos/console-stream.png
+  [4]: http://ci.testling.com/Raynos/console-stream
+  [5]: https://github.com/substack/tape/blob/028e858f85c6916a730dca183c00469ebb869729/lib/default_stream.js
diff --git a/node_modules/console-stream/index.js b/node_modules/console-stream/index.js
new file mode 100644
index 0000000..5e64ad6
--- /dev/null
+++ b/node_modules/console-stream/index.js
@@ -0,0 +1,45 @@
+var Stream = require("stream")
+var console = require("console")
+
+var NEW_LINE = "\n"
+
+module.exports = ConsoleStream
+
+function ConsoleStream() {
+    var stream = new Stream()
+    stream.writable = true
+    var buffered = ""
+
+    stream.write = write
+    stream.destroy = destroy
+    stream.end = end
+
+    return stream
+
+    function write(buffer) {
+        var s = buffered + String(buffer)
+        var lines = s.split(NEW_LINE)
+        for (var i = 0; i < lines.length - 1; i++) {
+            console.log(lines[i])
+        }
+
+        buffered = lines[i]
+    }
+
+    function destroy() {
+        stream.writable = false
+        stream.emit("close")
+    }
+
+    function end(buffer) {
+        if (arguments.length === 1) {
+            stream.write(buffer)
+        }
+
+        if (buffered) {
+            console.log(buffered)
+        }
+
+        stream.destroy()
+    }
+}
diff --git a/node_modules/console-stream/package.json b/node_modules/console-stream/package.json
new file mode 100644
index 0000000..6949c49
--- /dev/null
+++ b/node_modules/console-stream/package.json
@@ -0,0 +1,94 @@
+{
+  "_from": "console-stream@^0.1.1",
+  "_id": "console-stream@0.1.1",
+  "_inBundle": false,
+  "_integrity": "sha1-oJX+B7IEZZVfL6/Si11yvM2UnUQ=",
+  "_location": "/console-stream",
+  "_phantomChildren": {},
+  "_requested": {
+    "type": "range",
+    "registry": true,
+    "raw": "console-stream@^0.1.1",
+    "name": "console-stream",
+    "escapedName": "console-stream",
+    "rawSpec": "^0.1.1",
+    "saveSpec": null,
+    "fetchSpec": "^0.1.1"
+  },
+  "_requiredBy": [
+    "/squeak"
+  ],
+  "_resolved": "https://registry.npmjs.org/console-stream/-/console-stream-0.1.1.tgz",
+  "_shasum": "a095fe07b20465955f2fafd28b5d72bccd949d44",
+  "_spec": "console-stream@^0.1.1",
+  "_where": "C:\\Users\\marcr\\Desktop\\KorAp\\Git\\Kalamar\\node_modules\\squeak",
+  "author": {
+    "name": "Raynos",
+    "email": "raynos2@gmail.com"
+  },
+  "bugs": {
+    "url": "https://github.com/Raynos/console-stream/issues",
+    "email": "raynos2@gmail.com"
+  },
+  "bundleDependencies": false,
+  "contributors": [
+    {
+      "name": "Raynos"
+    }
+  ],
+  "dependencies": {},
+  "deprecated": false,
+  "description": "A writable stream that writes to the console",
+  "devDependencies": {
+    "browserify": "https://github.com/raynos/node-browserify/tarball/master",
+    "tape": "~0.2.2",
+    "testem": "~0.2.55"
+  },
+  "homepage": "https://github.com/Raynos/console-stream",
+  "keywords": [],
+  "licenses": [
+    {
+      "type": "MIT",
+      "url": "http://github.com/Raynos/console-stream/raw/master/LICENSE"
+    }
+  ],
+  "main": "index",
+  "name": "console-stream",
+  "repository": {
+    "type": "git",
+    "url": "git://github.com/Raynos/console-stream.git"
+  },
+  "scripts": {
+    "build": "browserify test/index.js -o test/static/bundle.js",
+    "test": "node ./test",
+    "testem": "testem"
+  },
+  "testling": {
+    "files": "test/index.js",
+    "browsers": {
+      "ie": [
+        "8",
+        "9",
+        "10"
+      ],
+      "firefox": [
+        "16",
+        "17",
+        "nightly"
+      ],
+      "chrome": [
+        "22",
+        "23",
+        "canary"
+      ],
+      "opera": [
+        "12",
+        "next"
+      ],
+      "safari": [
+        "5.1"
+      ]
+    }
+  },
+  "version": "0.1.1"
+}
diff --git a/node_modules/console-stream/test/index.js b/node_modules/console-stream/test/index.js
new file mode 100644
index 0000000..5f60123
--- /dev/null
+++ b/node_modules/console-stream/test/index.js
@@ -0,0 +1,83 @@
+var ConsoleStream = require("../index")
+var console = require("console")
+var test = require("tape")
+
+test("console stream", function (assert) {
+    var stream = ConsoleStream()
+
+    assert.ok(stream.write)
+    assert.ok(stream.end)
+    assert.ok(stream.destroy)
+
+    assert.end()
+})
+
+test("console stream destroy", function (assert) {
+    var stream = ConsoleStream()
+
+    stream.once("close", function () {
+        assert.ok(true)
+        assert.end()
+    })
+
+    stream.destroy()
+})
+
+test("console stream end", function (assert) {
+    var old = console.log
+    console.log = intercept
+
+    var closed = false
+    var stream = ConsoleStream()
+    var list = []
+
+    stream.once("close", function () {
+        closed = true
+
+        console.log = old
+
+        assert.deepEqual(list, ["foo"])
+        assert.equal(closed, true)
+
+        assert.end()
+    })
+
+    stream.end("foo")
+
+    function intercept(chunk) {
+        list.push(chunk)
+
+        // old.apply(this, arguments)
+    }
+})
+
+test("console stream write", function (assert) {
+    var old = console.log
+    console.log = intercept
+
+    var list = []
+    var stream = ConsoleStream()
+
+    stream.write("one")
+    stream.write("two")
+    stream.write("three")
+    stream.write("four\n")
+    stream.write("five\na")
+    stream.write("bar")
+    stream.end()
+
+    console.log = old
+
+    assert.deepEqual(list, [
+        "onetwothreefour"
+        , "five"
+        , "abar"
+    ])
+    assert.end()
+
+    function intercept(chunk) {
+        list.push(chunk)
+
+        // old.apply(this, arguments)
+    }
+})
diff --git a/node_modules/console-stream/test/static/index.html b/node_modules/console-stream/test/static/index.html
new file mode 100644
index 0000000..60f6ef8
--- /dev/null
+++ b/node_modules/console-stream/test/static/index.html
@@ -0,0 +1,11 @@
+<!doctype html>
+<html>
+<head>
+    <title>TAPE Example</title>
+    <script src="/testem.js"></script>
+    <script src="test-adapter.js"></script>
+    <script src="bundle.js"></script>
+</head>
+<body>
+</body>
+</html>
diff --git a/node_modules/console-stream/test/static/test-adapter.js b/node_modules/console-stream/test/static/test-adapter.js
new file mode 100644
index 0000000..8b4c12d
--- /dev/null
+++ b/node_modules/console-stream/test/static/test-adapter.js
@@ -0,0 +1,53 @@
+(function () {
+    var Testem = window.Testem
+    var regex = /^((?:not )?ok) (\d+) (.+)$/
+
+    Testem.useCustomAdapter(tapAdapter)
+
+    function tapAdapter(socket){
+        var results = {
+            failed: 0
+            , passed: 0
+            , total: 0
+            , tests: []
+        }
+
+        socket.emit('tests-start')
+
+        Testem.handleConsoleMessage = function(msg){
+            var m = msg.match(regex)
+            if (m) {
+                var passed = m[1] === 'ok'
+                var test = {
+                    passed: passed ? 1 : 0,
+                    failed: passed ? 0 : 1,
+                    total: 1,
+                    id: m[2],
+                    name: m[3],
+                    items: []
+                }
+
+                if (passed) {
+                    results.passed++
+                } else {
+                    console.error("failure", m)
+
+                    results.failed++
+                }
+
+                results.total++
+
+                // console.log("emitted test", test)
+                socket.emit('test-result', test)
+                results.tests.push(test)
+            } else if (msg === '# ok' || msg.match(/^# tests \d+/)){
+                // console.log("emitted all test")
+                socket.emit('all-test-results', results)
+            }
+
+            // return false if you want to prevent the console message from
+            // going to the console
+            // return false
+        }
+    }
+}())