vulcan 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/vulcan/cli.rb +20 -10
- data/lib/vulcan/version.rb +1 -1
- data/server/Procfile +1 -1
- data/server/bin/web +10 -0
- data/server/lib/cloudant.coffee +20 -0
- data/server/lib/logger.coffee +17 -0
- data/server/lib/on.coffee +10 -0
- data/server/lib/spawner.coffee +65 -0
- data/server/node_modules/coffee-script/CNAME +1 -0
- data/server/node_modules/coffee-script/LICENSE +22 -0
- data/server/node_modules/coffee-script/README +51 -0
- data/server/node_modules/coffee-script/Rakefile +78 -0
- data/server/node_modules/coffee-script/bin/cake +7 -0
- data/server/node_modules/coffee-script/bin/coffee +7 -0
- data/server/node_modules/coffee-script/extras/jsl.conf +44 -0
- data/server/node_modules/coffee-script/lib/coffee-script/browser.js +92 -0
- data/server/node_modules/coffee-script/lib/coffee-script/cake.js +111 -0
- data/server/node_modules/coffee-script/lib/coffee-script/coffee-script.js +167 -0
- data/server/node_modules/coffee-script/lib/coffee-script/command.js +500 -0
- data/server/node_modules/coffee-script/lib/coffee-script/grammar.js +606 -0
- data/server/node_modules/coffee-script/lib/coffee-script/helpers.js +77 -0
- data/server/node_modules/coffee-script/lib/coffee-script/index.js +11 -0
- data/server/node_modules/coffee-script/lib/coffee-script/lexer.js +788 -0
- data/server/node_modules/coffee-script/lib/coffee-script/nodes.js +2986 -0
- data/server/node_modules/coffee-script/lib/coffee-script/optparse.js +138 -0
- data/server/node_modules/coffee-script/lib/coffee-script/parser.js +683 -0
- data/server/node_modules/coffee-script/lib/coffee-script/repl.js +261 -0
- data/server/node_modules/coffee-script/lib/coffee-script/rewriter.js +349 -0
- data/server/node_modules/coffee-script/lib/coffee-script/scope.js +146 -0
- data/server/node_modules/coffee-script/package.json +55 -0
- data/server/node_modules/connect-form/History.md +0 -6
- data/server/node_modules/connect-form/lib/connect-form.js +2 -4
- data/server/node_modules/connect-form/node_modules/formidable/Readme.md +64 -36
- data/server/node_modules/connect-form/node_modules/formidable/lib/incoming_form.js +5 -1
- data/server/node_modules/connect-form/node_modules/formidable/package.json +20 -6
- data/server/node_modules/connect-form/node_modules/formidable/test/common.js +5 -6
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/file/funkyfilename.txt +1 -0
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/js/special-chars-in-filename.js +1 -1
- data/server/node_modules/connect-form/node_modules/formidable/test/{slow → integration}/test-fixtures.js +38 -33
- data/server/node_modules/connect-form/node_modules/formidable/test/legacy/simple/test-incoming-form.js +11 -0
- data/server/node_modules/connect-form/node_modules/formidable/test/run.js +1 -6
- data/server/node_modules/connect-form/node_modules/formidable/test/unit/test-incoming-form.js +63 -0
- data/server/node_modules/connect-form/package.json +27 -5
- data/server/node_modules/cradle/README.md +10 -10
- data/server/node_modules/cradle/lib/cradle.js +117 -523
- data/server/node_modules/cradle/lib/cradle/database/attachments.js +120 -0
- data/server/node_modules/cradle/lib/cradle/database/changes.js +56 -0
- data/server/node_modules/cradle/lib/cradle/database/documents.js +215 -0
- data/server/node_modules/cradle/lib/cradle/database/index.js +65 -0
- data/server/node_modules/cradle/lib/cradle/database/views.js +125 -0
- data/server/node_modules/cradle/node_modules/follow/LICENSE +202 -0
- data/server/node_modules/cradle/node_modules/follow/README.md +164 -0
- data/server/node_modules/cradle/node_modules/follow/Rakefile +54 -0
- data/server/node_modules/cradle/node_modules/follow/api.js +35 -0
- data/server/node_modules/cradle/node_modules/follow/browser/eventemitter2.js +453 -0
- data/server/node_modules/cradle/node_modules/follow/browser/export.js +78 -0
- data/server/node_modules/cradle/node_modules/follow/browser/index.html +14 -0
- data/server/node_modules/cradle/node_modules/follow/browser/jquery-1.6.1.min.js +18 -0
- data/server/node_modules/cradle/node_modules/follow/browser/log4js.js +46 -0
- data/server/node_modules/cradle/node_modules/follow/browser/main.js +92 -0
- data/server/node_modules/cradle/node_modules/follow/browser/querystring.js +28 -0
- data/server/node_modules/cradle/node_modules/follow/browser/request.jquery.js +237 -0
- data/server/node_modules/cradle/node_modules/follow/browser/require.js +33 -0
- data/server/node_modules/cradle/node_modules/follow/browser/util.js +28 -0
- data/server/node_modules/cradle/node_modules/follow/cli.js +101 -0
- data/server/node_modules/cradle/node_modules/follow/lib/feed.js +556 -0
- data/server/node_modules/cradle/node_modules/follow/lib/index.js +66 -0
- data/server/node_modules/cradle/node_modules/follow/lib/stream.js +305 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/LICENSE +55 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/README.md +285 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/main.js +618 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/mimetypes.js +146 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/oauth.js +34 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/package.json +42 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/googledoodle.png +0 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/run.sh +6 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/server.js +57 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-body.js +90 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-cookie.js +29 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-cookiejar.js +90 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-errors.js +30 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-oauth.js +109 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-pipes.js +167 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-proxy.js +39 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-timeout.js +87 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/uuid.js +19 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/vendor/cookie/index.js +55 -0
- data/server/node_modules/cradle/node_modules/follow/node_modules/request/vendor/cookie/jar.js +72 -0
- data/server/node_modules/cradle/node_modules/follow/package.json +45 -0
- data/server/node_modules/cradle/node_modules/follow/test/couch.js +153 -0
- data/server/node_modules/cradle/node_modules/follow/test/follow.js +136 -0
- data/server/node_modules/cradle/node_modules/follow/test/issues.js +178 -0
- data/server/node_modules/cradle/node_modules/follow/test/issues/10.js +24 -0
- data/server/node_modules/cradle/node_modules/follow/test/stream.js +493 -0
- data/server/node_modules/cradle/node_modules/request/LICENSE +55 -0
- data/server/node_modules/cradle/node_modules/request/README.md +287 -0
- data/server/node_modules/cradle/node_modules/request/forever.js +103 -0
- data/server/node_modules/cradle/node_modules/request/main.js +913 -0
- data/server/node_modules/cradle/node_modules/request/mimetypes.js +152 -0
- data/server/node_modules/cradle/node_modules/request/oauth.js +34 -0
- data/server/node_modules/cradle/node_modules/request/package.json +42 -0
- data/server/node_modules/cradle/node_modules/request/tests/googledoodle.png +0 -0
- data/server/node_modules/cradle/node_modules/request/tests/run.js +38 -0
- data/server/node_modules/cradle/node_modules/request/tests/server.js +82 -0
- data/server/node_modules/cradle/node_modules/request/tests/squid.conf +77 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.cnf +20 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.crl +0 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.crt +17 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.csr +13 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.key +18 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.srl +1 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.cnf +19 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.crt +16 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.csr +11 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.js +28 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.key +9 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/npm-ca.crt +16 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/test.crt +15 -0
- data/server/node_modules/cradle/node_modules/request/tests/ssl/test.key +15 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-body.js +95 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-cookie.js +29 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-cookiejar.js +90 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-defaults.js +68 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-errors.js +37 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-headers.js +52 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-httpModule.js +94 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-https-strict.js +97 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-https.js +86 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-oauth.js +117 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-params.js +92 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-pipes.js +202 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-proxy.js +39 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-qs.js +28 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-redirect.js +154 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-timeout.js +87 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-toJSON.js +14 -0
- data/server/node_modules/cradle/node_modules/request/tests/test-tunnel.js +61 -0
- data/server/node_modules/cradle/node_modules/request/tunnel.js +229 -0
- data/server/node_modules/cradle/node_modules/request/uuid.js +19 -0
- data/server/node_modules/cradle/node_modules/request/vendor/cookie/index.js +65 -0
- data/server/node_modules/cradle/node_modules/request/vendor/cookie/jar.js +72 -0
- data/server/node_modules/cradle/node_modules/vargs/package.json +33 -10
- data/server/node_modules/cradle/package.json +50 -12
- data/server/node_modules/cradle/test/cache-test.js +1 -4
- data/server/node_modules/cradle/test/connection-test.js +179 -0
- data/server/node_modules/cradle/test/database-attachment-test.js +344 -0
- data/server/node_modules/cradle/test/database-cache-test.js +132 -0
- data/server/node_modules/cradle/test/database-test.js +219 -0
- data/server/node_modules/cradle/test/database-view-test.js +141 -0
- data/server/node_modules/cradle/test/fixtures/databases.json +28 -1
- data/server/node_modules/cradle/test/helpers/seed.js +14 -5
- data/server/node_modules/cradle/test/response-test.js +1 -1
- data/server/node_modules/express/History.md +16 -0
- data/server/node_modules/express/bin/express +7 -6
- data/server/node_modules/express/lib-cov/application.js +510 -0
- data/server/node_modules/express/lib-cov/express.js +65 -0
- data/server/node_modules/express/lib-cov/middleware.js +54 -0
- data/server/node_modules/express/lib-cov/request.js +225 -0
- data/server/node_modules/express/lib-cov/response.js +611 -0
- data/server/node_modules/express/lib-cov/router/collection.js +40 -0
- data/server/node_modules/express/lib-cov/router/index.js +515 -0
- data/server/node_modules/express/lib-cov/router/methods.js +9 -0
- data/server/node_modules/express/lib-cov/router/route.js +68 -0
- data/server/node_modules/express/lib-cov/utils.js +151 -0
- data/server/node_modules/express/lib-cov/view.js +81 -0
- data/server/node_modules/express/lib/express.js +1 -1
- data/server/node_modules/express/lib/http.js +1 -2
- data/server/node_modules/express/lib/request.js +2 -2
- data/server/node_modules/express/lib/router/methods.js +10 -1
- data/server/node_modules/express/node_modules/connect/lib/connect.js +1 -1
- data/server/node_modules/express/node_modules/connect/lib/http.js +3 -2
- data/server/node_modules/express/node_modules/connect/lib/middleware/limit.js +0 -2
- data/server/node_modules/express/node_modules/connect/lib/middleware/session.js +1 -2
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/Readme.md +42 -25
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/incoming_form.js +1 -0
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/package.json +14 -3
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-incoming-form.js +11 -0
- data/server/node_modules/express/node_modules/connect/package.json +35 -7
- data/server/node_modules/express/node_modules/mime/package.json +30 -8
- data/server/node_modules/express/node_modules/mkdirp/README.markdown +35 -2
- data/server/node_modules/express/node_modules/mkdirp/examples/pow.js +1 -1
- data/server/node_modules/express/node_modules/mkdirp/index.js +72 -13
- data/server/node_modules/express/node_modules/mkdirp/package.json +39 -21
- data/server/node_modules/express/node_modules/mkdirp/test/chmod.js +38 -0
- data/server/node_modules/express/node_modules/mkdirp/test/clobber.js +37 -0
- data/server/node_modules/express/node_modules/mkdirp/test/perm.js +32 -0
- data/server/node_modules/express/node_modules/mkdirp/test/perm_sync.js +39 -0
- data/server/node_modules/express/node_modules/mkdirp/test/sync.js +27 -0
- data/server/node_modules/express/node_modules/mkdirp/test/umask.js +28 -0
- data/server/node_modules/express/node_modules/mkdirp/test/umask_sync.js +27 -0
- data/server/node_modules/express/node_modules/qs/History.md +10 -0
- data/server/node_modules/express/node_modules/qs/Readme.md +9 -2
- data/server/node_modules/express/node_modules/qs/examples.js +3 -0
- data/server/node_modules/express/node_modules/qs/lib/querystring.js +8 -6
- data/server/node_modules/express/node_modules/qs/package.json +26 -8
- data/server/node_modules/express/node_modules/qs/test/parse.js +13 -1
- data/server/node_modules/express/node_modules/qs/test/stringify.js +45 -37
- data/server/node_modules/express/package.json +55 -16
- data/server/node_modules/express/test.js +41 -0
- data/server/node_modules/knox/package.json +26 -4
- data/server/node_modules/node-uuid/package.json +40 -11
- data/server/node_modules/node-uuid/test/test.js +1 -1
- data/server/node_modules/nodemon/README.md +120 -0
- data/server/node_modules/nodemon/nodemon.js +518 -0
- data/server/node_modules/nodemon/nodemonignore.example +11 -0
- data/server/node_modules/nodemon/package.json +49 -0
- data/server/node_modules/restler/README.md +144 -94
- data/server/node_modules/restler/lib/multipartform.js +2 -0
- data/server/node_modules/restler/lib/restler.js +218 -61
- data/server/node_modules/restler/package.json +35 -8
- data/server/node_modules/restler/test/all.js +6 -1
- data/server/node_modules/restler/test/restler.js +624 -118
- data/server/package.json +14 -10
- data/server/web.coffee +64 -0
- data/server/web.js +15 -3
- metadata +170 -57
- data/server/index.js +0 -14
- data/server/node_modules/connect-form/LICENSE +0 -22
- data/server/node_modules/connect-form/index.js +0 -100
- data/server/node_modules/connect-form/node_modules/formidable/test/fast/test-incoming-form.js +0 -45
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/no-filename/generic.http +0 -13
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +0 -26
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http +0 -24
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-safari-5.http +0 -23
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +0 -24
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-7.http +0 -22
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-8.http +0 -22
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-safari-5.http +0 -22
- data/server/node_modules/connect-form/node_modules/formidable/test/fixture/multi_video.upload +0 -0
- data/server/node_modules/cradle/Makefile +0 -10
- data/server/node_modules/cradle/test/cradle-test.js +0 -650
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/no-filename/generic.http +0 -13
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +0 -26
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http +0 -24
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-safari-5.http +0 -23
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +0 -24
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-7.http +0 -22
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-8.http +0 -22
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-safari-5.http +0 -22
- data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multi_video.upload +0 -0
- data/server/node_modules/express/node_modules/connect/test.js +0 -52
- data/server/node_modules/express/testing/foo/app.js +0 -35
- data/server/node_modules/express/testing/foo/package.json +0 -9
- data/server/node_modules/express/testing/foo/public/stylesheets/style.css +0 -8
- data/server/node_modules/express/testing/foo/routes/index.js +0 -10
- data/server/node_modules/express/testing/foo/views/index.jade +0 -2
- data/server/node_modules/express/testing/foo/views/layout.jade +0 -6
- data/server/node_modules/express/testing/index.js +0 -43
- data/server/node_modules/express/testing/public/test.txt +0 -2971
- data/server/node_modules/express/testing/views/page.html +0 -1
- data/server/node_modules/express/testing/views/page.jade +0 -3
- data/server/node_modules/express/testing/views/test.md +0 -1
- data/server/node_modules/express/testing/views/user/index.jade +0 -1
- data/server/node_modules/express/testing/views/user/list.jade +0 -1
- data/server/node_modules/knox/lib/knox/mime/index.js +0 -308
- data/server/node_modules/knox/lib/knox/mime/test.js +0 -59
- data/server/node_modules/node-uuid/test/benchmark-native +0 -0
- data/server/node_modules/on/index.js +0 -13
- data/server/node_modules/restler/test/test_helper.js +0 -163
- data/server/node_modules/spawner/index.js +0 -106
data/server/node_modules/cradle/node_modules/follow/node_modules/request/vendor/cookie/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Tobi - Cookie
|
|
3
|
+
* Copyright(c) 2010 LearnBoost <dev@learnboost.com>
|
|
4
|
+
* MIT Licensed
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Module dependencies.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
var url = require('url');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Initialize a new `Cookie` with the given cookie `str` and `req`.
|
|
15
|
+
*
|
|
16
|
+
* @param {String} str
|
|
17
|
+
* @param {IncomingRequest} req
|
|
18
|
+
* @api private
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
var Cookie = exports = module.exports = function Cookie(str, req) {
|
|
22
|
+
this.str = str;
|
|
23
|
+
|
|
24
|
+
// First key is the name
|
|
25
|
+
this.name = str.substr(0, str.indexOf('='));
|
|
26
|
+
|
|
27
|
+
// Map the key/val pairs
|
|
28
|
+
str.split(/ *; */).reduce(function(obj, pair){
|
|
29
|
+
pair = pair.split(/ *= */);
|
|
30
|
+
obj[pair[0].toLowerCase()] = pair[1] || true;
|
|
31
|
+
return obj;
|
|
32
|
+
}, this);
|
|
33
|
+
|
|
34
|
+
// Assign value
|
|
35
|
+
this.value = this[this.name];
|
|
36
|
+
|
|
37
|
+
// Expires
|
|
38
|
+
this.expires = this.expires
|
|
39
|
+
? new Date(this.expires)
|
|
40
|
+
: Infinity;
|
|
41
|
+
|
|
42
|
+
// Default or trim path
|
|
43
|
+
this.path = this.path || '/';
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Return the original cookie string.
|
|
48
|
+
*
|
|
49
|
+
* @return {String}
|
|
50
|
+
* @api public
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
Cookie.prototype.toString = function(){
|
|
54
|
+
return this.str;
|
|
55
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Tobi - CookieJar
|
|
3
|
+
* Copyright(c) 2010 LearnBoost <dev@learnboost.com>
|
|
4
|
+
* MIT Licensed
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Module dependencies.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
var url = require('url');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Initialize a new `CookieJar`.
|
|
15
|
+
*
|
|
16
|
+
* @api private
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
var CookieJar = exports = module.exports = function CookieJar() {
|
|
20
|
+
this.cookies = [];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Add the given `cookie` to the jar.
|
|
25
|
+
*
|
|
26
|
+
* @param {Cookie} cookie
|
|
27
|
+
* @api private
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
CookieJar.prototype.add = function(cookie){
|
|
31
|
+
this.cookies = this.cookies.filter(function(c){
|
|
32
|
+
// Avoid duplication (same path, same name)
|
|
33
|
+
return !(c.name == cookie.name && c.path == cookie.path);
|
|
34
|
+
});
|
|
35
|
+
this.cookies.push(cookie);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Get cookies for the given `req`.
|
|
40
|
+
*
|
|
41
|
+
* @param {IncomingRequest} req
|
|
42
|
+
* @return {Array}
|
|
43
|
+
* @api private
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
CookieJar.prototype.get = function(req){
|
|
47
|
+
var path = url.parse(req.url).pathname
|
|
48
|
+
, now = new Date
|
|
49
|
+
, specificity = {};
|
|
50
|
+
return this.cookies.filter(function(cookie){
|
|
51
|
+
if (0 == path.indexOf(cookie.path) && now < cookie.expires
|
|
52
|
+
&& cookie.path.length > (specificity[cookie.name] || 0))
|
|
53
|
+
return specificity[cookie.name] = cookie.path.length;
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Return Cookie string for the given `req`.
|
|
59
|
+
*
|
|
60
|
+
* @param {IncomingRequest} req
|
|
61
|
+
* @return {String}
|
|
62
|
+
* @api private
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
CookieJar.prototype.cookieString = function(req){
|
|
66
|
+
var cookies = this.get(req);
|
|
67
|
+
if (cookies.length) {
|
|
68
|
+
return cookies.map(function(cookie){
|
|
69
|
+
return cookie.name + '=' + cookie.value;
|
|
70
|
+
}).join('; ');
|
|
71
|
+
}
|
|
72
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "follow",
|
|
3
|
+
"version": "0.7.2",
|
|
4
|
+
"author": {
|
|
5
|
+
"name": "Jason Smith",
|
|
6
|
+
"email": "jhs@iriscouch.com"
|
|
7
|
+
},
|
|
8
|
+
"description": "Extremely robust, fault-tolerant CouchDB changes follower",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"couchdb",
|
|
11
|
+
"changes",
|
|
12
|
+
"sleep",
|
|
13
|
+
"sleepy"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "http://github.com/iriscouch/follow",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git://github.com/iriscouch/follow.git"
|
|
19
|
+
},
|
|
20
|
+
"engines": [
|
|
21
|
+
"node"
|
|
22
|
+
],
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"request": "~2.2.5"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"tap": "~0.1.3",
|
|
28
|
+
"traceback": "~0.3.0"
|
|
29
|
+
},
|
|
30
|
+
"main": "./api.js",
|
|
31
|
+
"bin": {
|
|
32
|
+
"follow": "./cli.js"
|
|
33
|
+
},
|
|
34
|
+
"_npmUser": {
|
|
35
|
+
"name": "ddollar",
|
|
36
|
+
"email": "ddollar@gmail.com"
|
|
37
|
+
},
|
|
38
|
+
"_id": "follow@0.7.2",
|
|
39
|
+
"optionalDependencies": {},
|
|
40
|
+
"_engineSupported": true,
|
|
41
|
+
"_npmVersion": "1.1.21",
|
|
42
|
+
"_nodeVersion": "v0.6.17",
|
|
43
|
+
"_defaultsLoaded": true,
|
|
44
|
+
"_from": "follow@0.7.x"
|
|
45
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// CouchDB tests
|
|
2
|
+
//
|
|
3
|
+
// This module is also a library for other test modules.
|
|
4
|
+
|
|
5
|
+
var tap = require('tap')
|
|
6
|
+
, util = require('util')
|
|
7
|
+
, assert = require('assert')
|
|
8
|
+
, request = require('request')
|
|
9
|
+
|
|
10
|
+
var follow = require('../api')
|
|
11
|
+
, DB = process.env.db || 'http://localhost:5984/follow_test'
|
|
12
|
+
, RTT = null
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
module.exports = { 'DB': DB
|
|
16
|
+
, 'rtt' : get_rtt
|
|
17
|
+
, 'redo': redo_couch
|
|
18
|
+
, 'setup': setup_test
|
|
19
|
+
, 'make_data': make_data
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
function get_rtt() {
|
|
24
|
+
if(!RTT)
|
|
25
|
+
throw new Error('RTT was not set. Use setup(test) or redo(callback)')
|
|
26
|
+
return RTT
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
// Basically a redo but testing along the way.
|
|
31
|
+
function setup_test(test_func) {
|
|
32
|
+
assert.equal(typeof test_func, 'function', 'Please provide tap.test function')
|
|
33
|
+
|
|
34
|
+
test_func('Initialize CouchDB', function(t) {
|
|
35
|
+
init_db(t, function(er, rtt) {
|
|
36
|
+
RTT = rtt
|
|
37
|
+
t.end()
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function redo_couch(callback) {
|
|
43
|
+
function noop() {}
|
|
44
|
+
var t = { 'ok':noop, 'false':noop, 'equal':noop, 'end':noop }
|
|
45
|
+
init_db(t, function(er, rtt) {
|
|
46
|
+
if(rtt)
|
|
47
|
+
RTT = rtt
|
|
48
|
+
return callback(er)
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function init_db(t, callback) {
|
|
53
|
+
var create_begin = new Date
|
|
54
|
+
|
|
55
|
+
request.del({uri:DB, json:true}, function(er, res) {
|
|
56
|
+
t.false(er, 'Clear old test DB: ' + DB)
|
|
57
|
+
t.ok(!res.body.error || res.body.error == 'not_found', 'Couch cleared old test DB: ' + DB)
|
|
58
|
+
|
|
59
|
+
request.put({uri:DB, json:true}, function(er, res) {
|
|
60
|
+
t.false(er, 'Create new test DB: ' + DB)
|
|
61
|
+
t.false(res.body.error, 'Couch created new test DB: ' + DB)
|
|
62
|
+
|
|
63
|
+
var values = ['first', 'second', 'third']
|
|
64
|
+
, stores = 0
|
|
65
|
+
values.forEach(function(val) {
|
|
66
|
+
var doc = { _id:'doc_'+val, value:val }
|
|
67
|
+
|
|
68
|
+
request.post({uri:DB, json:doc}, function(er, res) {
|
|
69
|
+
t.false(er, 'POST document')
|
|
70
|
+
t.equal(res.statusCode, 201, 'Couch stored test document')
|
|
71
|
+
|
|
72
|
+
stores += 1
|
|
73
|
+
if(stores == values.length) {
|
|
74
|
+
var rtt = (new Date) - create_begin
|
|
75
|
+
callback(null, rtt)
|
|
76
|
+
//request.post({uri:DB, json:{_id:'_local/rtt', ms:(new Date)-begin}}, function(er, res) {
|
|
77
|
+
// t.false(er, 'Store RTT value')
|
|
78
|
+
// t.equal(res.statusCode, 201, 'Couch stored RTT value')
|
|
79
|
+
// t.end()
|
|
80
|
+
//})
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
function make_data(minimum_size, callback) {
|
|
90
|
+
var payload = {'docs':[]}
|
|
91
|
+
, size = 0
|
|
92
|
+
|
|
93
|
+
// TODO: Make document number 20 really large, at least over 9kb.
|
|
94
|
+
while(size < minimum_size) {
|
|
95
|
+
var doc = {}
|
|
96
|
+
, key_count = rndint(0, 25)
|
|
97
|
+
|
|
98
|
+
while(key_count-- > 0)
|
|
99
|
+
doc[rndstr(8)] = rndstr(20)
|
|
100
|
+
|
|
101
|
+
// The 20th document has one really large string value.
|
|
102
|
+
if(payload.docs.length == 19) {
|
|
103
|
+
var big_str = rndstr(9000, 15000)
|
|
104
|
+
doc.big = {'length':big_str.length, 'value':big_str}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
size += JSON.stringify(doc).length // This is an underestimate because an _id and _rev will be added.
|
|
108
|
+
payload.docs.push(doc)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
request.post({'uri':DB+'/_bulk_docs', 'json':payload}, function(er, res) {
|
|
112
|
+
if(er) throw er
|
|
113
|
+
|
|
114
|
+
if(res.statusCode != 201)
|
|
115
|
+
throw new Error('Bad bulk_docs update: ' + util.inspect(res.body))
|
|
116
|
+
|
|
117
|
+
if(res.body.length != payload.docs.length)
|
|
118
|
+
throw new Error('Should have results for '+payload.docs.length+' doc insertions')
|
|
119
|
+
|
|
120
|
+
if(res.body.length < 1500)
|
|
121
|
+
throw new Error('Seems like at least 1,500 docs should have been added: ' + res.body.length)
|
|
122
|
+
|
|
123
|
+
res.body.forEach(function(result) {
|
|
124
|
+
if(!result || !result.id || !result.rev)
|
|
125
|
+
throw new Error('Bad bulk_docs response: ' + util.inspect(result))
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
return callback(payload.docs.length)
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
function rndstr(minlen, maxlen) {
|
|
132
|
+
if(!maxlen) {
|
|
133
|
+
maxlen = minlen
|
|
134
|
+
minlen = 1
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
var str = ""
|
|
138
|
+
, length = rndint(minlen, maxlen)
|
|
139
|
+
|
|
140
|
+
while(length-- > 0)
|
|
141
|
+
str += String.fromCharCode(rndint(97, 122))
|
|
142
|
+
|
|
143
|
+
return str
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function rndint(min, max) {
|
|
147
|
+
return min + Math.floor(Math.random() * (max - min + 1))
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
if(require.main === module)
|
|
153
|
+
setup_test(tap.test)
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
var tap = require('tap')
|
|
2
|
+
, test = tap.test
|
|
3
|
+
, util = require('util')
|
|
4
|
+
, request = require('request')
|
|
5
|
+
|
|
6
|
+
var couch = require('./couch')
|
|
7
|
+
, follow = require('../api')
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
couch.setup(test)
|
|
11
|
+
|
|
12
|
+
test('Follow API', function(t) {
|
|
13
|
+
var i = 0
|
|
14
|
+
, saw = {}
|
|
15
|
+
|
|
16
|
+
var feed = follow(couch.DB, function(er, change) {
|
|
17
|
+
t.is(this, feed, 'Callback "this" value is the feed object')
|
|
18
|
+
|
|
19
|
+
i += 1
|
|
20
|
+
t.false(er, 'No error coming back from follow: ' + i)
|
|
21
|
+
t.equal(change.seq, i, 'Change #'+i+' should have seq_id='+i)
|
|
22
|
+
saw[change.id] = true
|
|
23
|
+
|
|
24
|
+
if(i == 3) {
|
|
25
|
+
t.ok(saw.doc_first, 'Got the first document')
|
|
26
|
+
t.ok(saw.doc_second, 'Got the second document')
|
|
27
|
+
t.ok(saw.doc_third , 'Got the third document')
|
|
28
|
+
|
|
29
|
+
t.doesNotThrow(function() { feed.stop() }, 'No problem calling stop()')
|
|
30
|
+
|
|
31
|
+
t.end()
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
test("Confirmation request behavior", function(t) {
|
|
37
|
+
var feed = follow(couch.DB, function() {})
|
|
38
|
+
|
|
39
|
+
var confirm_req = null
|
|
40
|
+
, follow_req = null
|
|
41
|
+
|
|
42
|
+
feed.on('confirm_request', function(req) { confirm_req = req })
|
|
43
|
+
feed.on('query', function(req) { follow_req = req })
|
|
44
|
+
|
|
45
|
+
setTimeout(check_req, couch.rtt() * 2)
|
|
46
|
+
function check_req() {
|
|
47
|
+
t.ok(confirm_req, 'The confirm_request event should have fired by now')
|
|
48
|
+
t.ok(confirm_req.agent, 'The confirm request has an agent')
|
|
49
|
+
|
|
50
|
+
t.ok(follow_req, 'The follow_request event should have fired by now')
|
|
51
|
+
t.ok(follow_req.agent, 'The follow request has an agent')
|
|
52
|
+
|
|
53
|
+
// Confirm that the changes follower is not still in the pool.
|
|
54
|
+
var host = 'localhost:5984'
|
|
55
|
+
follow_req.req.agent.sockets[host].forEach(function(socket, i) {
|
|
56
|
+
t.isNot(socket, follow_req.req.connection, 'The changes follower is not socket '+i+' in the agent pool')
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
feed.stop()
|
|
60
|
+
t.end()
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
test('Heartbeats', function(t) {
|
|
65
|
+
t.ok(couch.rtt(), 'The couch RTT is known')
|
|
66
|
+
var check_time = couch.rtt() * 3.5 // Enough time for 3 heartbeats.
|
|
67
|
+
|
|
68
|
+
var beats = 0
|
|
69
|
+
, retries = 0
|
|
70
|
+
|
|
71
|
+
var feed = follow(couch.DB, function() {})
|
|
72
|
+
feed.heartbeat = couch.rtt()
|
|
73
|
+
feed.on('response', function() { feed.retry_delay = 1 })
|
|
74
|
+
|
|
75
|
+
feed.on('heartbeat', function() { beats += 1 })
|
|
76
|
+
feed.on('retry', function() { retries += 1 })
|
|
77
|
+
|
|
78
|
+
feed.on('catchup', function() {
|
|
79
|
+
t.equal(beats, 0, 'Still 0 heartbeats after receiving changes')
|
|
80
|
+
t.equal(retries, 0, 'Still 0 retries after receiving changes')
|
|
81
|
+
|
|
82
|
+
//console.error('Waiting ' + couch.rtt() + ' * 3 = ' + check_time + ' to check stuff')
|
|
83
|
+
setTimeout(check_counters, check_time)
|
|
84
|
+
function check_counters() {
|
|
85
|
+
t.equal(beats, 3, 'Three heartbeats ('+couch.rtt()+') fired after '+check_time+' ms')
|
|
86
|
+
t.equal(retries, 0, 'No retries after '+check_time+' ms')
|
|
87
|
+
|
|
88
|
+
feed.stop()
|
|
89
|
+
t.end()
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
test('Events for DB confirmation and hitting the original seq', function(t) {
|
|
95
|
+
var feed = follow(couch.DB, on_change)
|
|
96
|
+
|
|
97
|
+
var events = { 'confirm':null, 'catchup':null }
|
|
98
|
+
feed.on('confirm', function(db) { events.confirm = db })
|
|
99
|
+
feed.on('catchup', function(seq) { events.catchup = seq })
|
|
100
|
+
|
|
101
|
+
function on_change(er, ch) {
|
|
102
|
+
t.false(er, 'No problem with the feed')
|
|
103
|
+
if(ch.seq == 3) {
|
|
104
|
+
t.ok(events.confirm, 'Confirm event fired')
|
|
105
|
+
t.equal(events.confirm && events.confirm.db_name, 'follow_test', 'Confirm event returned the Couch DB object')
|
|
106
|
+
t.equal(events.confirm && events.confirm.update_seq, 3, 'Confirm event got the update_seq right')
|
|
107
|
+
|
|
108
|
+
t.ok(events.catchup, 'Catchup event fired')
|
|
109
|
+
t.equal(events.catchup, 3, 'Catchup event fired on update 3')
|
|
110
|
+
|
|
111
|
+
feed.stop()
|
|
112
|
+
t.end()
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
test('Handle a deleted database', function(t) {
|
|
118
|
+
var feed = follow(couch.DB, function(er, change) {
|
|
119
|
+
if(er)
|
|
120
|
+
return t.equal(er.last_seq, 3, 'Got an error for the deletion event')
|
|
121
|
+
|
|
122
|
+
if(change.seq < 3)
|
|
123
|
+
return
|
|
124
|
+
|
|
125
|
+
t.equal(change.seq, 3, 'Got change number 3')
|
|
126
|
+
|
|
127
|
+
var redo_er
|
|
128
|
+
couch.redo(function(er) { redo_er = er })
|
|
129
|
+
|
|
130
|
+
setTimeout(check_results, couch.rtt() * 2)
|
|
131
|
+
function check_results() {
|
|
132
|
+
t.false(er, 'No problem redoing the couch')
|
|
133
|
+
t.end()
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
})
|