traceur-rb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (255) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +22 -0
  3. data/.rspec +1 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +4 -0
  7. data/Guardfile +8 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +87 -0
  10. data/Rakefile +2 -0
  11. data/lib/js/compile.js +31 -0
  12. data/lib/traceur-rb.rb +1 -0
  13. data/lib/traceur.rb +43 -0
  14. data/lib/traceur/compilation_options.rb +65 -0
  15. data/lib/traceur/compiler.rb +33 -0
  16. data/lib/traceur/configuration.rb +47 -0
  17. data/lib/traceur/node.rb +26 -0
  18. data/lib/traceur/node/command_result.rb +28 -0
  19. data/lib/traceur/node/runner.rb +40 -0
  20. data/lib/traceur/version.rb +3 -0
  21. data/spec/examples/classes.js +12 -0
  22. data/spec/integration/examples_spec.rb +28 -0
  23. data/spec/spec_helper.rb +1 -0
  24. data/spec/traceur/compilation_options_spec.rb +31 -0
  25. data/spec/traceur/configuration_spec.rb +54 -0
  26. data/spec/traceur/node_spec.rb +15 -0
  27. data/traceur-rb.gemspec +25 -0
  28. data/vendor/node_modules/.bin/traceur +3 -0
  29. data/vendor/node_modules/traceur/README.md +40 -0
  30. data/vendor/node_modules/traceur/bin/traceur-runtime.js +2101 -0
  31. data/vendor/node_modules/traceur/bin/traceur.js +23034 -0
  32. data/vendor/node_modules/traceur/node_modules/.bin/semver +125 -0
  33. data/vendor/node_modules/traceur/node_modules/commander/Readme.md +208 -0
  34. data/vendor/node_modules/traceur/node_modules/commander/index.js +852 -0
  35. data/vendor/node_modules/traceur/node_modules/commander/package.json +40 -0
  36. data/vendor/node_modules/traceur/node_modules/q-io/.npmignore +1 -0
  37. data/vendor/node_modules/traceur/node_modules/q-io/.travis.yml +3 -0
  38. data/vendor/node_modules/traceur/node_modules/q-io/CHANGES.md +122 -0
  39. data/vendor/node_modules/traceur/node_modules/q-io/LICENSE +19 -0
  40. data/vendor/node_modules/traceur/node_modules/q-io/README.md +928 -0
  41. data/vendor/node_modules/traceur/node_modules/q-io/buffer-stream.js +59 -0
  42. data/vendor/node_modules/traceur/node_modules/q-io/coverage-report.js +44 -0
  43. data/vendor/node_modules/traceur/node_modules/q-io/deprecate.js +51 -0
  44. data/vendor/node_modules/traceur/node_modules/q-io/fs-boot.js +307 -0
  45. data/vendor/node_modules/traceur/node_modules/q-io/fs-common.js +499 -0
  46. data/vendor/node_modules/traceur/node_modules/q-io/fs-mock.js +547 -0
  47. data/vendor/node_modules/traceur/node_modules/q-io/fs-root.js +105 -0
  48. data/vendor/node_modules/traceur/node_modules/q-io/fs.js +355 -0
  49. data/vendor/node_modules/traceur/node_modules/q-io/fs2http.js +65 -0
  50. data/vendor/node_modules/traceur/node_modules/q-io/http-apps.js +152 -0
  51. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/chain.js +24 -0
  52. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/content.js +93 -0
  53. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/cookie.js +154 -0
  54. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/decorators.js +178 -0
  55. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/fs.js +417 -0
  56. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/html.js +58 -0
  57. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/json.js +78 -0
  58. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/negotiate.js +120 -0
  59. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/proxy.js +27 -0
  60. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/redirect.js +209 -0
  61. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/route.js +125 -0
  62. data/vendor/node_modules/traceur/node_modules/q-io/http-apps/status.js +175 -0
  63. data/vendor/node_modules/traceur/node_modules/q-io/http-cookie.js +75 -0
  64. data/vendor/node_modules/traceur/node_modules/q-io/http.js +378 -0
  65. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/.npmignore +11 -0
  66. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/.travis.yml +4 -0
  67. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/CHANGES.md +78 -0
  68. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/LICENSE.md +21 -0
  69. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/README.md +1285 -0
  70. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/collections.js +22 -0
  71. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/dict.js +142 -0
  72. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/fast-map.js +57 -0
  73. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/fast-set.js +183 -0
  74. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-collection.js +261 -0
  75. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-map.js +186 -0
  76. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-order.js +55 -0
  77. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-set.js +59 -0
  78. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/heap.js +236 -0
  79. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/iterator.js +371 -0
  80. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/list.js +435 -0
  81. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/array-changes.js +247 -0
  82. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/map-changes.js +147 -0
  83. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/property-changes.js +448 -0
  84. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/range-changes.js +139 -0
  85. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/lru-map.js +79 -0
  86. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/lru-set.js +142 -0
  87. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/map.js +60 -0
  88. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/multi-map.js +41 -0
  89. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/package.json +12 -0
  90. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/sync +7 -0
  91. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/sync.patch +48 -0
  92. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/weak-map.js +590 -0
  93. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/package.json +49 -0
  94. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/set.js +173 -0
  95. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-array.js +274 -0
  96. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-function.js +59 -0
  97. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-object.js +538 -0
  98. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-regexp.js +14 -0
  99. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim.js +6 -0
  100. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array-map.js +49 -0
  101. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array-set.js +51 -0
  102. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array.js +269 -0
  103. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-map.js +61 -0
  104. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-set.js +736 -0
  105. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/tree-log.js +40 -0
  106. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/weak-map.js +1 -0
  107. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/LICENSE +19 -0
  108. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/README.md +66 -0
  109. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/mime.js +114 -0
  110. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/package.json +35 -0
  111. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/test.js +84 -0
  112. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/types/mime.types +1588 -0
  113. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/types/node.types +77 -0
  114. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/CHANGES +15 -0
  115. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/LICENSE +19 -0
  116. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/README +96 -0
  117. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/lib/mimeparse.js +166 -0
  118. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/package.json +43 -0
  119. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/CONTRIBUTING.md +40 -0
  120. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/LICENSE +19 -0
  121. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/README.md +813 -0
  122. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/benchmark/compare-with-callbacks.js +71 -0
  123. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/benchmark/scenarios.js +36 -0
  124. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/package.json +93 -0
  125. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/q.js +1937 -0
  126. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/queue.js +35 -0
  127. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/.gitmodules +6 -0
  128. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/History.md +36 -0
  129. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/Makefile +7 -0
  130. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/Readme.md +38 -0
  131. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/benchmark.js +32 -0
  132. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/examples.js +39 -0
  133. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/index.js +2 -0
  134. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/lib/querystring.js +123 -0
  135. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/package.json +19 -0
  136. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/.gitmodules +3 -0
  137. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/.npmignore +3 -0
  138. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/History.md +128 -0
  139. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/Makefile +53 -0
  140. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/Readme.md +61 -0
  141. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/bin/expresso +856 -0
  142. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/api.html +1080 -0
  143. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/index.html +377 -0
  144. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/index.md +290 -0
  145. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/layout/foot.html +3 -0
  146. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/layout/head.html +42 -0
  147. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/lib/bar.js +4 -0
  148. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/lib/foo.js +16 -0
  149. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/package.json +12 -0
  150. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/assert.test.js +91 -0
  151. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/async.test.js +12 -0
  152. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/bar.test.js +13 -0
  153. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/foo.test.js +14 -0
  154. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/http.test.js +146 -0
  155. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/serial/async.test.js +39 -0
  156. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/serial/http.test.js +48 -0
  157. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/.gitmodules +3 -0
  158. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/History.md +22 -0
  159. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/Makefile +6 -0
  160. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/Readme.md +248 -0
  161. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/examples/runner.js +53 -0
  162. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/index.js +2 -0
  163. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/lib/eql.js +91 -0
  164. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/lib/should.js +548 -0
  165. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/package.json +8 -0
  166. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/test/should.test.js +358 -0
  167. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/test/querystring.test.js +133 -0
  168. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/.npmignore +3 -0
  169. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/.travis.yml +4 -0
  170. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/LICENSE.md +20 -0
  171. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/README.md +33 -0
  172. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/package.json +37 -0
  173. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/test/url2-spec.js +125 -0
  174. data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/url2.js +151 -0
  175. data/vendor/node_modules/traceur/node_modules/q-io/package.json +51 -0
  176. data/vendor/node_modules/traceur/node_modules/q-io/reader.js +133 -0
  177. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/boot-directory-spec.js +47 -0
  178. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/contains-spec.js +11 -0
  179. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/fixtures/hello.txt +1 -0
  180. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/issues/1-spec.js +33 -0
  181. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/make-tree-spec.js +92 -0
  182. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/append-spec.js +41 -0
  183. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/copy-tree-spec.js +57 -0
  184. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/fixture/hello.txt +1 -0
  185. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/link-spec.js +70 -0
  186. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/make-tree-spec.js +109 -0
  187. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/merge-spec.js +67 -0
  188. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/move-spec.js +219 -0
  189. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/object-spec.js +20 -0
  190. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/range-spec.js +26 -0
  191. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/read-spec.js +40 -0
  192. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/remove-directory-spec.js +37 -0
  193. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/remove-tree-spec.js +39 -0
  194. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/root-spec.js +32 -0
  195. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/stat-spec.js +26 -0
  196. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/symbolic-link-spec.js +86 -0
  197. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/working-directory-spec.js +31 -0
  198. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/write-spec.js +73 -0
  199. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/range-spec.js +23 -0
  200. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/range-spec.txt +1 -0
  201. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/read-spec.js +22 -0
  202. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/relative-spec.js +25 -0
  203. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/reroot-spec.js +45 -0
  204. data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/write-spec.js +38 -0
  205. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/cookie-spec.js +52 -0
  206. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/directory-list-spec.js +86 -0
  207. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/01234.txt +1 -0
  208. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/1234.txt +1 -0
  209. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/5678.txt +0 -0
  210. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/9012/3456.txt +0 -0
  211. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/hosts-spec.js +49 -0
  212. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/interpret-range-spec.js +47 -0
  213. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/partial-range-spec.js +186 -0
  214. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/proxy-spec.js +82 -0
  215. data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/symbolic-link-spec.js +110 -0
  216. data/vendor/node_modules/traceur/node_modules/q-io/spec/http/agent-spec.js +96 -0
  217. data/vendor/node_modules/traceur/node_modules/q-io/spec/http/basic-spec.js +96 -0
  218. data/vendor/node_modules/traceur/node_modules/q-io/spec/lib/jasmine-promise.js +42 -0
  219. data/vendor/node_modules/traceur/node_modules/q-io/writer.js +111 -0
  220. data/vendor/node_modules/traceur/node_modules/semver/.npmignore +1 -0
  221. data/vendor/node_modules/traceur/node_modules/semver/LICENSE +27 -0
  222. data/vendor/node_modules/traceur/node_modules/semver/Makefile +24 -0
  223. data/vendor/node_modules/traceur/node_modules/semver/README.md +158 -0
  224. data/vendor/node_modules/traceur/node_modules/semver/bin/semver +125 -0
  225. data/vendor/node_modules/traceur/node_modules/semver/foot.js +6 -0
  226. data/vendor/node_modules/traceur/node_modules/semver/head.js +2 -0
  227. data/vendor/node_modules/traceur/node_modules/semver/package.json +31 -0
  228. data/vendor/node_modules/traceur/node_modules/semver/semver.browser.js +1039 -0
  229. data/vendor/node_modules/traceur/node_modules/semver/semver.browser.js.gz +0 -0
  230. data/vendor/node_modules/traceur/node_modules/semver/semver.js +1043 -0
  231. data/vendor/node_modules/traceur/node_modules/semver/semver.min.js +1 -0
  232. data/vendor/node_modules/traceur/node_modules/semver/semver.min.js.gz +0 -0
  233. data/vendor/node_modules/traceur/node_modules/semver/test/amd.js +15 -0
  234. data/vendor/node_modules/traceur/node_modules/semver/test/gtr.js +173 -0
  235. data/vendor/node_modules/traceur/node_modules/semver/test/index.js +584 -0
  236. data/vendor/node_modules/traceur/node_modules/semver/test/ltr.js +174 -0
  237. data/vendor/node_modules/traceur/node_modules/semver/test/no-module.js +19 -0
  238. data/vendor/node_modules/traceur/package.json +64 -0
  239. data/vendor/node_modules/traceur/src/node/System.js +31 -0
  240. data/vendor/node_modules/traceur/src/node/api.js +124 -0
  241. data/vendor/node_modules/traceur/src/node/command.js +141 -0
  242. data/vendor/node_modules/traceur/src/node/compile-single-file.js +69 -0
  243. data/vendor/node_modules/traceur/src/node/compiler.js +116 -0
  244. data/vendor/node_modules/traceur/src/node/deferred.js +110 -0
  245. data/vendor/node_modules/traceur/src/node/file-util.js +73 -0
  246. data/vendor/node_modules/traceur/src/node/getopt.js +147 -0
  247. data/vendor/node_modules/traceur/src/node/inline-module.js +149 -0
  248. data/vendor/node_modules/traceur/src/node/interpreter.js +33 -0
  249. data/vendor/node_modules/traceur/src/node/nodeLoader.js +41 -0
  250. data/vendor/node_modules/traceur/src/node/require.js +85 -0
  251. data/vendor/node_modules/traceur/src/node/to-amd-compiler.js +33 -0
  252. data/vendor/node_modules/traceur/src/node/to-commonjs-compiler.js +33 -0
  253. data/vendor/node_modules/traceur/src/node/traceur.js +32 -0
  254. data/vendor/node_modules/traceur/traceur +3 -0
  255. metadata +359 -0
@@ -0,0 +1,178 @@
1
+
2
+ var Q = require("q");
3
+ var HTTP = require("../http");
4
+ var RouteApps = require("./route");
5
+ var StatusApps = require("./status");
6
+
7
+ exports.Normalize = function (app) {
8
+ return function (request, response) {
9
+ var request = HTTP.normalizeRequest(request);
10
+ return Q.when(app(request, response), function (response) {
11
+ return HTTP.normalizeResponse(response);
12
+ });
13
+ };
14
+ };
15
+
16
+ exports.Date = function (app, present) {
17
+ present = present || function () {
18
+ return new Date();
19
+ };
20
+ return RouteApps.Trap(app, function (response, request) {
21
+ response.headers["date"] = "" + present();
22
+ });
23
+ };
24
+
25
+ /**
26
+ * Decorates a JSGI application such that rejected response promises
27
+ * get translated into `500` server error responses with no content.
28
+ *
29
+ * @param {App} app
30
+ * @returns {App}
31
+ */
32
+ exports.Error = function (app, debug) {
33
+ return function (request, response) {
34
+ return Q.when(app(request, response), null, function (error) {
35
+ if (!debug)
36
+ error = undefined;
37
+ return StatusApps.responseForStatus(request, 500, error && error.stack || error);
38
+ });
39
+ };
40
+ };
41
+
42
+ exports.Debug = function (app) {
43
+ return exports.Error(app, true);
44
+ };
45
+
46
+ /**
47
+ * Decorates a Q-JSGI application such that all requests and responses
48
+ * are logged.
49
+ *
50
+ * @param {App} app
51
+ * @returns {App}
52
+ */
53
+ exports.Log = function (app, log, stamp) {
54
+ log = log || console.log;
55
+ stamp = stamp || function (message) {
56
+ return new Date().toISOString() + " " + message;
57
+ };
58
+ return function (request, response) {
59
+ var remoteHost =
60
+ request.remoteHost + ":" +
61
+ request.remotePort;
62
+ var requestLine =
63
+ request.method + " " +
64
+ request.path + " " +
65
+ "HTTP/" + request.version.join(".");
66
+ log(stamp(
67
+ remoteHost + " " +
68
+ "--> " +
69
+ requestLine
70
+ ));
71
+ return Q.when(app(request, response), function (response) {
72
+ if (response) {
73
+ log(stamp(
74
+ remoteHost + " " +
75
+ "<== " +
76
+ response.status + " " +
77
+ requestLine + " " +
78
+ (response.headers["content-length"] || "-")
79
+ ));
80
+ } else {
81
+ log(stamp(
82
+ remoteHost + " " +
83
+ "... " +
84
+ "... " +
85
+ requestLine + " (response undefined / presumed streaming)"
86
+ ));
87
+ }
88
+ return response;
89
+ }, function (reason) {
90
+ log(stamp(
91
+ remoteHost + " " +
92
+ "!!! " +
93
+ requestLine + " " +
94
+ (reason && reason.message || reason)
95
+ ));
96
+ return Q.reject(reason);
97
+ });
98
+ };
99
+ };
100
+
101
+ /**
102
+ * Decorates a Q-JSGI application such that all responses have an
103
+ * X-Response-Time header with the time between the request and the
104
+ * response in milliseconds, not including any time needed to stream
105
+ * the body to the client.
106
+ *
107
+ * @param {App} app
108
+ * @returns {App}
109
+ */
110
+ exports.Time = function (app) {
111
+ return function (request, response) {
112
+ var start = new Date();
113
+ return Q.when(app(request, response), function (response) {
114
+ var stop = new Date();
115
+ if (response && response.headers) {
116
+ response.headers["x-response-time"] = "" + (stop - start);
117
+ }
118
+ return response;
119
+ });
120
+ };
121
+ };
122
+
123
+ /**
124
+ * Decorates a Q-JSGI application such that all responses have the
125
+ * given additional headers. These headers do not override the
126
+ * application's given response headers.
127
+ *
128
+ * @param {Object} headers
129
+ * @param {App} app decorated application.
130
+ */
131
+ exports.Headers = function (app, headers) {
132
+ return function (request, response) {
133
+ return Q.when(app(request, response), function (response) {
134
+ if (response && response.headers) {
135
+ Object.keys(headers).forEach(function (key) {
136
+ if (!(key in response.headers)) {
137
+ response.headers[key] = headers[key];
138
+ }
139
+ });
140
+ }
141
+ return response;
142
+ });
143
+ };
144
+ };
145
+
146
+ var farFuture =
147
+ 1000 * // ms
148
+ 60 * // s
149
+ 60 * // m
150
+ 24 * // h
151
+ 365 * // d
152
+ 10; // years
153
+ exports.Permanent = function (app, future) {
154
+ future = future || function () {
155
+ return new Date(new Date().getTime() + farFuture);
156
+ };
157
+ app = RouteApps.Tap(app, function (request, response) {
158
+ request.permanent = future;
159
+ });
160
+ app = RouteApps.Trap(app, function (response, request) {
161
+ response.headers["expires"] = "" + future();
162
+ });
163
+ return app;
164
+ };
165
+
166
+ /**
167
+ * Wraps a Q-JSGI application in a sequence of decorators.
168
+ * @param {Array * Decorator} decorators
169
+ * @param {App} app
170
+ * @returns {App}
171
+ */
172
+ exports.Decorators = function (decorators, app) {
173
+ decorators.reversed().forEach(function (Middleware) {
174
+ app = Middleware(app);
175
+ });
176
+ return app;
177
+ };
178
+
@@ -0,0 +1,417 @@
1
+
2
+ var Q = require("q");
3
+ var URL = require("url2");
4
+ var MimeTypes = require("mime");
5
+ var FS = require("../fs");
6
+ var StatusApps = require("./status");
7
+ var RedirectApps = require("./redirect");
8
+ var Negotiation = require("./negotiate");
9
+ var HtmlApps = require("./html");
10
+ var Deprecate = require("../deprecate");
11
+
12
+ /**
13
+ * @param {String} path
14
+ * @param {String} contentType
15
+ * @returns {App}
16
+ */
17
+ exports.File = function (path, contentType) {
18
+ return function (request, response) {
19
+ return exports.file(request, String(path), contentType);
20
+ };
21
+ };
22
+
23
+ /**
24
+ * @param {String} path
25
+ * @param {{
26
+ notFound,
27
+ file,
28
+ directory,
29
+ contentType,
30
+ redirectSymbolicLinks:Boolean,
31
+ redirect:Function(location),
32
+ permanent:Boolean
33
+ * }} options
34
+ * @returns {App}
35
+ */
36
+ exports.FileTree = function (root, options) {
37
+ if (!options)
38
+ options = {};
39
+ options.notFound = options.notFound || StatusApps.notFound;
40
+ options.file = options.file || exports.file;
41
+ options.directory = options.directory || exports.directory;
42
+ options.fs = options.fs || FS;
43
+ var fs = options.fs;
44
+ root = fs.canonical(root);
45
+ return function (request, response) {
46
+ var location = URL.parse(request.url);
47
+ request.fs = fs;
48
+ var redirect = options.redirect || (
49
+ request.permanent || options.permanent ?
50
+ RedirectApps.permanentRedirect :
51
+ RedirectApps.temporaryRedirect
52
+ );
53
+ return Q.when(root, function (root) {
54
+ var path = fs.join(root, request.pathInfo.slice(1));
55
+ return Q.when(fs.canonical(path), function (canonical) {
56
+ //TODO remove for 2.0.0
57
+ if (options.followInsecureSymlinks) {
58
+ Deprecate.deprecationWarning("followInsecureSymlinks", "followInsecureSymbolicLinks");
59
+ options.followInsecureSymbolicLinks = true;
60
+ }
61
+ if (!fs.contains(root, canonical) && !options.followInsecureSymbolicLinks)
62
+ return options.notFound(request, response);
63
+ if (path !== canonical && options.redirectSymbolicLinks)
64
+ return redirect(request, fs.relativeFromFile(path, canonical));
65
+ // TODO: relativeFromFile should be designed for URL’s, not generalized paths.
66
+ // HTTP.relative(pathToDirectoryLocation(path), pathToFile/DirectoryLocation(canonical))
67
+ return Q.when(fs.stat(canonical), function (stat) {
68
+ if (stat.isFile()) {
69
+ return options.file(request, canonical, options.contentType, fs);
70
+ } else if (stat.isDirectory()) {
71
+ return options.directory(request, canonical, options.contentType, fs);
72
+ } else {
73
+ return options.notFound(request, response);
74
+ }
75
+ });
76
+ }, function (reason) {
77
+ return options.notFound(request, response);
78
+ });
79
+ });
80
+ };
81
+ };
82
+
83
+ exports.file = function (request, path, contentType, fs) {
84
+ fs = fs || FS;
85
+ // TODO last-modified header
86
+ contentType = contentType || MimeTypes.lookup(path);
87
+ return Q.when(fs.stat(path), function (stat) {
88
+ var etag = exports.etag(stat);
89
+ var options = {
90
+ flags: "rb"
91
+ };
92
+ var range;
93
+ var status = 200;
94
+ var headers = {
95
+ "content-type": contentType,
96
+ etag: etag
97
+ };
98
+
99
+ // Partial range requests
100
+ if ("range" in request.headers) {
101
+ // Invalid cache
102
+ if (
103
+ "if-range" in request.headers &&
104
+ etag != request.headers["if-range"]
105
+ ) {
106
+ // Normal 200 for entire, altered content
107
+ } else {
108
+ // Truncate to the first requested continuous range
109
+ range = interpretFirstRange(request.headers["range"], stat.size);
110
+ // Like Apache, ignore the range header if it is invalid
111
+ if (range) {
112
+ if (range.end > stat.size) {
113
+ range.end = stat.size;
114
+ }
115
+ if (range.end <= range.begin) {
116
+ return StatusApps.responseForStatus(request, 416); // not satisfiable
117
+ }
118
+ status = 206; // partial content
119
+ headers["content-range"] = (
120
+ "bytes " +
121
+ range.begin + "-" + (range.end - 1) +
122
+ "/" + stat.size
123
+ );
124
+ headers["content-length"] = "" + (range.end - range.begin);
125
+ options.begin = range.begin;
126
+ options.end = range.end;
127
+ } else {
128
+ return StatusApps.responseForStatus(request, 416); // not satisfiable
129
+ }
130
+ }
131
+ // Full requests
132
+ } else {
133
+ // Cached
134
+ // We do not use date-based caching
135
+ // TODO consider if-match?
136
+ if (etag == request.headers["if-none-match"])
137
+ return StatusApps.responseForStatus(request, 304);
138
+ headers["content-length"] = "" + stat.size;
139
+ }
140
+
141
+ // TODO sendfile
142
+ return {
143
+ status: status,
144
+ headers: headers,
145
+ body: fs.open(path, options),
146
+ file: path,
147
+ range: range
148
+ };
149
+ });
150
+ };
151
+
152
+ var rangesExpression = /^\s*bytes\s*=\s*(\d*\s*-\s*\d*\s*(?:,\s*\d*\s*-\s*\d*\s*)*)$/;
153
+ var rangeExpression = /^\s*(\d*)\s*-\s*(\d*)\s*$/;
154
+
155
+ var interpretRange = function (text, size) {
156
+ var match = rangeExpression.exec(text);
157
+ if (!match)
158
+ return;
159
+ if (match[1] == "" && match[2] == "")
160
+ return;
161
+ var begin, end;
162
+ if (match[1] == "") {
163
+ begin = 0;
164
+ end = +match[2] + 1;
165
+ } else if (match[2] == "") {
166
+ begin = +match[1];
167
+ end = size;
168
+ } else {
169
+ begin = +match[1];
170
+ end = +match[2] + 1;
171
+ }
172
+ return {
173
+ begin: begin,
174
+ end: end
175
+ };
176
+ };
177
+
178
+ var interpretFirstRange = exports.interpretFirstRange = function (text, size) {
179
+ var match = rangesExpression.exec(text);
180
+ if (!match)
181
+ return;
182
+ var texts = match[1].split(/\s*,\s*/);
183
+ var range = interpretRange(texts[0], size);
184
+ for (var i = 0, ii = texts.length; i < ii; i++) {
185
+ var next = interpretRange(texts[i], size);
186
+ if (next.begin <= range.end) {
187
+ range.end = next.end;
188
+ } else {
189
+ return; // Can't satisfy non-contiguous ranges TODO
190
+ }
191
+ }
192
+ return range;
193
+ };
194
+
195
+ /**
196
+ * @param {Stat}
197
+ * @returns {String}
198
+ */
199
+ exports.etag = function (stat) {
200
+ return [
201
+ stat.node.ino,
202
+ stat.size,
203
+ stat.lastModified().getTime()
204
+ ].join("-");
205
+ };
206
+
207
+ /**
208
+ * @param {Request} request
209
+ * @param {String} path
210
+ * @param {Response}
211
+ */
212
+ exports.directory = function (request, path) {
213
+ var response = StatusApps.notFound(request);
214
+ response.directory = path;
215
+ return response;
216
+ };
217
+
218
+ exports.ListDirectories = function (app, listDirectory) {
219
+ listDirectory = listDirectory || exports.listDirectory;
220
+ return function (request) {
221
+ if (request.directoryIndex) {
222
+ throw new Error("DirectoryIndex must be used after ListDirectories");
223
+ }
224
+ request.listDirectories = true;
225
+ return Q.fcall(app, request)
226
+ .then(function (response) {
227
+ if (response.directory !== void 0) {
228
+ return exports.listDirectory(request, response);
229
+ } else {
230
+ return response;
231
+ }
232
+ });
233
+ };
234
+ };
235
+
236
+ exports.listDirectory = function (request, response) {
237
+ // TODO advisory to have JSON or HTML fragment handler.
238
+ request.location = URL.parse(request.path);
239
+ if (request.location.file) {
240
+ return RedirectApps.redirect(request, request.location.file + "/");
241
+ }
242
+ var handlers = {};
243
+ handlers["text/plain"] = exports.listDirectoryText;
244
+ handlers["text/markdown"] = exports.listDirectoryMarkdown;
245
+ if (request.handleHtmlFragmentResponse) {
246
+ handlers["text/html"] = exports.listDirectoryHtmlFragment;
247
+ }
248
+ if (request.handleJsonResponse) {
249
+ handlers["application/json"] = exports.listDirectoryJson;
250
+ }
251
+ var handleResponse = Negotiation.negotiate(request, handlers) || function () {
252
+ return response;
253
+ };
254
+ return handleResponse(request, response);
255
+ };
256
+
257
+ exports.listDirectoryHtmlFragment = function (request, response) {
258
+ return exports.listDirectoryData(request, response)
259
+ .then(function (data) {
260
+ return {
261
+ status: 200,
262
+ headers: {
263
+ "content-type": "text/html"
264
+ },
265
+ htmlTitle: "Directory Index",
266
+ htmlFragment: {
267
+ forEach: function (write) {
268
+ write("<ul class=\"directory-index\">\n");
269
+ Object.keys(data).sort().forEach(function (name) {
270
+ var stat = data[name];
271
+ var suffix = "";
272
+ if (stat.type === "directory") {
273
+ suffix = "/";
274
+ }
275
+ write(" <li class=\"entry " + stat.type + "\"><a href=\"" + HtmlApps.escapeHtml(name + suffix) + "\">" + HtmlApps.escapeHtml(name + suffix) + "</a></li>\n");
276
+ });
277
+ write("</ul>\n");
278
+ }
279
+ }
280
+ };
281
+ });
282
+ };
283
+
284
+ exports.listDirectoryText = function (request, response) {
285
+ return exports.listDirectoryData(request, response)
286
+ .then(function (data) {
287
+ return {
288
+ status: 200,
289
+ headers: {
290
+ "content-type": "text/plain"
291
+ },
292
+ body: {
293
+ forEach: function (write) {
294
+ Object.keys(data).sort().forEach(function (name) {
295
+ var stat = data[name];
296
+ var suffix = "";
297
+ if (stat.type === "directory") {
298
+ suffix = "/";
299
+ }
300
+ write(name + suffix + "\n");
301
+ });
302
+ }
303
+ }
304
+ };
305
+ });
306
+ };
307
+
308
+ exports.listDirectoryMarkdown = function (request, response) {
309
+ return exports.listDirectoryData(request, response)
310
+ .then(function (data) {
311
+ return {
312
+ status: 200,
313
+ headers: {
314
+ "content-type": "text/plain"
315
+ },
316
+ body: {
317
+ forEach: function (write) {
318
+ write("\n# Directory Index\n\n");
319
+ Object.keys(data).forEach(function (name) {
320
+ var stat = data[name];
321
+ var suffix = "";
322
+ if (stat.type === "directory") {
323
+ suffix = "/";
324
+ }
325
+ write("- " + name + suffix + "\n");
326
+ });
327
+ write("\n");
328
+ }
329
+ }
330
+ };
331
+ });
332
+ };
333
+
334
+ exports.listDirectoryJson = function (request, response) {
335
+ return exports.listDirectoryData(request, response)
336
+ .then(function (data) {
337
+ return {
338
+ status: 200,
339
+ headers: {},
340
+ data: data
341
+ };
342
+ });
343
+ };
344
+
345
+ exports.listDirectoryData = function (request, response) {
346
+ if (!request.fs) {
347
+ throw new Error("Can't list a directory without a designated file system");
348
+ }
349
+ var fs = request.fs;
350
+ return Q.invoke(fs, "list", response.directory)
351
+ .then(function (list) {
352
+ list.sort();
353
+ return list.map(function (name) {
354
+ return Q.invoke(fs, "stat", fs.join(response.directory, name))
355
+ .then(function (stat) {
356
+ if (stat.isDirectory()) {
357
+ return {name: name, stat: {
358
+ type: "directory"
359
+ }};
360
+ } else if (stat.isFile()) {
361
+ return {name: name, stat: {
362
+ type: "file"
363
+ }};
364
+ }
365
+ }, function () {
366
+ // ignore unstatable entries
367
+ });
368
+ })
369
+ })
370
+ .all()
371
+ .then(function (stats) {
372
+ var data = {};
373
+ stats.forEach(function (entry) {
374
+ if (entry) {
375
+ data[entry.name] = entry.stat;
376
+ }
377
+ });
378
+ return data;
379
+ });
380
+ };
381
+
382
+ exports.DirectoryIndex = function (app, indexFile) {
383
+ indexFile = indexFile || "index.html";
384
+ return function (request) {
385
+ request.directoryIndex = true;
386
+ request.location = URL.parse(request.path);
387
+ // redirect index.html to containing directory
388
+ // TODO worry about whether this file actually exists
389
+ if (request.location.file === indexFile) {
390
+ return RedirectApps.redirect(request, ".");
391
+ } else {
392
+ return Q.fcall(app, request)
393
+ .then(function (response) {
394
+ if (response.directory !== void 0) {
395
+ if (request.location.file) {
396
+ return RedirectApps.redirect(request, request.location.file + "/");
397
+ } else {
398
+ var index = request.fs.join(response.directory, indexFile);
399
+ return Q.invoke(request.fs, "isFile", index)
400
+ .then(function (isFile) {
401
+ if (isFile) {
402
+ request.url = URL.resolve(request.url, indexFile);
403
+ request.pathInfo += indexFile;
404
+ return app(request);
405
+ } else {
406
+ return response;
407
+ }
408
+ });
409
+ }
410
+ } else {
411
+ return response;
412
+ }
413
+ });
414
+ }
415
+ };
416
+ };
417
+