traceur-rb 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +22 -0
- data/.rspec +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/Guardfile +8 -0
- data/LICENSE.txt +22 -0
- data/README.md +87 -0
- data/Rakefile +2 -0
- data/lib/js/compile.js +31 -0
- data/lib/traceur-rb.rb +1 -0
- data/lib/traceur.rb +43 -0
- data/lib/traceur/compilation_options.rb +65 -0
- data/lib/traceur/compiler.rb +33 -0
- data/lib/traceur/configuration.rb +47 -0
- data/lib/traceur/node.rb +26 -0
- data/lib/traceur/node/command_result.rb +28 -0
- data/lib/traceur/node/runner.rb +40 -0
- data/lib/traceur/version.rb +3 -0
- data/spec/examples/classes.js +12 -0
- data/spec/integration/examples_spec.rb +28 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/traceur/compilation_options_spec.rb +31 -0
- data/spec/traceur/configuration_spec.rb +54 -0
- data/spec/traceur/node_spec.rb +15 -0
- data/traceur-rb.gemspec +25 -0
- data/vendor/node_modules/.bin/traceur +3 -0
- data/vendor/node_modules/traceur/README.md +40 -0
- data/vendor/node_modules/traceur/bin/traceur-runtime.js +2101 -0
- data/vendor/node_modules/traceur/bin/traceur.js +23034 -0
- data/vendor/node_modules/traceur/node_modules/.bin/semver +125 -0
- data/vendor/node_modules/traceur/node_modules/commander/Readme.md +208 -0
- data/vendor/node_modules/traceur/node_modules/commander/index.js +852 -0
- data/vendor/node_modules/traceur/node_modules/commander/package.json +40 -0
- data/vendor/node_modules/traceur/node_modules/q-io/.npmignore +1 -0
- data/vendor/node_modules/traceur/node_modules/q-io/.travis.yml +3 -0
- data/vendor/node_modules/traceur/node_modules/q-io/CHANGES.md +122 -0
- data/vendor/node_modules/traceur/node_modules/q-io/LICENSE +19 -0
- data/vendor/node_modules/traceur/node_modules/q-io/README.md +928 -0
- data/vendor/node_modules/traceur/node_modules/q-io/buffer-stream.js +59 -0
- data/vendor/node_modules/traceur/node_modules/q-io/coverage-report.js +44 -0
- data/vendor/node_modules/traceur/node_modules/q-io/deprecate.js +51 -0
- data/vendor/node_modules/traceur/node_modules/q-io/fs-boot.js +307 -0
- data/vendor/node_modules/traceur/node_modules/q-io/fs-common.js +499 -0
- data/vendor/node_modules/traceur/node_modules/q-io/fs-mock.js +547 -0
- data/vendor/node_modules/traceur/node_modules/q-io/fs-root.js +105 -0
- data/vendor/node_modules/traceur/node_modules/q-io/fs.js +355 -0
- data/vendor/node_modules/traceur/node_modules/q-io/fs2http.js +65 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps.js +152 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/chain.js +24 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/content.js +93 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/cookie.js +154 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/decorators.js +178 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/fs.js +417 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/html.js +58 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/json.js +78 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/negotiate.js +120 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/proxy.js +27 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/redirect.js +209 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/route.js +125 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-apps/status.js +175 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http-cookie.js +75 -0
- data/vendor/node_modules/traceur/node_modules/q-io/http.js +378 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/.npmignore +11 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/.travis.yml +4 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/CHANGES.md +78 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/LICENSE.md +21 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/README.md +1285 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/collections.js +22 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/dict.js +142 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/fast-map.js +57 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/fast-set.js +183 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-collection.js +261 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-map.js +186 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-order.js +55 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/generic-set.js +59 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/heap.js +236 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/iterator.js +371 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/list.js +435 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/array-changes.js +247 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/map-changes.js +147 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/property-changes.js +448 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/listen/range-changes.js +139 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/lru-map.js +79 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/lru-set.js +142 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/map.js +60 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/multi-map.js +41 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/package.json +12 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/sync +7 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/sync.patch +48 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/node_modules/weak-map/weak-map.js +590 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/package.json +49 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/set.js +173 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-array.js +274 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-function.js +59 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-object.js +538 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim-regexp.js +14 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/shim.js +6 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array-map.js +49 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array-set.js +51 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-array.js +269 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-map.js +61 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/sorted-set.js +736 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/tree-log.js +40 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/collections/weak-map.js +1 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/LICENSE +19 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/README.md +66 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/mime.js +114 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/package.json +35 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/test.js +84 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/types/mime.types +1588 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mime/types/node.types +77 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/CHANGES +15 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/LICENSE +19 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/README +96 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/lib/mimeparse.js +166 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/mimeparse/package.json +43 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/CONTRIBUTING.md +40 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/LICENSE +19 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/README.md +813 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/benchmark/compare-with-callbacks.js +71 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/benchmark/scenarios.js +36 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/package.json +93 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/q.js +1937 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/q/queue.js +35 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/.gitmodules +6 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/History.md +36 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/Makefile +7 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/Readme.md +38 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/benchmark.js +32 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/examples.js +39 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/index.js +2 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/lib/querystring.js +123 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/package.json +19 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/.gitmodules +3 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/.npmignore +3 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/History.md +128 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/Makefile +53 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/Readme.md +61 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/bin/expresso +856 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/api.html +1080 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/index.html +377 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/index.md +290 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/layout/foot.html +3 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/docs/layout/head.html +42 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/lib/bar.js +4 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/lib/foo.js +16 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/package.json +12 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/assert.test.js +91 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/async.test.js +12 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/bar.test.js +13 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/foo.test.js +14 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/http.test.js +146 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/serial/async.test.js +39 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/expresso/test/serial/http.test.js +48 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/.gitmodules +3 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/History.md +22 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/Makefile +6 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/Readme.md +248 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/examples/runner.js +53 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/index.js +2 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/lib/eql.js +91 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/lib/should.js +548 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/package.json +8 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/support/should/test/should.test.js +358 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/qs/test/querystring.test.js +133 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/.npmignore +3 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/.travis.yml +4 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/LICENSE.md +20 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/README.md +33 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/package.json +37 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/test/url2-spec.js +125 -0
- data/vendor/node_modules/traceur/node_modules/q-io/node_modules/url2/url2.js +151 -0
- data/vendor/node_modules/traceur/node_modules/q-io/package.json +51 -0
- data/vendor/node_modules/traceur/node_modules/q-io/reader.js +133 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/boot-directory-spec.js +47 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/contains-spec.js +11 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/fixtures/hello.txt +1 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/issues/1-spec.js +33 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/make-tree-spec.js +92 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/append-spec.js +41 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/copy-tree-spec.js +57 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/fixture/hello.txt +1 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/link-spec.js +70 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/make-tree-spec.js +109 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/merge-spec.js +67 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/move-spec.js +219 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/object-spec.js +20 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/range-spec.js +26 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/read-spec.js +40 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/remove-directory-spec.js +37 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/remove-tree-spec.js +39 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/root-spec.js +32 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/stat-spec.js +26 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/symbolic-link-spec.js +86 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/working-directory-spec.js +31 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/mock/write-spec.js +73 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/range-spec.js +23 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/range-spec.txt +1 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/read-spec.js +22 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/relative-spec.js +25 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/reroot-spec.js +45 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/fs/write-spec.js +38 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/cookie-spec.js +52 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/directory-list-spec.js +86 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/01234.txt +1 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/1234.txt +1 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/5678.txt +0 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/fixtures/9012/3456.txt +0 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/hosts-spec.js +49 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/interpret-range-spec.js +47 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/partial-range-spec.js +186 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/proxy-spec.js +82 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http-apps/symbolic-link-spec.js +110 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http/agent-spec.js +96 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/http/basic-spec.js +96 -0
- data/vendor/node_modules/traceur/node_modules/q-io/spec/lib/jasmine-promise.js +42 -0
- data/vendor/node_modules/traceur/node_modules/q-io/writer.js +111 -0
- data/vendor/node_modules/traceur/node_modules/semver/.npmignore +1 -0
- data/vendor/node_modules/traceur/node_modules/semver/LICENSE +27 -0
- data/vendor/node_modules/traceur/node_modules/semver/Makefile +24 -0
- data/vendor/node_modules/traceur/node_modules/semver/README.md +158 -0
- data/vendor/node_modules/traceur/node_modules/semver/bin/semver +125 -0
- data/vendor/node_modules/traceur/node_modules/semver/foot.js +6 -0
- data/vendor/node_modules/traceur/node_modules/semver/head.js +2 -0
- data/vendor/node_modules/traceur/node_modules/semver/package.json +31 -0
- data/vendor/node_modules/traceur/node_modules/semver/semver.browser.js +1039 -0
- data/vendor/node_modules/traceur/node_modules/semver/semver.browser.js.gz +0 -0
- data/vendor/node_modules/traceur/node_modules/semver/semver.js +1043 -0
- data/vendor/node_modules/traceur/node_modules/semver/semver.min.js +1 -0
- data/vendor/node_modules/traceur/node_modules/semver/semver.min.js.gz +0 -0
- data/vendor/node_modules/traceur/node_modules/semver/test/amd.js +15 -0
- data/vendor/node_modules/traceur/node_modules/semver/test/gtr.js +173 -0
- data/vendor/node_modules/traceur/node_modules/semver/test/index.js +584 -0
- data/vendor/node_modules/traceur/node_modules/semver/test/ltr.js +174 -0
- data/vendor/node_modules/traceur/node_modules/semver/test/no-module.js +19 -0
- data/vendor/node_modules/traceur/package.json +64 -0
- data/vendor/node_modules/traceur/src/node/System.js +31 -0
- data/vendor/node_modules/traceur/src/node/api.js +124 -0
- data/vendor/node_modules/traceur/src/node/command.js +141 -0
- data/vendor/node_modules/traceur/src/node/compile-single-file.js +69 -0
- data/vendor/node_modules/traceur/src/node/compiler.js +116 -0
- data/vendor/node_modules/traceur/src/node/deferred.js +110 -0
- data/vendor/node_modules/traceur/src/node/file-util.js +73 -0
- data/vendor/node_modules/traceur/src/node/getopt.js +147 -0
- data/vendor/node_modules/traceur/src/node/inline-module.js +149 -0
- data/vendor/node_modules/traceur/src/node/interpreter.js +33 -0
- data/vendor/node_modules/traceur/src/node/nodeLoader.js +41 -0
- data/vendor/node_modules/traceur/src/node/require.js +85 -0
- data/vendor/node_modules/traceur/src/node/to-amd-compiler.js +33 -0
- data/vendor/node_modules/traceur/src/node/to-commonjs-compiler.js +33 -0
- data/vendor/node_modules/traceur/src/node/traceur.js +32 -0
- data/vendor/node_modules/traceur/traceur +3 -0
- metadata +359 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
|
2
|
+
var Q = require("q");
|
3
|
+
// TODO negotiate text/html vs text/html+fragment (or other mime type)
|
4
|
+
|
5
|
+
/**
|
6
|
+
* @param {Request} request
|
7
|
+
* @param {String} path
|
8
|
+
* @param {String} contentType
|
9
|
+
* @returns {Response}
|
10
|
+
*/
|
11
|
+
exports.HandleHtmlFragmentResponses = function (app, handleHtmlFragmentResponse) {
|
12
|
+
handleHtmlFragmentResponse = handleHtmlFragmentResponse || exports.handleHtmlFragmentResponse;
|
13
|
+
return function (request) {
|
14
|
+
request.handleHtmlFragmentResponse = handleHtmlFragmentResponse;
|
15
|
+
return Q.fcall(app, request)
|
16
|
+
.then(function (response) {
|
17
|
+
if (response.htmlFragment) {
|
18
|
+
return Q.fcall(handleHtmlFragmentResponse, response);
|
19
|
+
} else {
|
20
|
+
return response;
|
21
|
+
}
|
22
|
+
});
|
23
|
+
};
|
24
|
+
};
|
25
|
+
|
26
|
+
exports.handleHtmlFragmentResponse = function (response) {
|
27
|
+
var htmlFragment = response.htmlFragment;
|
28
|
+
delete response.htmlFragment;
|
29
|
+
response.headers["content-type"] = "text/html; charset=utf-8";
|
30
|
+
response.body = {
|
31
|
+
forEach: function (write) {
|
32
|
+
write("<!doctype html>\n");
|
33
|
+
write("<html>\n");
|
34
|
+
write(" <head>\n");
|
35
|
+
if (response.htmlTitle !== void 0) {
|
36
|
+
write(" <title>" + escapeHtml(response.htmlTitle) + "</title>\n");
|
37
|
+
}
|
38
|
+
write(" </head>\n");
|
39
|
+
write(" <body>\n");
|
40
|
+
htmlFragment.forEach(function (line) {
|
41
|
+
write(" " + line);
|
42
|
+
});
|
43
|
+
write(" </body>\n");
|
44
|
+
write("</html>\n");
|
45
|
+
}
|
46
|
+
};
|
47
|
+
return response;
|
48
|
+
};
|
49
|
+
|
50
|
+
exports.escapeHtml = escapeHtml;
|
51
|
+
function escapeHtml(text) {
|
52
|
+
return String(text)
|
53
|
+
.replace(/&/g, "&")
|
54
|
+
.replace(/</g, "<")
|
55
|
+
.replace(/>/g, ">")
|
56
|
+
.replace(/"/g, """)
|
57
|
+
}
|
58
|
+
|
@@ -0,0 +1,78 @@
|
|
1
|
+
var Q = require("q");
|
2
|
+
var Content = require("./content");
|
3
|
+
var Status = require("./status");
|
4
|
+
|
5
|
+
exports.HandleJsonResponses = function (app, reviver, tab) {
|
6
|
+
return function (request) {
|
7
|
+
request.handleJsonResponse = exports.handleJsonResponse;
|
8
|
+
return Q.fcall(app, request)
|
9
|
+
.then(function (response) {
|
10
|
+
if (response.data !== void 0) {
|
11
|
+
return Q.fcall(exports.handleJsonResponse, response, reviver, tab);
|
12
|
+
} else {
|
13
|
+
return response;
|
14
|
+
}
|
15
|
+
});
|
16
|
+
};
|
17
|
+
};
|
18
|
+
|
19
|
+
exports.handleJsonResponse = function (response, revivier, tab) {
|
20
|
+
response.headers["content-type"] = "application/json";
|
21
|
+
response.body = {
|
22
|
+
forEach: function (write) {
|
23
|
+
write(JSON.stringify(response.data, revivier, tab));
|
24
|
+
}
|
25
|
+
};
|
26
|
+
return response;
|
27
|
+
};
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Wraps a Q-JSGI application such that the child application may
|
31
|
+
* simply return an object, which will in turn be serialized into a
|
32
|
+
* Q-JSGI response.
|
33
|
+
*
|
34
|
+
* @param {Function(Request):Object} app an application that accepts a
|
35
|
+
* request and returns a JSON serializable object.
|
36
|
+
* @returns {App}
|
37
|
+
*/
|
38
|
+
exports.Json = function (app, reviver, tabs) {
|
39
|
+
return function (request, response) {
|
40
|
+
return Q.when(app(request, response), function (object) {
|
41
|
+
return exports.json(object, reviver, tabs);
|
42
|
+
});
|
43
|
+
};
|
44
|
+
};
|
45
|
+
|
46
|
+
/**
|
47
|
+
* @param {Object} content data to serialize as JSON
|
48
|
+
* @param {Function} reviver
|
49
|
+
* @param {Number|String} tabs
|
50
|
+
* @returns {Response}
|
51
|
+
*/
|
52
|
+
exports.json = function (content, reviver, tabs) {
|
53
|
+
try {
|
54
|
+
var json = JSON.stringify(content, reviver, tabs);
|
55
|
+
} catch (exception) {
|
56
|
+
return Q.reject(exception);
|
57
|
+
}
|
58
|
+
return Content.ok([json]);
|
59
|
+
};
|
60
|
+
|
61
|
+
/**
|
62
|
+
* @param {Function(Request, Object):Response} app
|
63
|
+
* @param {App} badRequest
|
64
|
+
* @returns {App}
|
65
|
+
*/
|
66
|
+
exports.JsonRequest = function (app, badRequest) {
|
67
|
+
if (!badRequest)
|
68
|
+
badRequest = Status.badRequest;
|
69
|
+
return Content.ContentRequest(function (content, request, response) {
|
70
|
+
try {
|
71
|
+
var object = JSON.parse(content);
|
72
|
+
} catch (error) {
|
73
|
+
return badRequest(request, error);
|
74
|
+
}
|
75
|
+
return app(object, request, response);
|
76
|
+
});
|
77
|
+
};
|
78
|
+
|
@@ -0,0 +1,120 @@
|
|
1
|
+
|
2
|
+
var Q = require("q");
|
3
|
+
var MimeParse = require("mimeparse");
|
4
|
+
var Status = require("./status");
|
5
|
+
|
6
|
+
exports.negotiate = negotiate;
|
7
|
+
function negotiate(request, types, header) {
|
8
|
+
var keys = Object.keys(types);
|
9
|
+
var accept = request.headers[header || "accept"] || "*";
|
10
|
+
var best = MimeParse.bestMatch(keys, accept);
|
11
|
+
return types[best];
|
12
|
+
}
|
13
|
+
|
14
|
+
/// branch on HTTP method
|
15
|
+
/**
|
16
|
+
* @param {Object * App} methods
|
17
|
+
* @param {App} notAllowed (optional)
|
18
|
+
* @returns {App}
|
19
|
+
*/
|
20
|
+
exports.Method = function (methods, methodNotAllowed) {
|
21
|
+
var keys = Object.keys(methods);
|
22
|
+
if (!methodNotAllowed)
|
23
|
+
methodNotAllowed = exports.methodNotAllowed;
|
24
|
+
return function (request, response) {
|
25
|
+
var method = request.method;
|
26
|
+
if (Object.has(keys, method)) {
|
27
|
+
return Object.get(methods, method)(request, response);
|
28
|
+
} else {
|
29
|
+
return methodNotAllowed(request, response);
|
30
|
+
}
|
31
|
+
};
|
32
|
+
};
|
33
|
+
|
34
|
+
var Negotiator = function (requestHeader, responseHeader, respond) {
|
35
|
+
return function (types, notAcceptable) {
|
36
|
+
var keys = Object.keys(types);
|
37
|
+
if (!notAcceptable)
|
38
|
+
notAcceptable = Status.notAcceptable;
|
39
|
+
return function (request) {
|
40
|
+
var accept = request.headers[requestHeader] || "*";
|
41
|
+
var type = MimeParse.bestMatch(keys, accept);
|
42
|
+
request.terms = request.terms || {};
|
43
|
+
request.terms[responseHeader] = type;
|
44
|
+
if (Object.has(keys, type)) {
|
45
|
+
return Q.when(types[type](request, response), function (response) {
|
46
|
+
if (
|
47
|
+
respond !== null &&
|
48
|
+
response &&
|
49
|
+
response.status === 200 &&
|
50
|
+
response.headers
|
51
|
+
) {
|
52
|
+
response.headers[responseHeader] = type;
|
53
|
+
}
|
54
|
+
return response;
|
55
|
+
});
|
56
|
+
} else {
|
57
|
+
return notAcceptable(request);
|
58
|
+
}
|
59
|
+
};
|
60
|
+
};
|
61
|
+
};
|
62
|
+
|
63
|
+
/// branch on HTTP content negotiation
|
64
|
+
/**
|
65
|
+
* Routes based on content negotiation, between the request's `accept`
|
66
|
+
* header and the application's list of possible content types.
|
67
|
+
*
|
68
|
+
* @param {Object * App} types mapping content types to apps that can
|
69
|
+
* handle them.
|
70
|
+
* @param {App} notAcceptable
|
71
|
+
* @returns {App}
|
72
|
+
*/
|
73
|
+
exports.ContentType = Negotiator("accept", "content-type");
|
74
|
+
exports.Language = Negotiator("accept-language", "language");
|
75
|
+
exports.Charset = Negotiator("accept-charset", "charset");
|
76
|
+
exports.Encoding = Negotiator("accept-encoding", "encoding");
|
77
|
+
|
78
|
+
exports.Host = function (appForHost, notAcceptable) {
|
79
|
+
var table = Object.keys(appForHost).map(function (pattern) {
|
80
|
+
var parts = pattern.split(":");
|
81
|
+
return [
|
82
|
+
pattern,
|
83
|
+
parts[0] || "*",
|
84
|
+
parts[1] || "*",
|
85
|
+
appForHost[pattern]
|
86
|
+
];
|
87
|
+
});
|
88
|
+
if (!notAcceptable) {
|
89
|
+
notAcceptable = Status.notAcceptable;
|
90
|
+
}
|
91
|
+
return function (request) {
|
92
|
+
// find first matching host for app
|
93
|
+
for (var index = 0; index < table.length; index++) {
|
94
|
+
var row = table[index]; // [hostname, port, app]
|
95
|
+
var pattern = row[0];
|
96
|
+
var hostname = row[1];
|
97
|
+
var port = row[2];
|
98
|
+
var app = row[3];
|
99
|
+
if (
|
100
|
+
(hostname === "*" || hostname === request.hostname) &&
|
101
|
+
(port === "*" || port === "" + request.port)
|
102
|
+
) {
|
103
|
+
request.terms = request.terms || {};
|
104
|
+
request.terms.host = pattern;
|
105
|
+
return app(request);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
return notAcceptable(request);
|
109
|
+
};
|
110
|
+
};
|
111
|
+
|
112
|
+
// Branch on a selector function based on the request
|
113
|
+
exports.Select = function (select) {
|
114
|
+
return function (request, response) {
|
115
|
+
return Q.when(select(request, response), function (app) {
|
116
|
+
return app(request, response);
|
117
|
+
});
|
118
|
+
};
|
119
|
+
};
|
120
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
var HTTP = require("../http");
|
3
|
+
var URL = require("url2");
|
4
|
+
var Q = require("q");
|
5
|
+
|
6
|
+
exports.Proxy = function (app) {
|
7
|
+
if (typeof app === "string") {
|
8
|
+
var location = app;
|
9
|
+
app = function (request) {
|
10
|
+
request.url = location;
|
11
|
+
return request;
|
12
|
+
};
|
13
|
+
}
|
14
|
+
return function (request, response) {
|
15
|
+
return Q.when(app.apply(this, arguments), function (request) {
|
16
|
+
return HTTP.request(request);
|
17
|
+
});
|
18
|
+
};
|
19
|
+
};
|
20
|
+
|
21
|
+
exports.ProxyTree = function (url) {
|
22
|
+
return exports.Proxy(function (request) {
|
23
|
+
request.url = URL.resolve(url, request.pathInfo.replace(/^\//, ""));
|
24
|
+
return request;
|
25
|
+
});
|
26
|
+
};
|
27
|
+
|
@@ -0,0 +1,209 @@
|
|
1
|
+
|
2
|
+
var Q = require("q");
|
3
|
+
var URL = require("url2");
|
4
|
+
var Http = require("../http");
|
5
|
+
var Negotiation = require("./negotiate");
|
6
|
+
var HtmlApps = require("./html");
|
7
|
+
|
8
|
+
/**
|
9
|
+
* @param {String} path
|
10
|
+
* @param {Number} status (optional) default is `301`
|
11
|
+
* @returns {App}
|
12
|
+
*/
|
13
|
+
exports.PermanentRedirect = function (location, status, tree) {
|
14
|
+
return function (request, response) {
|
15
|
+
return exports.permanentRedirect(request, location, status, tree);
|
16
|
+
};
|
17
|
+
};
|
18
|
+
|
19
|
+
/**
|
20
|
+
* @param {String} path
|
21
|
+
* @param {Number} status (optional) default is `301`
|
22
|
+
* @returns {App}
|
23
|
+
*/
|
24
|
+
exports.PermanentRedirectTree = function (location, status) {
|
25
|
+
return function (request, response) {
|
26
|
+
return exports.permanentRedirect(request, location, status, true);
|
27
|
+
};
|
28
|
+
};
|
29
|
+
|
30
|
+
/**
|
31
|
+
* @param {String} path
|
32
|
+
* @param {Number} status (optional) default is `307`
|
33
|
+
* @returns {App}
|
34
|
+
*/
|
35
|
+
exports.TemporaryRedirect = function (location, status, tree) {
|
36
|
+
return function (request, response) {
|
37
|
+
return exports.temporaryRedirect(request, location, status, tree);
|
38
|
+
};
|
39
|
+
};
|
40
|
+
|
41
|
+
/**
|
42
|
+
* @param {String} path
|
43
|
+
* @param {Number} status (optional) default is `307`
|
44
|
+
* @returns {App}
|
45
|
+
*/
|
46
|
+
exports.TemporaryRedirectTree = function (location, status) {
|
47
|
+
return function (request, response) {
|
48
|
+
return exports.temporaryRedirect(request, location, status, true);
|
49
|
+
};
|
50
|
+
};
|
51
|
+
|
52
|
+
/**
|
53
|
+
* @param {String} path
|
54
|
+
* @param {Number} status (optional) default is `307`
|
55
|
+
* @returns {App}
|
56
|
+
*/
|
57
|
+
exports.Redirect = function (location, status, tree) {
|
58
|
+
return function (request, response) {
|
59
|
+
return exports.redirect(request, location, status, tree);
|
60
|
+
};
|
61
|
+
};
|
62
|
+
|
63
|
+
/**
|
64
|
+
* @param {String} path
|
65
|
+
* @param {Number} status (optional) default is `307`
|
66
|
+
* @returns {App}
|
67
|
+
*/
|
68
|
+
exports.RedirectTree = function (location, status) {
|
69
|
+
return function (request, response) {
|
70
|
+
return exports.redirect(request, location, status, true);
|
71
|
+
};
|
72
|
+
};
|
73
|
+
|
74
|
+
exports.permanentRedirect = function (request, location, status) {
|
75
|
+
return exports.redirect(request, location, status || 301);
|
76
|
+
};
|
77
|
+
|
78
|
+
exports.permanentRedirectTree = function (request, location, status) {
|
79
|
+
return exports.redirect(request, location, status || 301, true);
|
80
|
+
};
|
81
|
+
|
82
|
+
exports.temporaryRedirect = function (request, location, status) {
|
83
|
+
return exports.redirect(request, location, status || 307);
|
84
|
+
};
|
85
|
+
|
86
|
+
exports.temporaryRedirectTree = function (request, location, status) {
|
87
|
+
return exports.redirect(request, location, status || 307, true);
|
88
|
+
};
|
89
|
+
|
90
|
+
exports.redirectTree = function (request, location, status) {
|
91
|
+
return exports.redirect(request, location, status, true);
|
92
|
+
};
|
93
|
+
|
94
|
+
/**
|
95
|
+
* @param {String} location
|
96
|
+
* @param {Number} status (optional) default is `301`
|
97
|
+
* @returns {Response}
|
98
|
+
*/
|
99
|
+
exports.redirect = function (request, location, status, tree) {
|
100
|
+
|
101
|
+
// request.permanent gets set by Permanent middleware
|
102
|
+
status = status || (request.permanent ? 301 : 307);
|
103
|
+
|
104
|
+
// ascertain that the location is absolute, per spec
|
105
|
+
location = URL.resolve(request.url, location);
|
106
|
+
|
107
|
+
// redirect into a subtree with the remaining unrouted
|
108
|
+
// portion of the path, if so configured
|
109
|
+
if (tree) {
|
110
|
+
location = URL.resolve(
|
111
|
+
location,
|
112
|
+
request.pathInfo.replace(/^\//, "")
|
113
|
+
);
|
114
|
+
}
|
115
|
+
|
116
|
+
var handlers = {};
|
117
|
+
handlers["text/plain"] = exports.redirectText;
|
118
|
+
if (request.handleHtmlFragmentResponse) {
|
119
|
+
handlers["text/html"] = exports.redirectHtml;
|
120
|
+
}
|
121
|
+
var handler = Negotiation.negotiate(request, handlers) || exports.redirectText;
|
122
|
+
return handler(request, location, status);
|
123
|
+
|
124
|
+
};
|
125
|
+
|
126
|
+
exports.redirectText = function (request, location, status) {
|
127
|
+
var content = (
|
128
|
+
(request.permanent ? "Permanent redirect\n" : "Temporary redirect\n") +
|
129
|
+
"See: " + location + "\n"
|
130
|
+
);
|
131
|
+
var contentLength = content.length;
|
132
|
+
return {
|
133
|
+
status: status,
|
134
|
+
headers: {
|
135
|
+
location: location,
|
136
|
+
"content-type": "text/plain"
|
137
|
+
},
|
138
|
+
body: [content]
|
139
|
+
};
|
140
|
+
};
|
141
|
+
|
142
|
+
exports.redirectHtml = function (request, location, status) {
|
143
|
+
var title = request.permanent ? "Permanent redirect" : "Temporary redirect";
|
144
|
+
return {
|
145
|
+
status: status,
|
146
|
+
headers: {
|
147
|
+
location: location,
|
148
|
+
"content-type": "text/html"
|
149
|
+
},
|
150
|
+
htmlTitle: title,
|
151
|
+
htmlFragment: {
|
152
|
+
forEach: function (write) {
|
153
|
+
write("<h1>" + HtmlApps.escapeHtml(title) + "</h1>\n");
|
154
|
+
write(
|
155
|
+
"<p>See: <a href=\"" + HtmlApps.escapeHtml(location) + "\">" +
|
156
|
+
HtmlApps.escapeHtml(location) +
|
157
|
+
"</a></p>\n"
|
158
|
+
);
|
159
|
+
}
|
160
|
+
}
|
161
|
+
};
|
162
|
+
};
|
163
|
+
|
164
|
+
exports.RedirectTrap = function (app, maxRedirects) {
|
165
|
+
maxRedirects = maxRedirects || 20;
|
166
|
+
return function (request, response) {
|
167
|
+
var remaining = maxRedirects;
|
168
|
+
var deferred = Q.defer();
|
169
|
+
var self = this;
|
170
|
+
var args = arguments;
|
171
|
+
|
172
|
+
request = Http.normalizeRequest(request);
|
173
|
+
|
174
|
+
// try redirect loop
|
175
|
+
function next() {
|
176
|
+
Q.fcall(function () {
|
177
|
+
return app(request, response);
|
178
|
+
})
|
179
|
+
.then(function (response) {
|
180
|
+
if (exports.isRedirect(response)) {
|
181
|
+
if (remaining--) {
|
182
|
+
request.url = response.headers.location;
|
183
|
+
next();
|
184
|
+
} else {
|
185
|
+
throw new Error("Maximum redirects.");
|
186
|
+
}
|
187
|
+
} else {
|
188
|
+
deferred.resolve(response);
|
189
|
+
}
|
190
|
+
})
|
191
|
+
.fail(deferred.reject)
|
192
|
+
}
|
193
|
+
next();
|
194
|
+
|
195
|
+
return deferred.promise;
|
196
|
+
};
|
197
|
+
};
|
198
|
+
|
199
|
+
exports.isRedirect = function (response) {
|
200
|
+
return isRedirect[response.status] || false;
|
201
|
+
};
|
202
|
+
|
203
|
+
var isRedirect = {
|
204
|
+
301: true,
|
205
|
+
302: true,
|
206
|
+
303: true,
|
207
|
+
307: true
|
208
|
+
};
|
209
|
+
|