vulcan 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (260) hide show
  1. data/lib/vulcan/cli.rb +20 -10
  2. data/lib/vulcan/version.rb +1 -1
  3. data/server/Procfile +1 -1
  4. data/server/bin/web +10 -0
  5. data/server/lib/cloudant.coffee +20 -0
  6. data/server/lib/logger.coffee +17 -0
  7. data/server/lib/on.coffee +10 -0
  8. data/server/lib/spawner.coffee +65 -0
  9. data/server/node_modules/coffee-script/CNAME +1 -0
  10. data/server/node_modules/coffee-script/LICENSE +22 -0
  11. data/server/node_modules/coffee-script/README +51 -0
  12. data/server/node_modules/coffee-script/Rakefile +78 -0
  13. data/server/node_modules/coffee-script/bin/cake +7 -0
  14. data/server/node_modules/coffee-script/bin/coffee +7 -0
  15. data/server/node_modules/coffee-script/extras/jsl.conf +44 -0
  16. data/server/node_modules/coffee-script/lib/coffee-script/browser.js +92 -0
  17. data/server/node_modules/coffee-script/lib/coffee-script/cake.js +111 -0
  18. data/server/node_modules/coffee-script/lib/coffee-script/coffee-script.js +167 -0
  19. data/server/node_modules/coffee-script/lib/coffee-script/command.js +500 -0
  20. data/server/node_modules/coffee-script/lib/coffee-script/grammar.js +606 -0
  21. data/server/node_modules/coffee-script/lib/coffee-script/helpers.js +77 -0
  22. data/server/node_modules/coffee-script/lib/coffee-script/index.js +11 -0
  23. data/server/node_modules/coffee-script/lib/coffee-script/lexer.js +788 -0
  24. data/server/node_modules/coffee-script/lib/coffee-script/nodes.js +2986 -0
  25. data/server/node_modules/coffee-script/lib/coffee-script/optparse.js +138 -0
  26. data/server/node_modules/coffee-script/lib/coffee-script/parser.js +683 -0
  27. data/server/node_modules/coffee-script/lib/coffee-script/repl.js +261 -0
  28. data/server/node_modules/coffee-script/lib/coffee-script/rewriter.js +349 -0
  29. data/server/node_modules/coffee-script/lib/coffee-script/scope.js +146 -0
  30. data/server/node_modules/coffee-script/package.json +55 -0
  31. data/server/node_modules/connect-form/History.md +0 -6
  32. data/server/node_modules/connect-form/lib/connect-form.js +2 -4
  33. data/server/node_modules/connect-form/node_modules/formidable/Readme.md +64 -36
  34. data/server/node_modules/connect-form/node_modules/formidable/lib/incoming_form.js +5 -1
  35. data/server/node_modules/connect-form/node_modules/formidable/package.json +20 -6
  36. data/server/node_modules/connect-form/node_modules/formidable/test/common.js +5 -6
  37. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/file/funkyfilename.txt +1 -0
  38. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/js/special-chars-in-filename.js +1 -1
  39. data/server/node_modules/connect-form/node_modules/formidable/test/{slow → integration}/test-fixtures.js +38 -33
  40. data/server/node_modules/connect-form/node_modules/formidable/test/legacy/simple/test-incoming-form.js +11 -0
  41. data/server/node_modules/connect-form/node_modules/formidable/test/run.js +1 -6
  42. data/server/node_modules/connect-form/node_modules/formidable/test/unit/test-incoming-form.js +63 -0
  43. data/server/node_modules/connect-form/package.json +27 -5
  44. data/server/node_modules/cradle/README.md +10 -10
  45. data/server/node_modules/cradle/lib/cradle.js +117 -523
  46. data/server/node_modules/cradle/lib/cradle/database/attachments.js +120 -0
  47. data/server/node_modules/cradle/lib/cradle/database/changes.js +56 -0
  48. data/server/node_modules/cradle/lib/cradle/database/documents.js +215 -0
  49. data/server/node_modules/cradle/lib/cradle/database/index.js +65 -0
  50. data/server/node_modules/cradle/lib/cradle/database/views.js +125 -0
  51. data/server/node_modules/cradle/node_modules/follow/LICENSE +202 -0
  52. data/server/node_modules/cradle/node_modules/follow/README.md +164 -0
  53. data/server/node_modules/cradle/node_modules/follow/Rakefile +54 -0
  54. data/server/node_modules/cradle/node_modules/follow/api.js +35 -0
  55. data/server/node_modules/cradle/node_modules/follow/browser/eventemitter2.js +453 -0
  56. data/server/node_modules/cradle/node_modules/follow/browser/export.js +78 -0
  57. data/server/node_modules/cradle/node_modules/follow/browser/index.html +14 -0
  58. data/server/node_modules/cradle/node_modules/follow/browser/jquery-1.6.1.min.js +18 -0
  59. data/server/node_modules/cradle/node_modules/follow/browser/log4js.js +46 -0
  60. data/server/node_modules/cradle/node_modules/follow/browser/main.js +92 -0
  61. data/server/node_modules/cradle/node_modules/follow/browser/querystring.js +28 -0
  62. data/server/node_modules/cradle/node_modules/follow/browser/request.jquery.js +237 -0
  63. data/server/node_modules/cradle/node_modules/follow/browser/require.js +33 -0
  64. data/server/node_modules/cradle/node_modules/follow/browser/util.js +28 -0
  65. data/server/node_modules/cradle/node_modules/follow/cli.js +101 -0
  66. data/server/node_modules/cradle/node_modules/follow/lib/feed.js +556 -0
  67. data/server/node_modules/cradle/node_modules/follow/lib/index.js +66 -0
  68. data/server/node_modules/cradle/node_modules/follow/lib/stream.js +305 -0
  69. data/server/node_modules/cradle/node_modules/follow/node_modules/request/LICENSE +55 -0
  70. data/server/node_modules/cradle/node_modules/follow/node_modules/request/README.md +285 -0
  71. data/server/node_modules/cradle/node_modules/follow/node_modules/request/main.js +618 -0
  72. data/server/node_modules/cradle/node_modules/follow/node_modules/request/mimetypes.js +146 -0
  73. data/server/node_modules/cradle/node_modules/follow/node_modules/request/oauth.js +34 -0
  74. data/server/node_modules/cradle/node_modules/follow/node_modules/request/package.json +42 -0
  75. data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/googledoodle.png +0 -0
  76. data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/run.sh +6 -0
  77. data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/server.js +57 -0
  78. data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-body.js +90 -0
  79. data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-cookie.js +29 -0
  80. data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-cookiejar.js +90 -0
  81. data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-errors.js +30 -0
  82. data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-oauth.js +109 -0
  83. data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-pipes.js +167 -0
  84. data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-proxy.js +39 -0
  85. data/server/node_modules/cradle/node_modules/follow/node_modules/request/tests/test-timeout.js +87 -0
  86. data/server/node_modules/cradle/node_modules/follow/node_modules/request/uuid.js +19 -0
  87. data/server/node_modules/cradle/node_modules/follow/node_modules/request/vendor/cookie/index.js +55 -0
  88. data/server/node_modules/cradle/node_modules/follow/node_modules/request/vendor/cookie/jar.js +72 -0
  89. data/server/node_modules/cradle/node_modules/follow/package.json +45 -0
  90. data/server/node_modules/cradle/node_modules/follow/test/couch.js +153 -0
  91. data/server/node_modules/cradle/node_modules/follow/test/follow.js +136 -0
  92. data/server/node_modules/cradle/node_modules/follow/test/issues.js +178 -0
  93. data/server/node_modules/cradle/node_modules/follow/test/issues/10.js +24 -0
  94. data/server/node_modules/cradle/node_modules/follow/test/stream.js +493 -0
  95. data/server/node_modules/cradle/node_modules/request/LICENSE +55 -0
  96. data/server/node_modules/cradle/node_modules/request/README.md +287 -0
  97. data/server/node_modules/cradle/node_modules/request/forever.js +103 -0
  98. data/server/node_modules/cradle/node_modules/request/main.js +913 -0
  99. data/server/node_modules/cradle/node_modules/request/mimetypes.js +152 -0
  100. data/server/node_modules/cradle/node_modules/request/oauth.js +34 -0
  101. data/server/node_modules/cradle/node_modules/request/package.json +42 -0
  102. data/server/node_modules/cradle/node_modules/request/tests/googledoodle.png +0 -0
  103. data/server/node_modules/cradle/node_modules/request/tests/run.js +38 -0
  104. data/server/node_modules/cradle/node_modules/request/tests/server.js +82 -0
  105. data/server/node_modules/cradle/node_modules/request/tests/squid.conf +77 -0
  106. data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.cnf +20 -0
  107. data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.crl +0 -0
  108. data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.crt +17 -0
  109. data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.csr +13 -0
  110. data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.key +18 -0
  111. data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/ca.srl +1 -0
  112. data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.cnf +19 -0
  113. data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.crt +16 -0
  114. data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.csr +11 -0
  115. data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.js +28 -0
  116. data/server/node_modules/cradle/node_modules/request/tests/ssl/ca/server.key +9 -0
  117. data/server/node_modules/cradle/node_modules/request/tests/ssl/npm-ca.crt +16 -0
  118. data/server/node_modules/cradle/node_modules/request/tests/ssl/test.crt +15 -0
  119. data/server/node_modules/cradle/node_modules/request/tests/ssl/test.key +15 -0
  120. data/server/node_modules/cradle/node_modules/request/tests/test-body.js +95 -0
  121. data/server/node_modules/cradle/node_modules/request/tests/test-cookie.js +29 -0
  122. data/server/node_modules/cradle/node_modules/request/tests/test-cookiejar.js +90 -0
  123. data/server/node_modules/cradle/node_modules/request/tests/test-defaults.js +68 -0
  124. data/server/node_modules/cradle/node_modules/request/tests/test-errors.js +37 -0
  125. data/server/node_modules/cradle/node_modules/request/tests/test-headers.js +52 -0
  126. data/server/node_modules/cradle/node_modules/request/tests/test-httpModule.js +94 -0
  127. data/server/node_modules/cradle/node_modules/request/tests/test-https-strict.js +97 -0
  128. data/server/node_modules/cradle/node_modules/request/tests/test-https.js +86 -0
  129. data/server/node_modules/cradle/node_modules/request/tests/test-oauth.js +117 -0
  130. data/server/node_modules/cradle/node_modules/request/tests/test-params.js +92 -0
  131. data/server/node_modules/cradle/node_modules/request/tests/test-pipes.js +202 -0
  132. data/server/node_modules/cradle/node_modules/request/tests/test-proxy.js +39 -0
  133. data/server/node_modules/cradle/node_modules/request/tests/test-qs.js +28 -0
  134. data/server/node_modules/cradle/node_modules/request/tests/test-redirect.js +154 -0
  135. data/server/node_modules/cradle/node_modules/request/tests/test-timeout.js +87 -0
  136. data/server/node_modules/cradle/node_modules/request/tests/test-toJSON.js +14 -0
  137. data/server/node_modules/cradle/node_modules/request/tests/test-tunnel.js +61 -0
  138. data/server/node_modules/cradle/node_modules/request/tunnel.js +229 -0
  139. data/server/node_modules/cradle/node_modules/request/uuid.js +19 -0
  140. data/server/node_modules/cradle/node_modules/request/vendor/cookie/index.js +65 -0
  141. data/server/node_modules/cradle/node_modules/request/vendor/cookie/jar.js +72 -0
  142. data/server/node_modules/cradle/node_modules/vargs/package.json +33 -10
  143. data/server/node_modules/cradle/package.json +50 -12
  144. data/server/node_modules/cradle/test/cache-test.js +1 -4
  145. data/server/node_modules/cradle/test/connection-test.js +179 -0
  146. data/server/node_modules/cradle/test/database-attachment-test.js +344 -0
  147. data/server/node_modules/cradle/test/database-cache-test.js +132 -0
  148. data/server/node_modules/cradle/test/database-test.js +219 -0
  149. data/server/node_modules/cradle/test/database-view-test.js +141 -0
  150. data/server/node_modules/cradle/test/fixtures/databases.json +28 -1
  151. data/server/node_modules/cradle/test/helpers/seed.js +14 -5
  152. data/server/node_modules/cradle/test/response-test.js +1 -1
  153. data/server/node_modules/express/History.md +16 -0
  154. data/server/node_modules/express/bin/express +7 -6
  155. data/server/node_modules/express/lib-cov/application.js +510 -0
  156. data/server/node_modules/express/lib-cov/express.js +65 -0
  157. data/server/node_modules/express/lib-cov/middleware.js +54 -0
  158. data/server/node_modules/express/lib-cov/request.js +225 -0
  159. data/server/node_modules/express/lib-cov/response.js +611 -0
  160. data/server/node_modules/express/lib-cov/router/collection.js +40 -0
  161. data/server/node_modules/express/lib-cov/router/index.js +515 -0
  162. data/server/node_modules/express/lib-cov/router/methods.js +9 -0
  163. data/server/node_modules/express/lib-cov/router/route.js +68 -0
  164. data/server/node_modules/express/lib-cov/utils.js +151 -0
  165. data/server/node_modules/express/lib-cov/view.js +81 -0
  166. data/server/node_modules/express/lib/express.js +1 -1
  167. data/server/node_modules/express/lib/http.js +1 -2
  168. data/server/node_modules/express/lib/request.js +2 -2
  169. data/server/node_modules/express/lib/router/methods.js +10 -1
  170. data/server/node_modules/express/node_modules/connect/lib/connect.js +1 -1
  171. data/server/node_modules/express/node_modules/connect/lib/http.js +3 -2
  172. data/server/node_modules/express/node_modules/connect/lib/middleware/limit.js +0 -2
  173. data/server/node_modules/express/node_modules/connect/lib/middleware/session.js +1 -2
  174. data/server/node_modules/express/node_modules/connect/node_modules/formidable/Readme.md +42 -25
  175. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/incoming_form.js +1 -0
  176. data/server/node_modules/express/node_modules/connect/node_modules/formidable/package.json +14 -3
  177. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-incoming-form.js +11 -0
  178. data/server/node_modules/express/node_modules/connect/package.json +35 -7
  179. data/server/node_modules/express/node_modules/mime/package.json +30 -8
  180. data/server/node_modules/express/node_modules/mkdirp/README.markdown +35 -2
  181. data/server/node_modules/express/node_modules/mkdirp/examples/pow.js +1 -1
  182. data/server/node_modules/express/node_modules/mkdirp/index.js +72 -13
  183. data/server/node_modules/express/node_modules/mkdirp/package.json +39 -21
  184. data/server/node_modules/express/node_modules/mkdirp/test/chmod.js +38 -0
  185. data/server/node_modules/express/node_modules/mkdirp/test/clobber.js +37 -0
  186. data/server/node_modules/express/node_modules/mkdirp/test/perm.js +32 -0
  187. data/server/node_modules/express/node_modules/mkdirp/test/perm_sync.js +39 -0
  188. data/server/node_modules/express/node_modules/mkdirp/test/sync.js +27 -0
  189. data/server/node_modules/express/node_modules/mkdirp/test/umask.js +28 -0
  190. data/server/node_modules/express/node_modules/mkdirp/test/umask_sync.js +27 -0
  191. data/server/node_modules/express/node_modules/qs/History.md +10 -0
  192. data/server/node_modules/express/node_modules/qs/Readme.md +9 -2
  193. data/server/node_modules/express/node_modules/qs/examples.js +3 -0
  194. data/server/node_modules/express/node_modules/qs/lib/querystring.js +8 -6
  195. data/server/node_modules/express/node_modules/qs/package.json +26 -8
  196. data/server/node_modules/express/node_modules/qs/test/parse.js +13 -1
  197. data/server/node_modules/express/node_modules/qs/test/stringify.js +45 -37
  198. data/server/node_modules/express/package.json +55 -16
  199. data/server/node_modules/express/test.js +41 -0
  200. data/server/node_modules/knox/package.json +26 -4
  201. data/server/node_modules/node-uuid/package.json +40 -11
  202. data/server/node_modules/node-uuid/test/test.js +1 -1
  203. data/server/node_modules/nodemon/README.md +120 -0
  204. data/server/node_modules/nodemon/nodemon.js +518 -0
  205. data/server/node_modules/nodemon/nodemonignore.example +11 -0
  206. data/server/node_modules/nodemon/package.json +49 -0
  207. data/server/node_modules/restler/README.md +144 -94
  208. data/server/node_modules/restler/lib/multipartform.js +2 -0
  209. data/server/node_modules/restler/lib/restler.js +218 -61
  210. data/server/node_modules/restler/package.json +35 -8
  211. data/server/node_modules/restler/test/all.js +6 -1
  212. data/server/node_modules/restler/test/restler.js +624 -118
  213. data/server/package.json +14 -10
  214. data/server/web.coffee +64 -0
  215. data/server/web.js +15 -3
  216. metadata +170 -57
  217. data/server/index.js +0 -14
  218. data/server/node_modules/connect-form/LICENSE +0 -22
  219. data/server/node_modules/connect-form/index.js +0 -100
  220. data/server/node_modules/connect-form/node_modules/formidable/test/fast/test-incoming-form.js +0 -45
  221. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/no-filename/generic.http +0 -13
  222. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +0 -26
  223. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-firefox-3.6.http +0 -24
  224. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-safari-5.http +0 -23
  225. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +0 -24
  226. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-7.http +0 -22
  227. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-8.http +0 -22
  228. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-safari-5.http +0 -22
  229. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/multi_video.upload +0 -0
  230. data/server/node_modules/cradle/Makefile +0 -10
  231. data/server/node_modules/cradle/test/cradle-test.js +0 -650
  232. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/no-filename/generic.http +0 -13
  233. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +0 -26
  234. 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
  235. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-safari-5.http +0 -23
  236. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +0 -24
  237. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-7.http +0 -22
  238. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-8.http +0 -22
  239. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-safari-5.http +0 -22
  240. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multi_video.upload +0 -0
  241. data/server/node_modules/express/node_modules/connect/test.js +0 -52
  242. data/server/node_modules/express/testing/foo/app.js +0 -35
  243. data/server/node_modules/express/testing/foo/package.json +0 -9
  244. data/server/node_modules/express/testing/foo/public/stylesheets/style.css +0 -8
  245. data/server/node_modules/express/testing/foo/routes/index.js +0 -10
  246. data/server/node_modules/express/testing/foo/views/index.jade +0 -2
  247. data/server/node_modules/express/testing/foo/views/layout.jade +0 -6
  248. data/server/node_modules/express/testing/index.js +0 -43
  249. data/server/node_modules/express/testing/public/test.txt +0 -2971
  250. data/server/node_modules/express/testing/views/page.html +0 -1
  251. data/server/node_modules/express/testing/views/page.jade +0 -3
  252. data/server/node_modules/express/testing/views/test.md +0 -1
  253. data/server/node_modules/express/testing/views/user/index.jade +0 -1
  254. data/server/node_modules/express/testing/views/user/list.jade +0 -1
  255. data/server/node_modules/knox/lib/knox/mime/index.js +0 -308
  256. data/server/node_modules/knox/lib/knox/mime/test.js +0 -59
  257. data/server/node_modules/node-uuid/test/benchmark-native +0 -0
  258. data/server/node_modules/on/index.js +0 -13
  259. data/server/node_modules/restler/test/test_helper.js +0 -163
  260. data/server/node_modules/spawner/index.js +0 -106
data/server/index.js DELETED
@@ -1,14 +0,0 @@
1
- var express = require('express');
2
- var form = require('connect-form');
3
-
4
- var app = express.createServer(
5
- express.logger());
6
-
7
- app.get('/', function(req, res) {
8
- console.log('got request');
9
- setTimeout(function() {
10
- res.send('ok');
11
- }, 2000);
12
- });
13
-
14
- module.exports = app;
@@ -1,22 +0,0 @@
1
- (The MIT License)
2
-
3
- Copyright (c) 2009-2010 TJ Holowaychuk <tj@vision-media.ca>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- 'Software'), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,100 +0,0 @@
1
-
2
- /*!
3
- * Connect - Multipart
4
- * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>
5
- * MIT Licensed
6
- */
7
-
8
- /**
9
- * Module dependencies.
10
- */
11
-
12
- var formidable = require('formidable');
13
-
14
- /**
15
- * Setup form with the given `options`.
16
- *
17
- * Options:
18
- *
19
- * - `encoding` Encoding used for incoming forms. Defaults to utf8
20
- * - `uploadDir` Directory to save uploads. Defaults to "/tmp"
21
- * - `keepExtensions` Include original extensions. Defaults to `false`
22
- *
23
- * Examples:
24
- *
25
- * var form = require('connect-form');
26
- * var server = connect.createServer(
27
- * form({ keepExtensions: true }),
28
- * function(req, res, next){
29
- * // Form was submitted
30
- * if (req.form) {
31
- * // Do something when parsing is finished
32
- * // and respond, or respond immediately
33
- * // and work with the files.
34
- * req.form.complete(function(err, fields, files){
35
- * res.writeHead(200, {});
36
- * if (err) res.write(JSON.stringify(err.message));
37
- * res.write(JSON.stringify(fields));
38
- * res.write(JSON.stringify(files));
39
- * res.end();
40
- * });
41
- * // Regular request, pass to next middleware
42
- * } else {
43
- * next();
44
- * }
45
- * }
46
- * );
47
- *
48
- * @param {Object} options
49
- * @return {Function}
50
- * @api public
51
- */
52
-
53
- module.exports = function(options){
54
- options = options || {};
55
- return function(req, res, next){
56
- if (formRequest(req)) {
57
- var form = req.form = new formidable.IncomingForm;
58
- merge(form, options);
59
- form.complete = function(fn){
60
- form.parse(req, fn);
61
- };
62
- }
63
- next();
64
- };
65
- };
66
-
67
- /**
68
- * Check if `req` is a valid form request.
69
- *
70
- * @param {IncomingMessage} req
71
- * @return {Boolean}
72
- * @api private
73
- */
74
-
75
- function formRequest(req) {
76
- var contentType = req.headers['content-type'];
77
- if (!contentType) return;
78
- return req.body === undefined
79
- && (req.method === 'POST'
80
- || req.method === 'PUT')
81
- && (~contentType.indexOf('multipart/form-data')
82
- || ~contentType.indexOf('urlencoded'));
83
- }
84
-
85
- /**
86
- * Merge object `b` with object `a`.
87
- *
88
- * @param {Object} a
89
- * @param {Object} b
90
- * @return {Object} a
91
- * @api private
92
- */
93
-
94
- function merge(a, b) {
95
- var keys = Object.keys(b);
96
- for (var i = 0, len = keys.length; i < len; ++i) {
97
- a[keys[i]] = b[keys[i]];
98
- }
99
- return a;
100
- }
@@ -1,45 +0,0 @@
1
- var common = require('../common');
2
- var test = common.fastOrSlow.fast();
3
- var assert = common.assert;
4
-
5
- var IncomingForm = common.require('incoming_form').IncomingForm;
6
-
7
- var form;
8
- test.before(function() {
9
- form = new IncomingForm();
10
- });
11
-
12
- function makeHeader(filename) {
13
- return 'Content-Disposition: form-data; name="upload"; filename="' + filename + '"';
14
- }
15
-
16
- test('#_fileName with regular characters', function() {
17
- var filename = 'foo.txt';
18
- assert.equal(form._fileName(makeHeader(filename)), 'foo.txt');
19
- });
20
-
21
- test('#_fileName with unescaped quote', function() {
22
- var filename = 'my".txt';
23
- assert.equal(form._fileName(makeHeader(filename)), 'my".txt');
24
- });
25
-
26
- test('#_fileName with escaped quote', function() {
27
- var filename = 'my%22.txt';
28
- assert.equal(form._fileName(makeHeader(filename)), 'my".txt');
29
- });
30
-
31
- test('#_fileName with bad quote and additional sub-header', function() {
32
- var filename = 'my".txt';
33
- var header = makeHeader(filename) + '; foo="bar"';
34
- assert.equal(form._fileName(header), filename);
35
- });
36
-
37
- test('#_fileName with semicolon', function() {
38
- var filename = 'my;.txt';
39
- assert.equal(form._fileName(makeHeader(filename)), 'my;.txt');
40
- });
41
-
42
- test('#_fileName with utf8 character', function() {
43
- var filename = 'my&#9731;.txt';
44
- assert.equal(form._fileName(makeHeader(filename)), 'my☃.txt');
45
- });
@@ -1,13 +0,0 @@
1
- POST /upload HTTP/1.1
2
- Host: localhost:8080
3
- Content-Type: multipart/form-data; boundary=----WebKitFormBoundarytyE4wkKlZ5CQJVTG
4
- Content-Length: 1000
5
-
6
- ------WebKitFormBoundarytyE4wkKlZ5CQJVTG
7
- Content-Disposition: form-data; name="upload"; filename=""
8
- Content-Type: text/plain
9
-
10
- I am a plain text file
11
-
12
- ------WebKitFormBoundarytyE4wkKlZ5CQJVTG--
13
-
@@ -1,26 +0,0 @@
1
- POST /upload HTTP/1.1
2
- Host: localhost:8080
3
- Connection: keep-alive
4
- Referer: http://localhost:8080/
5
- Content-Length: 383
6
- Cache-Control: max-age=0
7
- Origin: http://localhost:8080
8
- User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1
9
- Content-Type: multipart/form-data; boundary=----WebKitFormBoundarytyE4wkKlZ5CQJVTG
10
- Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
11
- Accept-Encoding: gzip,deflate,sdch
12
- Accept-Language: en-US,en;q=0.8
13
- Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
14
- Cookie: jqCookieJar_tablesorter=%7B%22showListTable%22%3A%5B%5B5%2C1%5D%2C%5B1%2C0%5D%5D%7D
15
-
16
- ------WebKitFormBoundarytyE4wkKlZ5CQJVTG
17
- Content-Disposition: form-data; name="title"
18
-
19
- Weird filename
20
- ------WebKitFormBoundarytyE4wkKlZ5CQJVTG
21
- Content-Disposition: form-data; name="upload"; filename=": \ ? % * | %22 < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt"
22
- Content-Type: text/plain
23
-
24
- I am a text file with a funky name!
25
-
26
- ------WebKitFormBoundarytyE4wkKlZ5CQJVTG--
@@ -1,24 +0,0 @@
1
- POST /upload HTTP/1.1
2
- Host: localhost:8080
3
- User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.22) Gecko/20110902 Firefox/3.6.22
4
- Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
5
- Accept-Language: en-us,en;q=0.5
6
- Accept-Encoding: gzip,deflate
7
- Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
8
- Keep-Alive: 115
9
- Connection: keep-alive
10
- Referer: http://localhost:8080/
11
- Content-Type: multipart/form-data; boundary=---------------------------9849436581144108930470211272
12
- Content-Length: 438
13
-
14
- -----------------------------9849436581144108930470211272
15
- Content-Disposition: form-data; name="title"
16
-
17
- Weird filename
18
- -----------------------------9849436581144108930470211272
19
- Content-Disposition: form-data; name="upload"; filename=": \ ? % * | " < > . &#9731; ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt"
20
- Content-Type: text/plain
21
-
22
- I am a text file with a funky name!
23
-
24
- -----------------------------9849436581144108930470211272--
@@ -1,23 +0,0 @@
1
- POST /upload HTTP/1.1
2
- Host: localhost:8080
3
- Origin: http://localhost:8080
4
- Content-Length: 383
5
- User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1
6
- Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryQJZ1gvhvdgfisJPJ
7
- Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
8
- Referer: http://localhost:8080/
9
- Accept-Language: en-us
10
- Accept-Encoding: gzip, deflate
11
- Connection: keep-alive
12
-
13
- ------WebKitFormBoundaryQJZ1gvhvdgfisJPJ
14
- Content-Disposition: form-data; name="title"
15
-
16
- Weird filename
17
- ------WebKitFormBoundaryQJZ1gvhvdgfisJPJ
18
- Content-Disposition: form-data; name="upload"; filename=": \ ? % * | %22 < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt"
19
- Content-Type: text/plain
20
-
21
- I am a text file with a funky name!
22
-
23
- ------WebKitFormBoundaryQJZ1gvhvdgfisJPJ--
@@ -1,24 +0,0 @@
1
- POST /upload HTTP/1.1
2
- Host: 192.168.56.1:8080
3
- Connection: keep-alive
4
- Referer: http://192.168.56.1:8080/
5
- Content-Length: 344
6
- Cache-Control: max-age=0
7
- Origin: http://192.168.56.1:8080
8
- User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 Safari/534.30
9
- Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryEvqBNplR3ByrwQPa
10
- Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
11
- Accept-Encoding: gzip,deflate,sdch
12
- Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
13
- Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
14
-
15
- ------WebKitFormBoundaryEvqBNplR3ByrwQPa
16
- Content-Disposition: form-data; name="title"
17
-
18
- Weird filename
19
- ------WebKitFormBoundaryEvqBNplR3ByrwQPa
20
- Content-Disposition: form-data; name="upload"; filename=" ? % * | %22 < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt"
21
- Content-Type: text/plain
22
-
23
-
24
- ------WebKitFormBoundaryEvqBNplR3ByrwQPa--
@@ -1,22 +0,0 @@
1
- POST /upload HTTP/1.1
2
- Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, */*
3
- Referer: http://192.168.56.1:8080/
4
- Accept-Language: de
5
- User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)
6
- Content-Type: multipart/form-data; boundary=---------------------------7db1fe232017c
7
- Accept-Encoding: gzip, deflate
8
- Host: 192.168.56.1:8080
9
- Content-Length: 368
10
- Connection: Keep-Alive
11
- Cache-Control: no-cache
12
-
13
- -----------------------------7db1fe232017c
14
- Content-Disposition: form-data; name="title"
15
-
16
- Weird filename
17
- -----------------------------7db1fe232017c
18
- Content-Disposition: form-data; name="upload"; filename=" ? % * | " < > . &#9731; ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt"
19
- Content-Type: application/octet-stream
20
-
21
-
22
- -----------------------------7db1fe232017c--
@@ -1,22 +0,0 @@
1
- POST /upload HTTP/1.1
2
- Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, */*
3
- Referer: http://192.168.56.1:8080/
4
- Accept-Language: de
5
- User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)
6
- Content-Type: multipart/form-data; boundary=---------------------------7db3a8372017c
7
- Accept-Encoding: gzip, deflate
8
- Host: 192.168.56.1:8080
9
- Content-Length: 368
10
- Connection: Keep-Alive
11
- Cache-Control: no-cache
12
-
13
- -----------------------------7db3a8372017c
14
- Content-Disposition: form-data; name="title"
15
-
16
- Weird filename
17
- -----------------------------7db3a8372017c
18
- Content-Disposition: form-data; name="upload"; filename=" ? % * | " < > . &#9731; ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt"
19
- Content-Type: application/octet-stream
20
-
21
-
22
- -----------------------------7db3a8372017c--
@@ -1,22 +0,0 @@
1
- POST /upload HTTP/1.1
2
- Host: 192.168.56.1:8080
3
- Referer: http://192.168.56.1:8080/
4
- Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
5
- Accept-Language: en-US
6
- Origin: http://192.168.56.1:8080
7
- User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4
8
- Accept-Encoding: gzip, deflate
9
- Content-Type: multipart/form-data; boundary=----WebKitFormBoundarykmaWSUbu697WN9TM
10
- Content-Length: 344
11
- Connection: keep-alive
12
-
13
- ------WebKitFormBoundarykmaWSUbu697WN9TM
14
- Content-Disposition: form-data; name="title"
15
-
16
- Weird filename
17
- ------WebKitFormBoundarykmaWSUbu697WN9TM
18
- Content-Disposition: form-data; name="upload"; filename=" ? % * | %22 < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt"
19
- Content-Type: text/plain
20
-
21
-
22
- ------WebKitFormBoundarykmaWSUbu697WN9TM--
@@ -1,10 +0,0 @@
1
- default: test
2
-
3
- #
4
- # Run all tests
5
- #
6
- test:
7
- node test/scripts/prepare-db.js
8
- vows test/*-test.js
9
-
10
- .PHONY: test
@@ -1,650 +0,0 @@
1
- var path = require('path'),
2
- assert = require('assert'),
3
- events = require('events'),
4
- http = require('http'),
5
- fs = require('fs'),
6
- vows = require('vows'),
7
- seed = require('./helpers/seed');
8
-
9
- function status(code) {
10
- return function (e, res) {
11
- assert.ok(res || e);
12
- assert.equal((res || e).headers.status || (res || e).status, code);
13
- };
14
- }
15
-
16
- function mixin(target) {
17
- var objs = Array.prototype.slice.call(arguments, 1);
18
- objs.forEach(function (o) {
19
- for (var attr in o) { target[attr] = o[attr] }
20
- });
21
- return target;
22
- }
23
-
24
- var cradle = require('../lib/cradle');
25
-
26
- vows.describe("cradle").addBatch(seed.requireSeed()).addBatch({
27
- "Default connection settings": {
28
- topic: function () {
29
- cradle.setup({
30
- host: "http://cloudhead.io",
31
- port: 4242,
32
- milk: 'white'
33
- });
34
- return new(cradle.Connection);
35
- },
36
- "should be carried on to new Connections": function (c) {
37
- assert.equal(c.host, "cloudhead.io");
38
- assert.equal(c.protocol, "http");
39
- assert.equal(c.port, 4242);
40
- assert.equal(c.options.milk, 'white');
41
- assert.equal(c.options.cache, true);
42
- },
43
- "with just a {} passed to a new Connection object": {
44
- topic: function () { return new(cradle.Connection)({milk: 'green'}) },
45
- "should override the defaults": function (c) {
46
- assert.equal(c.options.milk, 'green');
47
- assert.equal(c.port, 4242);
48
- }
49
- },
50
- "with a host and port passed to Connection": {
51
- topic: function () { return new(cradle.Connection)("255.255.0.0", 9696) },
52
- "should override the defaults": function (c) {
53
- assert.equal(c.host, '255.255.0.0');
54
- assert.equal(c.port, 9696);
55
- }
56
- },
57
- "with a host, port and options passed to Connection": {
58
- topic: function () { return new(cradle.Connection)("4.4.4.4", 911, {raw: true}) },
59
- "should override the defaults": function (c) {
60
- assert.equal(c.host, '4.4.4.4');
61
- assert.equal(c.port, 911);
62
- assert.equal(c.options.raw, true);
63
- }
64
- },
65
- "with a host and port and protocol passed to Connection": {
66
- topic: function () { return new(cradle.Connection)("http://4.4.4.4", 911, {raw: true, secure: true}) },
67
- "should override the defaults": function (c) {
68
- assert.equal(c.host, '4.4.4.4');
69
- assert.equal(c.port, 911);
70
- assert.equal(c.options.raw, true);
71
- assert.equal(c.options.secure, true);
72
- }
73
- },
74
- "with a host and port passed as an object to Connection": {
75
- topic: function () { return new(cradle.Connection)({ host: "https://4.4.4.4", port: 911, raw: true }) },
76
- "should override the defaults": function (c) {
77
- assert.equal(c.options.secure, true);
78
- assert.equal(c.host, '4.4.4.4');
79
- assert.equal(c.port, 911);
80
- assert.equal(c.options.raw, true);
81
- }
82
- },
83
- "with a the 'https' protocol": {
84
- topic: function () { return new(cradle.Connection)("https://couch.io", 5984) },
85
- "should set 'secure' to `true`": function (c) {
86
- assert.equal(c.protocol, 'https');
87
- assert.equal(c.options.secure, true);
88
- assert.equal(c.host, 'couch.io');
89
- assert.equal(c.port, 5984);
90
- }
91
- },
92
- },
93
- }).addBatch({
94
- //
95
- // Cache
96
- //
97
- "A Cradle connection (cache)": {
98
- topic: function () {
99
- return new(cradle.Connection)('127.0.0.1', 5984, { cache: true }).database('pigs');
100
- },
101
- "save()": {
102
- topic: function (db) {
103
- var promise = new(events.EventEmitter);
104
- db.save('bob', {ears: true}, function (e, res) {
105
- promise.emit("success", db);
106
- });
107
- return promise;
108
- },
109
- "should write through the cache": function (db) {
110
- assert.ok(db.cache.has('bob'));
111
- assert.ok(db.cache.get('bob')._rev);
112
- },
113
- "when fetching the cached document": {
114
- topic: function (db) {
115
- db.get('bob', this.callback)
116
- },
117
- "document contains _id": function (e, doc) {
118
- assert.equal(doc._id, 'bob');
119
- }
120
- },
121
- "and": {
122
- topic: function (db) {
123
- var promise = new(events.EventEmitter);
124
- db.save('bob', {size: 12}, function (e, res) {
125
- promise.emit('success', res, db.cache.get('bob'));
126
- });
127
- return promise;
128
- },
129
- "return a 201": status(201),
130
- "allow an overwrite": function (res) {
131
- assert.match(res.rev, /^2/);
132
- },
133
- "caches the updated document": function (e, res, doc) {
134
- assert.ok(doc);
135
- assert.equal(doc.size, 12);
136
- assert.isUndefined(doc.ears);
137
- }
138
- }
139
- },
140
- "save() with / in id": {
141
- topic: function (db) {
142
- var promise = new(events.EventEmitter);
143
- db.save('bob/someotherdoc', {size: 12}, function (e, res) {
144
- promise.emit('success', res, db.cache.get('bob/someotherdoc'));
145
- });
146
- return promise;
147
- },
148
- "return a 201": status(201),
149
- "allow an overwrite": function (res) {
150
- assert.match(res.rev, /^1/);
151
- },
152
- "caches the updated document": function (e, res, doc) {
153
- assert.ok(doc);
154
- assert.equal(doc.size, 12);
155
- }
156
- },
157
- "merge()": {
158
- topic: function (db) {
159
- var promise = new(events.EventEmitter);
160
- db.save('billy', {ears: true}, function (e, res) {
161
- promise.emit("success", db);
162
- });
163
- return promise;
164
- },
165
- "should write through the cache": function (db) {
166
- assert.ok(db.cache.has('billy'));
167
- assert.ok(db.cache.get('billy')._rev);
168
- },
169
- "and": {
170
- topic: function (db) {
171
- var promise = new(events.EventEmitter);
172
- db.merge('billy', {size: 12}, function (e, res) {
173
- promise.emit('success', res, db.cache.get('billy'));
174
- });
175
- return promise;
176
- },
177
- "return a 201": status(201),
178
- "allow an overwrite": function (res) {
179
- assert.match(res.rev, /^2/);
180
- },
181
- "caches the updated document": function (e, res, doc) {
182
- assert.ok(doc);
183
- assert.equal(doc.size, 12);
184
- assert.equal(doc.ears, true);
185
- }
186
- }
187
- },
188
- "remove()": {
189
- topic: function (db) {
190
- var promise = new(events.EventEmitter);
191
- db.save('bruno', {}, function (e, res) {
192
- promise.emit("success", db);
193
- });
194
- return promise;
195
- },
196
- "shouldn't ask for a revision": {
197
- topic: function (db) {
198
- var promise = new(events.EventEmitter);
199
- db.remove('bruno', function () { promise.emit('success', db) });
200
- return promise;
201
- },
202
- "and should purge the cache": function (db) {
203
- assert.equal(db.cache.has('bruno'), false);
204
- },
205
- "and raise an exception if you use remove() without a rev": function (db) {
206
- //assert.throws(db.remove('bruno'), Error);
207
- }
208
- }
209
- },
210
- "saveAttachment()": {
211
- "updates the cache": {
212
- topic: function (db) {
213
- var that = this;
214
- db.save({_id:'attachment-cacher'}, function (e, res) {
215
- db.saveAttachment(res.id, res.rev, 'foo.txt', 'text/plain', 'Foo!', function (attRes) {
216
- that.callback(null, db.cache.get(res.id));
217
- });
218
- });
219
- },
220
- "with the revision": function (cached) {
221
- assert.match(cached._rev, /^2-/);
222
- },
223
- "with the _attachments": function (cached) {
224
- assert.ok(cached._attachments);
225
- assert.ok(cached._attachments['foo.txt']);
226
- assert.equal(cached._attachments['foo.txt'].stub, true);
227
- },
228
- "and is valid enough to re-save": {
229
- topic: function (cached, db) {
230
- var that = this
231
- db.save(mixin({foo:'bar'}, cached), function (e,res) {
232
- db.cache.purge(cached._id);
233
- db.get(cached._id, that.callback);
234
- });
235
- },
236
- "has the attachment": function (res) {
237
- var att = res._attachments['foo.txt'];
238
- assert.equal(att.stub, true);
239
- assert.equal(att.content_type, 'text/plain');
240
- assert.equal(att.length, 4);
241
- assert.equal(att.revpos, 2);
242
- },
243
- "and actually updated the rev": function (res) {
244
- assert.match(res._rev, /^3-/);
245
- }
246
- }
247
- },
248
- "pulls the revision from the cache if not given": {
249
- topic: function (db) {
250
- var callback = this.callback;
251
- db.save({_id:'attachment-saving-pulls-rev-from-cache'}, function (e, res) {
252
- db.saveAttachment(res.id, null, 'foo.txt', 'text/plain', 'Foo!', callback);
253
- });
254
- },
255
- "and saves successfully": status(201)
256
- }
257
- }
258
- }
259
- }).addBatch({
260
- "Connection": {
261
- topic: function () {
262
- return new(cradle.Connection)('127.0.0.1', 5984, {cache: false});
263
- },
264
- "getting server info": {
265
- topic: function (c) { c.info(this.callback) },
266
-
267
- "returns a 200": status(200),
268
- "returns the version number": function (info) {
269
- assert.ok(info);
270
- assert.match(info.version, /\d+\.\d+\.\d+/);
271
- }
272
- },
273
- "uuids()": {
274
- "with count": {
275
- topic: function (c) { c.uuids(42, this.callback) },
276
-
277
- "returns a 200": status(200),
278
- "returns an array of UUIDs": function (uuids) {
279
- assert.isArray(uuids);
280
- assert.lengthOf(uuids, 42);
281
- }
282
- },
283
- "without count": {
284
- topic: function (c) { c.uuids(this.callback) },
285
-
286
- "returns a 200": status(200),
287
- "returns an array of UUIDs": function (uuids) {
288
- assert.isArray(uuids);
289
- assert.lengthOf(uuids, 1);
290
- }
291
- }
292
- },
293
- "getting the list of databases": {
294
- topic: function (c) {
295
- c.databases(this.callback);
296
- },
297
- "should contain the 'rabbits' and 'pigs' databases": function (dbs) {
298
- assert.isArray(dbs);
299
- assert.include(dbs, 'rabbits');
300
- assert.include(dbs, 'pigs');
301
- }
302
- },
303
- }
304
- }).addBatch({
305
- "Connection": {
306
- topic: function () {
307
- return new(cradle.Connection)('127.0.0.1', 5984, {cache: false});
308
- },
309
- "create()": {
310
- topic: function (c) {
311
- c.database('badgers').create(this.callback);
312
- },
313
- "returns a 201": status(201),
314
- "creates a database": {
315
- topic: function (res, c) { c.database('badgers').exists(this.callback) },
316
- "it exists": function (res) { assert.ok(res) }
317
- }
318
- },
319
- "destroy()": {
320
- topic: function (c) {
321
- c.database('rabbits').destroy(this.callback);
322
- },
323
- "returns a 200": status(200),
324
- "destroys a database": {
325
- topic: function (res, c) {
326
- c.database('rabbits').exists(this.callback);
327
- },
328
- "it doesn't exist anymore": function (res) { assert.ok(! res) }
329
- }
330
- },
331
- "database()": {
332
- topic: function (c) { return c.database('pigs') },
333
-
334
- "info()": {
335
- topic: function (db) {
336
- db.info(this.callback);
337
- },
338
- "returns a 200": status(200),
339
- "returns database info": function (info) {
340
- assert.equal(info['db_name'], 'pigs');
341
- }
342
- },
343
- "fetching a document by id (GET)": {
344
- topic: function (db) { db.get('mike', this.callback) },
345
- "returns a 200": status(200),
346
- "returns the document": function (res) {
347
- assert.equal(res.id, 'mike');
348
- },
349
- "when not found": {
350
- topic: function (_, db) { db.get('tyler', this.callback) },
351
- "returns a 404": status(404),
352
- "returns the error": function (err, res) {
353
- assert.isObject(err);
354
- assert.isObject(err.headers);
355
- assert.isUndefined(res);
356
- },
357
- }
358
- },
359
- "head()": {
360
- topic: function (db) { db.head('mike', this.callback) },
361
- "returns the headers": function (res) {
362
- assert.match(res.etag, /^"\d-[a-z0-9]+"$/);
363
- }
364
- },
365
- "save()": {
366
- "with an id & doc": {
367
- topic: function (db) {
368
- db.save('joe', {gender: 'male'}, this.callback);
369
- },
370
- "creates a new document (201)": status(201),
371
- "returns the revision": function (res) {
372
- assert.ok(res.rev);
373
- }
374
- },
375
- "with a doc containing non-ASCII characters": {
376
- topic: function (db) {
377
- db.save('john', {umlauts: 'äöü'}, this.callback);
378
- },
379
- "creates a new document (201)": status(201)
380
- },
381
- "with a large doc": {
382
- topic: function (db) {
383
- var text = (function (s) {
384
- for (var i = 0; i < 18; i++) { s += s }
385
- return s;
386
- })('blah');
387
-
388
- db.save('large-bob', {
389
- gender: 'male',
390
- speech: text
391
- }, this.callback);
392
- },
393
- "creates a new document (201)": status(201)
394
- },
395
- "with a '_design' id": {
396
- topic: function (db) {
397
- db.save('_design/horses', {
398
- all: {
399
- map: function (doc) {
400
- if (doc.speed == 72) emit(null, doc);
401
- }
402
- }
403
- }, this.callback);
404
- },
405
- "creates a doc (201)": status(201),
406
- "returns the revision": function (res) {
407
- assert.ok(res.rev);
408
- },
409
- "creates a design doc": {
410
- topic: function (res, db) {
411
- db.view('horses/all', this.callback);
412
- },
413
- "which can be queried": status(200)
414
- }
415
- },
416
- "without an id (POST)": {},
417
- },
418
- "calling save() with an array": {
419
- topic: function (db) {
420
- db.save([{_id: 'tom'}, {_id: 'flint'}], this.callback);
421
- },
422
- "returns an array of document ids and revs": function (res) {
423
- assert.equal(res[0].id, 'tom');
424
- assert.equal(res[1].id, 'flint');
425
- },
426
- "should bulk insert the documents": {
427
- topic: function (res, db) {
428
- var promise = new(events.EventEmitter);
429
- db.get('tom', function (e, tom) {
430
- db.get('flint', function (e, flint) {
431
- promise.emit('success', tom, flint);
432
- });
433
- });
434
- return promise;
435
- },
436
- "which can then be retrieved": function (e, tom, flint) {
437
- assert.ok(tom._id);
438
- assert.ok(flint._id);
439
- }
440
- }
441
- },
442
- "getting all documents": {
443
- topic: function (db) {
444
- db.all(this.callback);
445
- },
446
- "returns a 200": status(200),
447
- "returns a list of all docs": function (res) {
448
- assert.isArray(res);
449
- assert.isNumber(res.total_rows);
450
- assert.isNumber(res.offset);
451
- assert.isArray(res.rows);
452
- },
453
- "which can be iterated upon": function (res) {
454
- assert.isFunction(res.forEach);
455
- }
456
- },
457
- "updating a document (PUT)": {
458
- topic: function (db) {
459
- var promise = new(events.EventEmitter);
460
- db.get('mike', function (err, doc) {
461
- db.save('mike', doc.rev,
462
- {color: doc.color, age: 13}, function (err, res) {
463
- if (! err) promise.emit('success', res, db);
464
- else promise.emit('error', res);
465
- });
466
- });
467
- return promise;
468
- },
469
- "returns a 201": status(201),
470
- "returns the revision": function (res) {
471
- assert.ok(res.rev);
472
- assert.match(res.rev, /^2/);
473
- },
474
- },
475
- "deleting a document (DELETE)": {
476
- topic: function (db) {
477
- var promise = new(events.EventEmitter);
478
- db.get('bill', function (e, res) {
479
- db.remove('bill', res.rev, function (e, res) {
480
- promise.emit('success', res);
481
- });
482
- });
483
- return promise;
484
- },
485
- "returns a 200": status(200)
486
- },
487
- "querying a view": {
488
- topic: function (db) {
489
- db.view('pigs/all', this.callback);
490
- },
491
- "returns a 200": status(200),
492
- "returns view results": function (res) {
493
- assert.isArray(res.rows);
494
- assert.equal(res.rows.length, 2);
495
- assert.equal(res.total_rows, 2);
496
- },
497
- "returns an iterable object with key/val pairs": function (res) {
498
- assert.isArray(res);
499
- assert.lengthOf(res, 2);
500
- res.forEach(function (k, v) {
501
- assert.isObject(v);
502
- assert.isString(k);
503
- assert.ok(k === 'mike' || k === 'bill');
504
- });
505
- },
506
- "with options": {
507
-
508
- },
509
- "with a start & end key": {
510
-
511
- }
512
- },
513
- // same as the above test, but with a temporary view
514
- "querying a temporary view": {
515
- topic: function (db) {
516
- db.temporaryView({
517
- map: function (doc) {
518
- if (doc.color) emit(doc._id, doc);
519
- }
520
- }, this.callback);
521
- },
522
- "returns a 200": status(200),
523
- "returns view results": function (res) {
524
- assert.isArray(res.rows);
525
- assert.equal(res.rows.length, 2);
526
- assert.equal(res.total_rows, 2);
527
- },
528
- "returns an iterable object with key/val pairs": function (res) {
529
- assert.isArray(res);
530
- assert.lengthOf(res, 2);
531
- res.forEach(function (k, v) {
532
- assert.isObject(v);
533
- assert.isString(k);
534
- assert.ok(k === 'mike' || k === 'bill');
535
- });
536
- },
537
- "with options": {
538
-
539
- },
540
- "with a start & end key": {
541
-
542
- }
543
- },
544
- "putting an attachment": {
545
- "to an existing document": {
546
- "with given data": {
547
- topic: function (db) {
548
- var callback = this.callback;
549
- db.save({_id: 'complete-attachment'}, function (e, res) {
550
- db.saveAttachment(res.id, res.rev, 'foo.txt', 'text/plain', 'Foo!', callback);
551
- });
552
- },
553
- "returns a 201": status(201),
554
- "returns the revision": function (res) {
555
- assert.ok(res.rev);
556
- assert.match(res.rev, /^2/);
557
- },
558
- },
559
- "with streaming data": {
560
- topic: function (db) {
561
- var callback = this.callback, filestream;
562
- db.save({'_id':'streaming-attachment'}, function (e, res) {
563
- filestream = fs.createReadStream(__dirname + "/../README.md");
564
- db.saveAttachment(res.id, res.rev, 'foo.txt', 'text/plain', filestream, callback);
565
- })
566
- },
567
- "returns a 201": status(201),
568
- "returns the revision": function (res) {
569
- assert.ok(res.rev);
570
- assert.match(res.rev, /^2/);
571
- }
572
- },
573
- "with incorrect revision": {
574
- topic: function (db) {
575
- var callback = this.callback, oldRev;
576
- db.save({_id: 'attachment-incorrect-revision'}, function (e, res) {
577
- oldRev = res.rev;
578
- db.save({_id: 'attachment-incorrect-revision', _rev:res.rev}, function (e, res) {
579
- db.saveAttachment(res.id, oldRev, 'foo.txt', 'text/plain', 'Foo!', callback);
580
- });
581
- });
582
- },
583
- "returns a 409": status(409)
584
- }
585
- },
586
- "to a non-existing document": {
587
- topic: function (db) {
588
- db.saveAttachment('standalone-attachment', 'foo.txt', 'text/plain', 'Foo!', this.callback);
589
- },
590
- "returns a 201": status(201),
591
- "returns the revision": function (res) {
592
- assert.ok(res.rev);
593
- assert.match(res.rev, /^1-/);
594
- }
595
- }
596
- },
597
- "getting an attachment": {
598
- "when it exists": {
599
- topic: function (db) {
600
- var promise = new(events.EventEmitter), response = {};
601
- doc = {_id:'attachment-getter', _attachments:{ "foo.txt":{content_type:"text/plain", data:"aGVsbG8gd29ybGQ="} }};
602
- db.save(doc, function (e, res) {
603
- var streamer = db.getAttachment('attachment-getter','foo.txt');
604
- streamer.addListener('response', function (res) {
605
- response.headers = res.headers;
606
- response.headers.status = res.statusCode;
607
- response.body = "";
608
- });
609
- streamer.addListener('data', function (chunk) { response.body += chunk; });
610
- streamer.addListener('end', function () { promise.emit('success', response); });
611
- });
612
- return promise;
613
- },
614
- "returns a 200": status(200),
615
- "returns the right mime-type in the header": function (res) {
616
- assert.equal(res.headers['content-type'], 'text/plain');
617
- },
618
- "returns the attachment in the body": function (res) {
619
- assert.equal(res.body, "hello world");
620
- }
621
- },
622
- "when not found": {
623
- topic: function (db) {
624
- var promise = new(events.EventEmitter), response = {};
625
- db.save({_id:'attachment-not-found'}, function (e, res) {
626
- var streamer = db.getAttachment('attachment-not-found','foo.txt');
627
- streamer.addListener('response', function (res) {
628
- response.headers = res.headers;
629
- response.headers.status = res.statusCode;
630
- promise.emit('success', response);
631
- });
632
- });
633
- return promise;
634
- },
635
- "returns a 404": status(404)
636
- }
637
- },
638
- "cleaning up a view with viewCleanup()": {
639
- topic: function (db) {
640
- db.viewCleanup(this.callback);
641
- },
642
- "returns a 202": status(202),
643
- "no error is thrown and we get ok response": function (e, res) {
644
- assert.ok(!e);
645
- assert.ok(res && res.ok && res.ok === true);
646
- }
647
- }
648
- }
649
- }
650
- }).export(module);