vulcan 0.2.5 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. data/README.md +1 -80
  2. data/lib/vulcan/cli.rb +12 -33
  3. data/lib/vulcan/version.rb +1 -1
  4. data/server/bin/make +3 -1
  5. data/server/lib/spawner.js +4 -9
  6. data/server/node_modules/connect-form/node_modules/formidable/Readme.md +2 -13
  7. data/server/node_modules/connect-form/node_modules/formidable/lib/incoming_form.js +7 -19
  8. data/server/node_modules/connect-form/node_modules/formidable/lib/multipart_parser.js +1 -12
  9. data/server/node_modules/connect-form/node_modules/formidable/package.json +1 -1
  10. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +10 -0
  11. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +9 -0
  12. data/server/node_modules/connect-form/node_modules/formidable/test/legacy/simple/test-multipart-parser.js +1 -1
  13. data/server/node_modules/cradle/lib/cradle.js +1 -0
  14. data/server/node_modules/cradle/node_modules/vows/LICENSE +20 -0
  15. data/server/node_modules/cradle/node_modules/vows/Makefile +7 -0
  16. data/server/node_modules/cradle/node_modules/vows/README.md +39 -0
  17. data/server/node_modules/cradle/node_modules/vows/bin/vows +515 -0
  18. data/server/node_modules/cradle/node_modules/vows/lib/assert/error.js +27 -0
  19. data/server/node_modules/cradle/node_modules/vows/lib/assert/macros.js +215 -0
  20. data/server/node_modules/cradle/node_modules/vows/lib/assert/utils.js +77 -0
  21. data/server/node_modules/cradle/node_modules/vows/lib/vows.js +193 -0
  22. data/server/node_modules/cradle/node_modules/vows/lib/vows/console.js +131 -0
  23. data/server/node_modules/cradle/node_modules/vows/lib/vows/context.js +55 -0
  24. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/file.js +29 -0
  25. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/fragments/coverage-foot.html +2 -0
  26. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/fragments/coverage-head.html +61 -0
  27. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/report-html.js +54 -0
  28. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/report-json.js +54 -0
  29. data/server/node_modules/cradle/node_modules/vows/lib/vows/coverage/report-plain.js +38 -0
  30. data/server/node_modules/cradle/node_modules/vows/lib/vows/extras.js +28 -0
  31. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/dot-matrix.js +67 -0
  32. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/json.js +16 -0
  33. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/silent.js +8 -0
  34. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/spec.js +44 -0
  35. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/watch.js +39 -0
  36. data/server/node_modules/cradle/node_modules/vows/lib/vows/reporters/xunit.js +90 -0
  37. data/server/node_modules/cradle/node_modules/vows/lib/vows/suite.js +319 -0
  38. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/LICENSE +20 -0
  39. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/Makefile +4 -0
  40. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/README.md +72 -0
  41. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/lib/eyes.js +233 -0
  42. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/package.json +14 -0
  43. data/server/node_modules/cradle/node_modules/vows/node_modules/eyes/test/eyes-test.js +55 -0
  44. data/server/node_modules/cradle/node_modules/vows/package.json +14 -0
  45. data/server/node_modules/cradle/node_modules/vows/test/assert-test.js +135 -0
  46. data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/failing.js +18 -0
  47. data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/log.js +18 -0
  48. data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/passing.js +17 -0
  49. data/server/node_modules/cradle/node_modules/vows/test/fixtures/isolate/stderr.js +18 -0
  50. data/server/node_modules/cradle/node_modules/vows/test/isolate-test.js +140 -0
  51. data/server/node_modules/cradle/node_modules/vows/test/testInherit.js +133 -0
  52. data/server/node_modules/cradle/node_modules/vows/test/vows-error-test.js +51 -0
  53. data/server/node_modules/cradle/node_modules/vows/test/vows-test.js +374 -0
  54. data/server/node_modules/cradle/package.json +3 -3
  55. data/server/node_modules/cradle/test/cache-test.js +7 -6
  56. data/server/node_modules/cradle/test/cradle-test.js +5 -4
  57. data/server/node_modules/cradle/test/response-test.js +6 -5
  58. data/server/node_modules/express/History.md +1 -53
  59. data/server/node_modules/express/Makefile +9 -3
  60. data/server/node_modules/express/Readme.md +1 -3
  61. data/server/node_modules/express/bin/express +66 -65
  62. data/server/node_modules/express/lib/express.js +1 -1
  63. data/server/node_modules/express/lib/request.js +9 -23
  64. data/server/node_modules/express/lib/response.js +2 -3
  65. data/server/node_modules/express/lib/utils.js +0 -13
  66. data/server/node_modules/express/lib/view.js +16 -19
  67. data/server/node_modules/express/lib/view/view.js +1 -2
  68. data/server/node_modules/express/node_modules/connect/lib/connect.js +1 -1
  69. data/server/node_modules/express/node_modules/connect/lib/http.js +0 -2
  70. data/server/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js +31 -135
  71. data/server/node_modules/express/node_modules/connect/lib/middleware/limit.js +1 -5
  72. data/server/node_modules/express/node_modules/connect/lib/middleware/session.js +2 -2
  73. data/server/node_modules/express/node_modules/connect/lib/middleware/static.js +21 -26
  74. data/server/node_modules/express/node_modules/connect/lib/middleware/staticCache.js +38 -91
  75. data/server/node_modules/express/node_modules/connect/lib/middleware/vhost.js +1 -1
  76. data/server/node_modules/express/node_modules/connect/lib/utils.js +4 -11
  77. data/server/node_modules/express/node_modules/connect/package.json +6 -7
  78. data/server/node_modules/express/node_modules/connect/test.js +31 -44
  79. data/server/node_modules/express/node_modules/mime/index.js +1 -0
  80. data/server/node_modules/express/node_modules/mime/mime.js +3 -3
  81. data/server/node_modules/express/node_modules/mime/{types/mime.types → mime.types} +0 -0
  82. data/server/node_modules/express/node_modules/mime/{types/node.types → node.types} +0 -17
  83. data/server/node_modules/express/node_modules/mime/package.json +10 -21
  84. data/server/node_modules/express/node_modules/mime/test.js +3 -2
  85. data/server/node_modules/express/node_modules/qs/History.md +0 -11
  86. data/server/node_modules/express/node_modules/qs/Makefile +3 -1
  87. data/server/node_modules/express/node_modules/qs/Readme.md +4 -2
  88. data/server/node_modules/express/node_modules/qs/lib/querystring.js +74 -100
  89. data/server/node_modules/express/node_modules/qs/package.json +2 -9
  90. data/server/node_modules/express/node_modules/qs/support/expresso/History.md +128 -0
  91. data/server/node_modules/express/node_modules/qs/support/expresso/Makefile +53 -0
  92. data/server/node_modules/express/node_modules/qs/support/expresso/Readme.md +61 -0
  93. data/server/node_modules/express/node_modules/qs/support/expresso/bin/expresso +856 -0
  94. data/server/node_modules/express/node_modules/qs/support/expresso/docs/api.html +1080 -0
  95. data/server/node_modules/express/node_modules/qs/support/expresso/docs/index.html +377 -0
  96. data/server/node_modules/express/node_modules/qs/support/expresso/docs/index.md +290 -0
  97. data/server/node_modules/express/node_modules/qs/support/expresso/docs/layout/foot.html +3 -0
  98. data/server/node_modules/express/node_modules/qs/support/expresso/docs/layout/head.html +42 -0
  99. data/server/node_modules/express/node_modules/qs/support/expresso/lib/bar.js +4 -0
  100. data/server/node_modules/express/node_modules/qs/support/expresso/lib/foo.js +16 -0
  101. data/server/node_modules/express/node_modules/qs/support/expresso/package.json +12 -0
  102. data/server/node_modules/express/node_modules/qs/support/expresso/test/assert.test.js +91 -0
  103. data/server/node_modules/express/node_modules/qs/support/expresso/test/async.test.js +12 -0
  104. data/server/node_modules/express/node_modules/qs/support/expresso/test/bar.test.js +13 -0
  105. data/server/node_modules/express/node_modules/qs/support/expresso/test/foo.test.js +14 -0
  106. data/server/node_modules/express/node_modules/qs/support/expresso/test/http.test.js +146 -0
  107. data/server/node_modules/express/node_modules/qs/support/expresso/test/serial/async.test.js +39 -0
  108. data/server/node_modules/express/node_modules/qs/support/expresso/test/serial/http.test.js +48 -0
  109. data/server/node_modules/express/node_modules/qs/support/should/History.md +22 -0
  110. data/server/node_modules/express/node_modules/qs/support/should/Makefile +6 -0
  111. data/server/node_modules/express/node_modules/qs/support/should/Readme.md +248 -0
  112. data/server/node_modules/express/node_modules/qs/support/should/examples/runner.js +53 -0
  113. data/server/node_modules/express/node_modules/qs/support/should/index.js +2 -0
  114. data/server/node_modules/express/node_modules/qs/support/should/lib/eql.js +91 -0
  115. data/server/node_modules/express/node_modules/qs/support/should/lib/should.js +548 -0
  116. data/server/node_modules/express/node_modules/qs/support/should/package.json +8 -0
  117. data/server/node_modules/express/node_modules/qs/support/should/test/should.test.js +358 -0
  118. data/server/node_modules/express/node_modules/qs/test/{parse.js → parse.test.js} +2 -1
  119. data/server/node_modules/express/node_modules/qs/test/{stringify.js → stringify.test.js} +0 -0
  120. data/server/node_modules/express/package.json +8 -9
  121. data/server/node_modules/node-uuid/README.md +67 -166
  122. data/server/node_modules/node-uuid/package.json +3 -5
  123. data/server/node_modules/node-uuid/{benchmark → test}/benchmark-native.c +0 -0
  124. data/server/node_modules/node-uuid/test/benchmark.js +27 -0
  125. data/server/node_modules/node-uuid/test/test.html +0 -3
  126. data/server/node_modules/node-uuid/test/test.js +57 -214
  127. data/server/node_modules/node-uuid/uuid.js +56 -225
  128. data/server/node_modules/restler/README.md +7 -20
  129. data/server/node_modules/restler/bin/restler +1 -1
  130. data/server/node_modules/restler/lib/multipartform.js +8 -9
  131. data/server/node_modules/restler/lib/restler.js +22 -64
  132. data/server/node_modules/restler/package.json +2 -2
  133. data/server/node_modules/restler/test/restler.js +2 -22
  134. data/server/node_modules/restler/test/test_helper.js +1 -20
  135. data/server/package.json +10 -10
  136. data/server/web.js +7 -30
  137. metadata +96 -89
  138. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/file/plain.txt +0 -1
  139. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/http/no-filename/generic.http +0 -13
  140. data/server/node_modules/connect-form/node_modules/formidable/test/fixture/js/no-filename.js +0 -3
  141. data/server/node_modules/express/node_modules/connect/node_modules/formidable/Makefile +0 -14
  142. data/server/node_modules/express/node_modules/connect/node_modules/formidable/Readme.md +0 -286
  143. data/server/node_modules/express/node_modules/connect/node_modules/formidable/TODO +0 -3
  144. data/server/node_modules/express/node_modules/connect/node_modules/formidable/benchmark/bench-multipart-parser.js +0 -70
  145. data/server/node_modules/express/node_modules/connect/node_modules/formidable/example/post.js +0 -43
  146. data/server/node_modules/express/node_modules/connect/node_modules/formidable/example/upload.js +0 -48
  147. data/server/node_modules/express/node_modules/connect/node_modules/formidable/index.js +0 -1
  148. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/file.js +0 -61
  149. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/incoming_form.js +0 -377
  150. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/index.js +0 -3
  151. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/multipart_parser.js +0 -312
  152. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/querystring_parser.js +0 -25
  153. data/server/node_modules/express/node_modules/connect/node_modules/formidable/lib/util.js +0 -6
  154. data/server/node_modules/express/node_modules/connect/node_modules/formidable/package.json +0 -22
  155. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/common.js +0 -19
  156. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/funkyfilename.txt +0 -1
  157. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/file/plain.txt +0 -1
  158. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/no-filename/generic.http +0 -13
  159. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/info.md +0 -3
  160. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-chrome-13.http +0 -26
  161. 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
  162. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/osx-safari-5.http +0 -23
  163. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-chrome-12.http +0 -24
  164. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-7.http +0 -22
  165. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-ie-8.http +0 -22
  166. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/http/special-chars-in-filename/xp-safari-5.http +0 -22
  167. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/no-filename.js +0 -3
  168. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/js/special-chars-in-filename.js +0 -21
  169. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multi_video.upload +0 -0
  170. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/fixture/multipart.js +0 -72
  171. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/integration/test-fixtures.js +0 -89
  172. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/common.js +0 -24
  173. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/integration/test-multipart-parser.js +0 -80
  174. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-file.js +0 -104
  175. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-incoming-form.js +0 -715
  176. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-multipart-parser.js +0 -50
  177. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/simple/test-querystring-parser.js +0 -45
  178. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/legacy/system/test-multi-video-upload.js +0 -72
  179. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/run.js +0 -2
  180. data/server/node_modules/express/node_modules/connect/node_modules/formidable/test/unit/test-incoming-form.js +0 -63
  181. data/server/node_modules/express/node_modules/connect/node_modules/formidable/tool/record.js +0 -47
  182. data/server/node_modules/express/node_modules/mkdirp/LICENSE +0 -21
  183. data/server/node_modules/express/node_modules/mkdirp/README.markdown +0 -21
  184. data/server/node_modules/express/node_modules/mkdirp/examples/pow.js +0 -6
  185. data/server/node_modules/express/node_modules/mkdirp/examples/pow.js.orig +0 -6
  186. data/server/node_modules/express/node_modules/mkdirp/examples/pow.js.rej +0 -19
  187. data/server/node_modules/express/node_modules/mkdirp/index.js +0 -20
  188. data/server/node_modules/express/node_modules/mkdirp/package.json +0 -23
  189. data/server/node_modules/express/node_modules/mkdirp/test/mkdirp.js +0 -28
  190. data/server/node_modules/express/node_modules/mkdirp/test/race.js +0 -41
  191. data/server/node_modules/express/node_modules/mkdirp/test/rel.js +0 -32
  192. data/server/node_modules/express/node_modules/qs/test/mocha.opts +0 -2
  193. data/server/node_modules/express/testing/foo/app.js +0 -35
  194. data/server/node_modules/express/testing/foo/package.json +0 -9
  195. data/server/node_modules/express/testing/foo/public/stylesheets/style.css +0 -8
  196. data/server/node_modules/express/testing/foo/routes/index.js +0 -10
  197. data/server/node_modules/express/testing/foo/views/index.jade +0 -2
  198. data/server/node_modules/express/testing/foo/views/layout.jade +0 -6
  199. data/server/node_modules/express/testing/index.js +0 -43
  200. data/server/node_modules/express/testing/public/test.txt +0 -2971
  201. data/server/node_modules/express/testing/views/page.html +0 -1
  202. data/server/node_modules/express/testing/views/page.jade +0 -3
  203. data/server/node_modules/express/testing/views/test.md +0 -1
  204. data/server/node_modules/express/testing/views/user/index.jade +0 -1
  205. data/server/node_modules/express/testing/views/user/list.jade +0 -1
  206. data/server/node_modules/node-uuid/benchmark/README.md +0 -53
  207. data/server/node_modules/node-uuid/benchmark/bench.gnu +0 -174
  208. data/server/node_modules/node-uuid/benchmark/bench.sh +0 -34
  209. data/server/node_modules/node-uuid/benchmark/benchmark.js +0 -84
  210. data/server/node_modules/node-uuid/test/benchmark-native +0 -0
  211. data/server/node_modules/node-uuid/test/compare_v1.js +0 -63
@@ -1,12 +1,10 @@
1
- Restler 0.2.4
1
+ Restler 0.2.0
2
2
  ===========
3
3
 
4
4
  (C) Dan Webb (dan@danwebb.net/@danwrong) 2011, Licensed under the MIT-LICENSE
5
5
 
6
6
  An HTTP client library for node.js (0.3 and up). Hides most of the complexity of creating and using http.Client. Very early days yet.
7
7
 
8
- See [Version History](https://github.com/danwrong/restler/wiki/Version-History) for changes
9
-
10
8
 
11
9
  Features
12
10
  --------
@@ -21,9 +19,8 @@ Features
21
19
  * Transparently handle SSL (just specify https in the URL)
22
20
  * Deals with basic auth for you, just provide username and password options
23
21
  * Simple service wrapper that allows you to easily put together REST API libraries
24
- * Transparently handle content-encoded responses (gzip, deflate)
25
-
26
-
22
+
23
+
27
24
  API
28
25
  ---
29
26
 
@@ -71,12 +68,9 @@ All of these attempt to turn the response into a JavaScript object. In order to
71
68
 
72
69
  * _method_ Request method, can be get, post, put, del
73
70
  * _query_ Query string variables as a javascript object, will override the querystring in the URL
74
- * _data_ The data to be added to the body of the request. Can be a string or any object.
75
- Note that if you want your request body to be JSON with the Content-Type `application/json`, you need to
76
- JSON.stringify your object first. Otherwise, it will be sent as `application/x-www-form-urlencoded` and encoded accordingly.
71
+ * _data_ The data to be added to the body of the request. Can be a string or any object
77
72
  * _parser_ A function that will be called on the returned data. try parsers.auto, parsers.json etc
78
73
  * _encoding_ The encoding of the request body. defaults to utf8
79
- * _decoding_ The encoding of the response body. For a list of supported values see [Buffers](http://nodejs.org/docs/latest/api/buffers.html#buffers). Additionally accepts `"buffer"` - returns response as `Buffer`. Defaults to `utf8`.
80
74
  * _headers_ a hash of HTTP headers to be sent
81
75
  * _username_ Basic auth username
82
76
  * _password_ Basic auth password
@@ -88,7 +82,7 @@ JSON.stringify your object first. Otherwise, it will be sent as `application/x-w
88
82
  Example usage
89
83
  -------------
90
84
 
91
- var sys = require('util'),
85
+ var sys = require('sys'),
92
86
  rest = require('./restler');
93
87
 
94
88
  rest.get('http://google.com').on('complete', function(data) {
@@ -118,7 +112,7 @@ Example usage
118
112
  password: 'wouldntyouliketoknow',
119
113
  data: {
120
114
  'sound[message]': 'hello from restler!',
121
- 'sound[file]': rest.file('doug-e-fresh_the-show.mp3', null, null, null, 'audio/mpeg')
115
+ 'sound[file]': rest.file('doug-e-fresh_the-show.mp3', 'audio/mpeg')
122
116
  }
123
117
  }).on('complete', function(data) {
124
118
  sys.puts(data.audio_url);
@@ -141,13 +135,6 @@ Example usage
141
135
  sys.p(data);
142
136
  });
143
137
 
144
- // the JSON post
145
- rest.post('http://example.com/action', {
146
- data: JSON.stringify({ id: 334 }),
147
- }).on('complete', function(data, response) {
148
- // you can get at the raw response like this...
149
- });
150
-
151
138
 
152
139
  Running the tests
153
140
  -----------------
@@ -157,4 +144,4 @@ Running the tests
157
144
  TODO
158
145
  ----
159
146
  * Deal with no utf-8 response bodies
160
- * What do you need? Let me know or fork.
147
+ * What do you need? Let me know or fork.
@@ -2,7 +2,7 @@
2
2
 
3
3
  require.paths.push(process.cwd());
4
4
 
5
- var sys = require('util'),
5
+ var sys = require('sys'),
6
6
  rest = require('../lib/restler'),
7
7
  repl = require('repl');
8
8
 
@@ -1,5 +1,5 @@
1
1
  var fs = require('fs');
2
- var sys = require('util')
2
+ var sys = require("sys")
3
3
  exports.defaultBoundary = '48940923NODERESLTER3890457293';
4
4
 
5
5
 
@@ -109,7 +109,7 @@ Part.prototype = {
109
109
  fs.open(this.value.path, "r", 0666, function (err, fd) {
110
110
  if (err) throw err;
111
111
 
112
- var position = 0;
112
+ position = 0;
113
113
 
114
114
  (function reader () {
115
115
  fs.read(fd, 1024 * 4, position, "binary", function (er, chunk) {
@@ -142,13 +142,12 @@ function MultiPartRequest(data, boundary) {
142
142
 
143
143
  MultiPartRequest.prototype = {
144
144
  _partNames: function() {
145
- var partNames = [];
146
- for (var name in this.data) {
147
- partNames.push(name)
145
+ partNames = []
146
+ for (var name in this.data) {
147
+ partNames.push(name)
148
148
  }
149
149
  return partNames;
150
150
  },
151
-
152
151
  write: function(stream, callback) {
153
152
  var partCount = 0, self = this;
154
153
 
@@ -158,8 +157,8 @@ MultiPartRequest.prototype = {
158
157
 
159
158
  // Let each part write itself out to the stream
160
159
  (function writePart() {
161
- var partName = self.partNames[partCount];
162
- var part = new Part(partName, self.data[partName], self.boundary);
160
+ partName = this.partNames[partCount];
161
+ part = new Part(partName, self.data[partName], self.boundary);
163
162
  part.write(stream, function (err) {
164
163
  if (err) {
165
164
  callback(err);
@@ -200,4 +199,4 @@ var exportMethods = {
200
199
 
201
200
  Object.keys(exportMethods).forEach(function(exportMethod) {
202
201
  exports[exportMethod] = exportMethods[exportMethod]
203
- })
202
+ })
@@ -1,10 +1,9 @@
1
- var sys = require('util'),
1
+ var sys = require('sys'),
2
2
  http = require('http'),
3
3
  https = require('https'),
4
4
  url = require('url'),
5
5
  qs = require('querystring'),
6
- multipart = require('./multipartform'),
7
- zlib = require('zlib');
6
+ multipart = require('./multipartform');
8
7
 
9
8
  function mixin(target, source) {
10
9
  Object.keys(source).forEach(function(key) {
@@ -21,7 +20,7 @@ function Request(uri, options) {
21
20
  'Accept': '*/*',
22
21
  'User-Agent': 'Restler for node.js',
23
22
  'Host': this.url.host
24
- };
23
+ }
25
24
 
26
25
  mixin(this.headers, options.headers || {});
27
26
 
@@ -47,11 +46,6 @@ function Request(uri, options) {
47
46
  this.headers['Content-Type'] = 'application/x-www-form-urlencoded';
48
47
  this.headers['Content-Length'] = this.options.data.length;
49
48
  }
50
- if(typeof this.options.data == 'string') {
51
- var buffer = new Buffer(this.options.data, this.options.encoding || 'utf8');
52
- this.options.data = buffer;
53
- this.headers['Content-Length'] = buffer.length;
54
- }
55
49
  }
56
50
 
57
51
  var proto = (this.url.protocol == 'https:') ? https : http;
@@ -68,10 +62,9 @@ function Request(uri, options) {
68
62
  }
69
63
 
70
64
  Request.prototype = new process.EventEmitter();
71
-
72
65
  mixin(Request.prototype, {
73
66
  _isRedirect: function(response) {
74
- return ([301, 302, 303].indexOf(response.statusCode) >= 0);
67
+ return ([301, 302].indexOf(response.statusCode) >= 0);
75
68
  },
76
69
  _fullPath: function() {
77
70
  var path = this.url.pathname || '/';
@@ -108,46 +101,25 @@ mixin(Request.prototype, {
108
101
  } else {
109
102
  var body = '';
110
103
 
111
- response.setEncoding('binary');
104
+ // TODO Handle different encodings
105
+ response.setEncoding('utf8');
112
106
 
113
107
  response.on('data', function(chunk) {
114
108
  body += chunk;
115
109
  });
116
110
 
117
111
  response.on('end', function() {
118
- self._decode(new Buffer(body, 'binary'), response, function(err, body) {
119
- if (err) {
120
- self._respond('error', '', 'Failed to decode response body');
121
- return;
122
- }
123
- self._encode(body, response, function(body) {
124
- self._fireEvents(body, response);
125
- });
126
- });
112
+ if (self.options.parser) {
113
+ self.options.parser.call(response, body, function(parsedData) {
114
+
115
+ self._fireEvents(parsedData, response);
116
+ });
117
+ } else {
118
+ self._fireEvents(body, response);
119
+ }
127
120
  });
128
121
  }
129
122
  },
130
- _decode: function(body, response, callback) {
131
- var encoder = response.headers['content-encoding'];
132
- if (encoder in decoders) {
133
- decoders[encoder].call(response, body, callback);
134
- } else {
135
- callback(null, body);
136
- }
137
- },
138
- _encode: function(body, response, callback) {
139
- var self = this;
140
- if (self.options.decoding == 'buffer') {
141
- callback(body);
142
- } else {
143
- body = body.toString(self.options.decoding);
144
- if (self.options.parser) {
145
- self.options.parser.call(response, body, callback);
146
- } else {
147
- callback(body);
148
- }
149
- }
150
- },
151
123
  _respond: function(type, data, response) {
152
124
  if (this.options.originalRequest) {
153
125
  this.options.originalRequest.emit(type, data, response);
@@ -163,11 +135,11 @@ mixin(Request.prototype, {
163
135
  this._respond(response.statusCode.toString(), body, response);
164
136
  this._respond('complete', body, response);
165
137
  },
166
- _makeRequest: function() {
138
+ _makeRequest: function() {
167
139
  var self = this;
168
140
 
169
141
  this.request.on('response', function(response) {
170
- self._responseHandler(response);
142
+ self._responseHandler(response);
171
143
  }).on('error', function(err) {
172
144
  self._respond('error', null, err);
173
145
  });
@@ -183,7 +155,7 @@ mixin(Request.prototype, {
183
155
  if (this.options.data) {
184
156
  this.request.write(this.options.data.toString(), this.options.encoding || 'utf8');
185
157
  }
186
- this.request.end();
158
+ this.request.end();
187
159
  }
188
160
 
189
161
  return this;
@@ -198,9 +170,7 @@ function shortcutOptions(options, method) {
198
170
  }
199
171
 
200
172
  function request(url, options) {
201
- var request = new Request(url, options);
202
- request.on('error', function() {});
203
- return request.run();
173
+ return (new Request(url, options)).run();
204
174
  }
205
175
 
206
176
  function get(url, options) {
@@ -237,7 +207,7 @@ var parsers = {
237
207
  json: function(data, callback) {
238
208
  callback(data && JSON.parse(data));
239
209
  }
240
- };
210
+ }
241
211
 
242
212
  parsers.auto.matchers = {
243
213
  'application/json': parsers.json
@@ -263,27 +233,15 @@ try {
263
233
  parser.on('end', function(result) {
264
234
  callback(result);
265
235
  });
266
- try {
267
- parser.parseString(data);
268
- } catch (e) {
269
- callback({error:'Oops, something went wrong.'});
270
- }
236
+
237
+ parser.parseString(data);
271
238
  } else {
272
239
  callback();
273
240
  }
274
241
  };
275
242
 
276
243
  parsers.auto.matchers['application/xml'] = parsers.xml;
277
- } catch(e) { }
278
-
279
- var decoders = {
280
- gzip: function(buf, callback) {
281
- zlib.gunzip(buf, callback);
282
- },
283
- deflate: function(buf, callback) {
284
- zlib.inflate(buf, callback);
285
- }
286
- };
244
+ } catch(e) {}
287
245
 
288
246
 
289
247
  function Service(defaults) {
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "restler",
3
- "version": "0.2.4",
3
+ "version": "0.2.1",
4
4
  "description": "An HTTP client library for node.js",
5
5
  "contributors": [{ "name": "Dan Webb", "email": "dan@danwebb.net" }],
6
6
  "homepage": "https://github.com/danwrong/restler",
7
7
  "directories" : { "lib" : "./lib" },
8
8
  "main" : "./lib/restler",
9
9
  "engines": { "node": ">= 0.3.7" }
10
- }
10
+ }
@@ -1,6 +1,6 @@
1
1
  var helper = require('./test_helper'),
2
2
  rest = require('../lib/restler'),
3
- sys = require('util');
3
+ sys = require('sys');
4
4
 
5
5
  helper.testCase("Basic Tests", helper.echoServer, {
6
6
  testRequestShouldTakePath: function(host, test) {
@@ -145,24 +145,4 @@ helper.testCase('Redirect Tests', helper.redirectServer, {
145
145
  test.equal('Hell Yeah!', data, "returned " + sys.inspect(data));
146
146
  });
147
147
  }
148
- });
149
-
150
- helper.testCase('Content-Length Tests', helper.contentLengthServer, {
151
- testRequestHeaderIncludesContentLengthWithJSONData: function(host, test){
152
- var jsonString = JSON.stringify({ greeting: 'hello world' });
153
- rest.post(host, {
154
- data: jsonString
155
- }).on('complete', function(data){
156
- test.equal(26, data, 'should set content-length');
157
- });
158
- },
159
- testJSONMultibyteContentLength: function (host, test){
160
- var multibyteData = JSON.stringify({ greeting: 'こんにちは世界' });
161
- rest.post(host, {
162
- data: multibyteData
163
- }).on('complete', function(data) {
164
- test.notEqual(22, data, 'should unicode string length');
165
- test.equal(36, data, 'should byte-size content-length');
166
- });
167
- }
168
- });
148
+ });
@@ -1,5 +1,5 @@
1
1
  var http = require("http"),
2
- sys = require('util'),
2
+ sys = require('sys'),
3
3
  test = require('assert');
4
4
 
5
5
  exports.echoServer = function() {
@@ -84,25 +84,6 @@ exports.redirectServer = function() {
84
84
  return ["http://localhost:" + port, server];
85
85
  }
86
86
 
87
- exports.contentLengthServer = function (){
88
- var port = exports.port++;
89
-
90
- var server = http.createServer(function(request, response){
91
- response.writeHead(200, { 'Content-Type': 'text/plain' });
92
- if('content-length' in request.headers){
93
- response.write(request.headers['content-length']);
94
- } else {
95
- response.write('content-length isnot set');
96
- }
97
-
98
- response.end();
99
- server.close();
100
- });
101
-
102
- server.listen(port, 'localhost');
103
- return ['http://localhost:' + port, server];
104
- };
105
-
106
87
  exports.port = 7000;
107
88
 
108
89
  exports.testCase = function(caseName, serverFunc, tests) {
data/server/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "heroku-make",
3
3
  "version": "0.0.1",
4
- "dependencies": {
5
- "connect-form": "0.2.1",
6
- "cradle": "0.5.8",
7
- "express": "2.5.6",
8
- "knox": "0.0.9",
9
- "node-uuid": "1.3.3",
10
- "restler": "0.2.4"
11
- },
4
+ "dependencies": [
5
+ "connect-form",
6
+ "cradle",
7
+ "express",
8
+ "knox",
9
+ "node-uuid",
10
+ "restler"
11
+ ],
12
12
  "engines": {
13
- "node": "0.6.x",
14
- "npm": "1.0.x"
13
+ "node": ">=0.4.7 <0.6.0",
14
+ "npm": ">=1.0.0"
15
15
  }
16
16
  }
data/server/web.js CHANGED
@@ -1,8 +1,10 @@
1
+ require.paths.unshift(__dirname + '/lib');
2
+
1
3
  var cradle = require('cradle');
2
4
  var express = require('express');
3
5
  var fs = require('fs');
4
6
  var spawner = require('spawner').create();
5
- var util = require('util');
7
+ var sys = require('sys');
6
8
  var uuid = require('node-uuid');
7
9
 
8
10
  var app = express.createServer(
@@ -12,14 +14,6 @@ var app = express.createServer(
12
14
  require('connect-form')({ keepExtensions: true })
13
15
  );
14
16
 
15
- function log_action(uuid, message) {
16
- console.log(uuid + ': ' + message);
17
- }
18
-
19
- function log_error(uuid, message) {
20
- log_action(uuid, 'ERROR: ' + message);
21
- }
22
-
23
17
  // connect to couchdb
24
18
  var couchdb_url = require('url').parse(process.env.CLOUDANT_URL);
25
19
  var couchdb_options = couchdb_url.auth ?
@@ -33,7 +27,6 @@ app.post('/make', function(request, response, next) {
33
27
 
34
28
  // require a form
35
29
  if (! request.form) {
36
- console.log('invalid form');
37
30
  response.write('invalid form');
38
31
  response.send(500);
39
32
  } else {
@@ -55,12 +48,10 @@ app.post('/make', function(request, response, next) {
55
48
  var prefix = fields.prefix;
56
49
 
57
50
  // create a couchdb documents for this build
58
- log_action(id, 'saving to couchdb');
59
51
  db.save(id, { command:command, prefix:prefix }, function(err, doc) {
60
- if (err) { log_error(id, util.inspect(err)); return next(err); }
52
+ if (err) { return next(err); }
61
53
 
62
54
  // save the input tarball as an attachment
63
- log_action(id, 'saving attachment - [id:' + doc.id + ', rev:' + doc.rev + ']')
64
55
  db.saveAttachment(
65
56
  doc.id,
66
57
  doc.rev,
@@ -68,26 +59,16 @@ app.post('/make', function(request, response, next) {
68
59
  'application/octet-stream',
69
60
  fs.createReadStream(files.code.path),
70
61
  function(err, data) {
71
- if (err) {
72
- // work around temporary problem with cloudant and document
73
- // conflicts
74
- if (err.error != 'conflict') {
75
- log_error(id, err.reason);
76
- return next(err.reason);
77
- }
78
- }
62
+ if (err) { return next(err); }
79
63
 
80
64
  // spawn bin/make with this build id
81
- log_action(id, 'spawning build');
82
65
  var ls = spawner.spawn('bin/make ' + id, function(err) {
83
- log_error(id, 'could not spawn: ' + err);
84
66
  response.write('could not spawn: ' + err);
85
67
  response.send(500);
86
68
  });
87
69
 
88
70
  ls.on('error', function(error) {
89
- log_error(id, 'spawn error: ' + util.inspect(error));
90
- response.write('error: ' + util.inspect(error));
71
+ response.write('error: ' + err);
91
72
  response.send(500);
92
73
  });
93
74
 
@@ -105,7 +86,7 @@ app.post('/make', function(request, response, next) {
105
86
  response.header('X-Make-Id', id);
106
87
  });
107
88
  }
108
-
89
+
109
90
  });
110
91
  }
111
92
  });
@@ -116,10 +97,6 @@ app.get('/output/:id', function(request, response, next) {
116
97
  // from couchdb
117
98
  var stream = db.getAttachment(request.params.id, 'output');
118
99
 
119
- stream.on('error', function(err) {
120
- console.log('download error: ' + err);
121
- });
122
-
123
100
  stream.on('data', function(chunk) {
124
101
  response.write(chunk, 'binary');
125
102
  });