Repository: babel/ruby-babel-transpiler Branch: master Commit: 6878f6edb4e7 Files: 175 Total size: 14.3 KB Directory structure: gitextract_fr5fwut_/ ├── .gitignore ├── .travis.yml ├── Gemfile ├── LICENSE ├── MAINTAINING.md ├── README.md ├── SOURCE-BUILDS.md ├── babel-source.gemspec.erb ├── babel-transpiler.gemspec ├── lib/ │ ├── babel/ │ │ ├── source.rb.erb │ │ ├── transpiler/ │ │ │ └── version.rb │ │ └── transpiler.rb │ └── babel-transpiler.rb ├── script/ │ ├── build-gem │ ├── deploy │ ├── eval-erb-template │ ├── gem-version │ ├── local-source-versions │ ├── published-source-versions │ ├── test │ ├── test-gem │ ├── unpublished-source-versions │ └── validate-travis ├── source-versions/ │ ├── 4.0.1 │ ├── 4.0.2 │ ├── 4.1.1 │ ├── 4.2.0 │ ├── 4.2.1 │ ├── 4.3.0 │ ├── 4.4.1 │ ├── 4.4.2 │ ├── 4.4.3 │ ├── 4.4.4 │ ├── 4.4.5 │ ├── 4.4.6 │ ├── 4.5.0 │ ├── 4.5.2 │ ├── 4.5.3 │ ├── 4.5.4 │ ├── 4.5.5 │ ├── 4.6.0 │ ├── 4.6.1 │ ├── 4.6.2 │ ├── 4.6.3 │ ├── 4.6.4 │ ├── 4.6.5 │ ├── 4.6.6 │ ├── 4.7.0 │ ├── 4.7.1 │ ├── 4.7.10 │ ├── 4.7.11 │ ├── 4.7.12 │ ├── 4.7.13 │ ├── 4.7.14 │ ├── 4.7.15 │ ├── 4.7.16 │ ├── 4.7.2 │ ├── 4.7.3 │ ├── 4.7.4 │ ├── 4.7.5 │ ├── 4.7.6 │ ├── 4.7.7 │ ├── 4.7.8 │ ├── 4.7.9 │ ├── 5.0.0 │ ├── 5.0.0-beta1 │ ├── 5.0.0-beta2 │ ├── 5.0.0-beta3 │ ├── 5.0.0-beta4 │ ├── 5.0.1 │ ├── 5.0.10 │ ├── 5.0.11 │ ├── 5.0.12 │ ├── 5.0.13 │ ├── 5.0.2 │ ├── 5.0.3 │ ├── 5.0.4 │ ├── 5.0.5 │ ├── 5.0.6 │ ├── 5.0.7 │ ├── 5.0.8 │ ├── 5.0.9 │ ├── 5.1.0 │ ├── 5.1.1 │ ├── 5.1.10 │ ├── 5.1.11 │ ├── 5.1.12 │ ├── 5.1.13 │ ├── 5.1.2 │ ├── 5.1.3 │ ├── 5.1.4 │ ├── 5.1.5 │ ├── 5.1.6 │ ├── 5.1.7 │ ├── 5.1.8 │ ├── 5.1.9 │ ├── 5.2.0 │ ├── 5.2.1 │ ├── 5.2.10 │ ├── 5.2.11 │ ├── 5.2.12 │ ├── 5.2.13 │ ├── 5.2.14 │ ├── 5.2.15 │ ├── 5.2.16 │ ├── 5.2.17 │ ├── 5.2.2 │ ├── 5.2.6 │ ├── 5.2.7 │ ├── 5.2.8 │ ├── 5.2.9 │ ├── 5.3.0 │ ├── 5.3.1 │ ├── 5.3.2 │ ├── 5.3.3 │ ├── 5.4.0 │ ├── 5.4.1 │ ├── 5.4.2 │ ├── 5.4.3 │ ├── 5.4.4 │ ├── 5.4.5 │ ├── 5.4.6 │ ├── 5.4.7 │ ├── 5.6.0 │ ├── 5.6.1 │ ├── 5.6.11 │ ├── 5.6.12 │ ├── 5.6.13 │ ├── 5.6.14 │ ├── 5.6.15 │ ├── 5.6.16 │ ├── 5.6.17 │ ├── 5.6.18 │ ├── 5.6.19 │ ├── 5.6.2 │ ├── 5.6.20 │ ├── 5.6.3 │ ├── 5.6.4 │ ├── 5.6.5 │ ├── 5.6.6 │ ├── 5.6.7 │ ├── 5.8.0 │ ├── 5.8.1 │ ├── 5.8.10 │ ├── 5.8.11 │ ├── 5.8.12 │ ├── 5.8.13 │ ├── 5.8.14 │ ├── 5.8.15 │ ├── 5.8.16 │ ├── 5.8.17 │ ├── 5.8.18 │ ├── 5.8.19 │ ├── 5.8.2 │ ├── 5.8.23 │ ├── 5.8.24 │ ├── 5.8.25 │ ├── 5.8.26 │ ├── 5.8.27 │ ├── 5.8.28 │ ├── 5.8.29 │ ├── 5.8.3 │ ├── 5.8.30 │ ├── 5.8.31 │ ├── 5.8.32 │ ├── 5.8.33 │ ├── 5.8.34 │ ├── 5.8.35 │ ├── 5.8.4 │ ├── 5.8.5 │ ├── 5.8.6 │ ├── 5.8.7 │ ├── 5.8.8 │ └── 5.8.9 └── test/ └── test_babel_transpiler.rb ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ *.gem Gemfile.lock tmp/ ================================================ FILE: .travis.yml ================================================ language: ruby cache: bundler sudo: false script: ./script/test after_success: ./script/deploy env: global: secure: "QQRK8r/bp7FY8gDAPKywoiUkUSmW5gjrV4d1CM8IguncenjAy0HKGrOy0bWMLj0iz211AuxVvofk6c7B3410ILIjbGgMlPNFe8AGlZhL5lTIIc3D4SxEJ5t/cGQ/BCOyN+IG5qvgYBjwcRQm56NNOhwIHWYS6noAQOWfjafxL3I=" matrix: - BUILD_SOURCE_GEM=1 - VALIDATE_TRAVIS=1 - SOURCE_VERSION="~>4.0.0" - SOURCE_VERSION="~>4.1.0" - SOURCE_VERSION="~>4.2.0" - SOURCE_VERSION="~>4.3.0" - SOURCE_VERSION="~>4.4.0" - SOURCE_VERSION="~>4.5.0" - SOURCE_VERSION="~>4.6.0" - SOURCE_VERSION="~>4.7.0" - SOURCE_VERSION="~>5.0.0" - SOURCE_VERSION="~>5.1.0" - SOURCE_VERSION="~>5.2.0" - SOURCE_VERSION="~>5.3.0" - SOURCE_VERSION="~>5.4.0" - SOURCE_VERSION="~>5.6.0" - SOURCE_VERSION="~>5.8.0" matrix: include: - rvm: 2.0.0 env: - rvm: 2.1 env: - rvm: 2.2 env: - rvm: 2.3.0 env: allow_failures: - env: VALIDATE_TRAVIS=1 ================================================ FILE: Gemfile ================================================ source 'https://rubygems.org' gemspec path: ENV['PWD'] gem 'babel-source', ENV['SOURCE_VERSION'] ================================================ FILE: LICENSE ================================================ Copyright (c) 2015 Joshua Peek Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: MAINTAINING.md ================================================ # Maintaining ## Releasing a new version This project follows [semver](http://semver.org/). Any gem dependency changes will require a new major release. ### Make a release commit To prepare the release commit, edit the [lib/babel/transpiler/version.rb](https://github.com/babel/ruby-babel-transpiler/blob/master/lib/babel/transpiler/version.rb) constant. Then make a single commit with the description as "Ruby Babel Transpiler 1.x.x". Tag the commit with `v1.x.x`. Finally, build the gem and push it to RubyGems. ``` sh $ git pull $ vim lib/babel/transpiler/version.rb $ git add lib/babel/transpiler/version.rb $ git commit -m "Ruby Babel Transpiler 1.x.x" $ git tag v1.x.x $ git push $ git push --tags $ gem build babel-transpiler.gemspec $ gem push babel-transpiler*.gem ``` ================================================ FILE: README.md ================================================ # Ruby Babel Transpiler Ruby Babel is a bridge to the [JS Babel transpiler](https://babeljs.io). ``` ruby require 'babel/transpiler' Babel::Transpiler.transform File.read("foo.es6") ``` ## Installation ``` sh $ gem install babel-transpiler ``` ## Dependencies This library depends on the `babel-source` gem which is updated any time a new version of [Babel](https://babeljs.io) is released. ### ExecJS The [ExecJS](https://github.com/rails/execjs) library is used to automatically choose the best JavaScript engine for your platform. Check out its [README](https://github.com/rails/execjs/blob/master/README.md) for a complete list of supported engines. ================================================ FILE: SOURCE-BUILDS.md ================================================ # Babel Source Builds The Ruby transpiler bridge is just a thin [ExecJS](https://github.com/rails/execjs) wrapper around the [Babel](https://babeljs.io) JS source. The source itself is redistributed as a [babel-source](https://rubygems.org/gems/babel-source) RubyGem with the corresponding version. This means users can easily upgrade to the latest Babel anytime its released while maintaining Ruby API compatibility. Babel JS releases tend be released more frequently than changes to the Ruby bridge itself. So theres some automation behind releasing the source gems. ## CI gem builds `BUILD_SOURCE_GEM=1` is a special entry in the Travis build matrix that automatically builds and tests unpublished source gems. A list of *local source versions* is maintained under the `source-versions/` directory. This listing is diff'd against the [published release list on rubygems.org](https://rubygems.org/gems/babel-source/versions) to get the subset of unpublished gems that should be tested. To test a new release, `touch source-versions/1.2.3`, commit the file and push the changes. On the Travis build matrix, see the `BUILD_SOURCE_GEM=1` job. [![](https://cloud.githubusercontent.com/assets/137/6420712/347d80cc-be8e-11e4-9114-1bb2991c933d.png)](https://travis-ci.org/babel/ruby-babel-transpiler/builds/52399555) This job runs the [`build-gem`](https://github.com/babel/ruby-babel-transpiler/blob/master/script/build-gem) script which fetches the [babel/babel](https://github.com/babel/babel) for the version and builds a local `.gem` file. The [`test-gem`](https://github.com/babel/ruby-babel-transpiler/blob/master/script/test-gem) then runs the test suite against the gem. This catches any changes in the babel build process or API changes that may need to be made to the Ruby bridge before releasing. [![](https://cloud.githubusercontent.com/assets/137/6420733/626d226c-be8e-11e4-8c93-59dd17bab8a1.png)](https://travis-ci.org/babel/ruby-babel-transpiler/jobs/52399556) ### CI gem releases While any fork can test changes against the source gem building code path, `master` has a special deployment designation. Any unreleased source gem pushed to `master` will be automatically published to RubyGems via a Travis `after_success` [`deploy`](https://github.com/babel/ruby-babel-transpiler/blob/master/script/deploy) script. Unfortunately, none of the [official Travis deployment providers](http://docs.travis-ci.com/user/deployment/) could be used. But that may change in the future. So core contributors may release a new source version by touching `source-versions/1.2.3` and committing to `master`. No need to worry about special RubyGem permissions. ### PR release requests To complete the automation workflow, "release requests" are automatically published anytime a new tag is pushed to [babel/babel](https://github.com/babel/babel/releases). Contributors just should verify the build is green and should merge any new release. [![](https://cloud.githubusercontent.com/assets/137/6420592/0827ad96-be8d-11e4-8345-de7c8bc05621.png)](https://github.com/babel/ruby-babel-transpiler/pull/111/files) A [babel/babel](https://github.com/babel/babel/releases) Webhook is setup to POST to a Heroku instance running the [pr-release](https://github.com/babel/ruby-babel-transpiler/blob/heroku/pr-release) script. Its only responsible for opening a PR with a new `source-versions/1.x.x` file. To avoid merge conflicts, the local versions are tracked as individual files rather than a single file with a list of versions. Should the Webhook fail or a PR need to be reopened for an older version, this can all be done manually with any GitHub user or fork. Theres nothing special about the bot account or its permissions. ================================================ FILE: babel-source.gemspec.erb ================================================ Gem::Specification.new do |s| s.name = 'babel-source' s.version = "<%= version %>" s.date = Time.at(<%= date %>) s.summary = "Babel JS source" s.homepage = "https://github.com/babel/ruby-babel-transpiler" s.license = "MIT" s.files = [ 'LICENSE', 'lib/babel.js', 'lib/babel/external-helpers.js', 'lib/babel/polyfill.js', 'lib/babel/source.rb' ] s.authors = ['Sebastian McKenzie'] s.email = 'sebmck@gmail.com' end ================================================ FILE: babel-transpiler.gemspec ================================================ require File.expand_path("../lib/babel/transpiler/version.rb", __FILE__) Gem::Specification.new do |s| s.name = 'babel-transpiler' s.version = Babel::Transpiler::VERSION s.homepage = "https://github.com/babel/ruby-babel-transpiler" s.summary = "Ruby Babel JS Compiler" s.description = <<-EOS Ruby Babel is a bridge to the JS Babel transpiler. EOS s.license = "MIT" s.files = [ 'lib/babel-transpiler.rb', 'lib/babel/transpiler.rb', 'lib/babel/transpiler/version.rb', 'LICENSE' ] s.add_dependency 'babel-source', '>= 4.0', '< 6' s.add_dependency 'execjs', '~> 2.0' s.add_development_dependency 'minitest', '~> 5.5' s.authors = ['Joshua Peek'] s.email = 'josh@joshpeek.com' end ================================================ FILE: lib/babel/source.rb.erb ================================================ module Babel module Source VERSION = "<%= version %>" DATE = Time.at(<%= date %>) PATH = File.expand_path("../..", __FILE__) end end ================================================ FILE: lib/babel/transpiler/version.rb ================================================ module Babel module Transpiler VERSION = "0.7.0" end end ================================================ FILE: lib/babel/transpiler.rb ================================================ require 'execjs' require 'babel/source' require 'babel/transpiler/version' module Babel module Transpiler def self.version VERSION end def self.source_version Source::VERSION end def self.source_path Source::PATH end def self.script_path File.join(source_path, "babel.js") end def self.context @context ||= ExecJS.compile("var self = this; " + File.read(script_path)) end def self.transform(code, options = {}) context.call('babel.transform', code, options.merge('ast' => false)) end end end ================================================ FILE: lib/babel-transpiler.rb ================================================ require 'babel/transpiler' ================================================ FILE: script/build-gem ================================================ #!/bin/bash set -e set -x VERSION="$1" GEM_VERSION=$(./script/gem-version $VERSION) mkdir -p tmp/ pushd tmp/ if [ ! -d babel ]; then git clone https://github.com/babel/babel fi pushd babel/ git fetch origin git checkout --quiet "v$VERSION" make bootstrap build-dist DATE=$(git show --format=%at | head -n1) popd popd dir="tmp/babel-source-$VERSION" mkdir -p "$dir/lib/babel" cp "tmp/babel/packages/babel/dist/browser.js" "$dir/lib/babel.js" cp "tmp/babel/packages/babel/dist/external-helpers.js" "$dir/lib/babel/external-helpers.js" cp "tmp/babel/packages/babel/dist/polyfill.js" "$dir/lib/babel/polyfill.js" cp "tmp/babel/LICENSE" "$dir/LICENSE" ./script/eval-erb-template "babel-source.gemspec.erb" "$GEM_VERSION" "$DATE" > "$dir/babel-source.gemspec" ./script/eval-erb-template "lib/babel/source.rb.erb" "$GEM_VERSION" "$DATE" > "$dir/lib/babel/source.rb" pushd "$dir" gem build babel-source.gemspec popd mkdir -p tmp/vendor/cache cp "$dir/babel-source-$GEM_VERSION.gem" "tmp/vendor/cache" ================================================ FILE: script/deploy ================================================ #!/bin/bash set -e if [ -n "$TRAVIS" ] && ([ "$TRAVIS_SECURE_ENV_VARS" != "true" ] || [ "$TRAVIS_BRANCH" != "master" ] || [ "$TRAVIS_PULL_REQUEST" != "false" ] || [ -z "$BUILD_SOURCE_GEM" ]) then echo "skipping deploy" >&2 exit 0 fi echo "deploying unpublished versions" >&2 if [ "$TRAVIS_SECURE_ENV_VARS" = "true" ]; then cat << EOF > ~/.gem/credentials --- :rubygems_api_key: $RUBYGEMS_API_KEY EOF chmod 0600 ~/.gem/credentials fi for source_version in $(./script/unpublished-source-versions) do if [ ! -f "tmp/vendor/cache/babel-source-$source_version.gem" ]; then ./script/test-gem "$version" fi gem push "tmp/vendor/cache/babel-source-$source_version.gem" done ================================================ FILE: script/eval-erb-template ================================================ #!/usr/bin/env ruby require 'erb' version, date = ARGV[1], ARGV[2] puts ERB.new(File.read(ARGV[0])).result(binding) ================================================ FILE: script/gem-version ================================================ #!/bin/bash if [ -n "$1" ]; then echo $1 | sed s/-/./g else sed s/-/./g fi ================================================ FILE: script/local-source-versions ================================================ #!/bin/bash ls ./source-versions | sort ================================================ FILE: script/published-source-versions ================================================ #!/usr/bin/env ruby require 'json' require 'open-uri' url = "https://rubygems.org/api/v1/versions/babel-source.json" puts JSON.parse(open(url).read).map { |v| v["number"] }.reverse ================================================ FILE: script/test ================================================ #!/bin/bash set -e bundle exec ruby -w test/test_babel_transpiler.rb if [ -n "$VALIDATE_TRAVIS" ]; then ./script/validate-travis fi if [ -n "$BUILD_SOURCE_GEM" ]; then for version in $(./script/unpublished-source-versions) do ./script/test-gem "$version" done fi ================================================ FILE: script/test-gem ================================================ #!/bin/bash set -e set -x export VERSION="$1" export SOURCE_VERSION=$(./script/gem-version $VERSION) if [ ! -f "tmp/vendor/cache/babel-source-$SOURCE_VERSION.gem" ]; then ./script/build-gem "$VERSION" fi cp Gemfile tmp/Gemfile rm -f tmp/Gemfile.lock export BUNDLE_GEMFILE="tmp/Gemfile" bundle install --no-prune bundle exec ruby test/test_babel_transpiler.rb ================================================ FILE: script/unpublished-source-versions ================================================ #!/bin/bash comm -13 <(./script/published-source-versions | sort) <(./script/local-source-versions | ./script/gem-version | sort) ================================================ FILE: script/validate-travis ================================================ #!/usr/bin/env ruby require 'set' require 'yaml' def version_constraints(versions) Set.new(versions.compact.map { |v| v =~ /^(\d+)\.(\d+)\.(\d+)$/ && v.sub(/^(\d+)\.(\d+)\.(\d+)$/, '~>\1.\2.0') }.compact) end published = version_constraints(`./script/published-source-versions`.split("\n")) local = version_constraints(`./script/local-source-versions`.split("\n")) config = YAML.load(File.read(".travis.yml")) travis = Set.new(config["env"]["matrix"].map { |s| s[/^SOURCE_VERSION="(.+)"$/, 1] }.compact) missing = (published & local) - travis if missing.any? abort "Add the following envs to .travis.yml: \n" + missing.map { |v| "- SOURCE_VERSION=\"#{v}\"" }.join("\n") end ================================================ FILE: source-versions/4.0.1 ================================================ ================================================ FILE: source-versions/4.0.2 ================================================ ================================================ FILE: source-versions/4.1.1 ================================================ ================================================ FILE: source-versions/4.2.0 ================================================ ================================================ FILE: source-versions/4.2.1 ================================================ ================================================ FILE: source-versions/4.3.0 ================================================ ================================================ FILE: source-versions/4.4.1 ================================================ ================================================ FILE: source-versions/4.4.2 ================================================ ================================================ FILE: source-versions/4.4.3 ================================================ ================================================ FILE: source-versions/4.4.4 ================================================ ================================================ FILE: source-versions/4.4.5 ================================================ ================================================ FILE: source-versions/4.4.6 ================================================ ================================================ FILE: source-versions/4.5.0 ================================================ ================================================ FILE: source-versions/4.5.2 ================================================ ================================================ FILE: source-versions/4.5.3 ================================================ ================================================ FILE: source-versions/4.5.4 ================================================ ================================================ FILE: source-versions/4.5.5 ================================================ ================================================ FILE: source-versions/4.6.0 ================================================ ================================================ FILE: source-versions/4.6.1 ================================================ ================================================ FILE: source-versions/4.6.2 ================================================ ================================================ FILE: source-versions/4.6.3 ================================================ ================================================ FILE: source-versions/4.6.4 ================================================ ================================================ FILE: source-versions/4.6.5 ================================================ ================================================ FILE: source-versions/4.6.6 ================================================ ================================================ FILE: source-versions/4.7.0 ================================================ ================================================ FILE: source-versions/4.7.1 ================================================ ================================================ FILE: source-versions/4.7.10 ================================================ ================================================ FILE: source-versions/4.7.11 ================================================ ================================================ FILE: source-versions/4.7.12 ================================================ ================================================ FILE: source-versions/4.7.13 ================================================ ================================================ FILE: source-versions/4.7.14 ================================================ ================================================ FILE: source-versions/4.7.15 ================================================ ================================================ FILE: source-versions/4.7.16 ================================================ ================================================ FILE: source-versions/4.7.2 ================================================ ================================================ FILE: source-versions/4.7.3 ================================================ ================================================ FILE: source-versions/4.7.4 ================================================ ================================================ FILE: source-versions/4.7.5 ================================================ ================================================ FILE: source-versions/4.7.6 ================================================ ================================================ FILE: source-versions/4.7.7 ================================================ ================================================ FILE: source-versions/4.7.8 ================================================ ================================================ FILE: source-versions/4.7.9 ================================================ ================================================ FILE: source-versions/5.0.0 ================================================ ================================================ FILE: source-versions/5.0.0-beta1 ================================================ ================================================ FILE: source-versions/5.0.0-beta2 ================================================ ================================================ FILE: source-versions/5.0.0-beta3 ================================================ ================================================ FILE: source-versions/5.0.0-beta4 ================================================ ================================================ FILE: source-versions/5.0.1 ================================================ ================================================ FILE: source-versions/5.0.10 ================================================ ================================================ FILE: source-versions/5.0.11 ================================================ ================================================ FILE: source-versions/5.0.12 ================================================ ================================================ FILE: source-versions/5.0.13 ================================================ ================================================ FILE: source-versions/5.0.2 ================================================ ================================================ FILE: source-versions/5.0.3 ================================================ ================================================ FILE: source-versions/5.0.4 ================================================ ================================================ FILE: source-versions/5.0.5 ================================================ ================================================ FILE: source-versions/5.0.6 ================================================ ================================================ FILE: source-versions/5.0.7 ================================================ ================================================ FILE: source-versions/5.0.8 ================================================ ================================================ FILE: source-versions/5.0.9 ================================================ ================================================ FILE: source-versions/5.1.0 ================================================ ================================================ FILE: source-versions/5.1.1 ================================================ ================================================ FILE: source-versions/5.1.10 ================================================ ================================================ FILE: source-versions/5.1.11 ================================================ ================================================ FILE: source-versions/5.1.12 ================================================ ================================================ FILE: source-versions/5.1.13 ================================================ ================================================ FILE: source-versions/5.1.2 ================================================ ================================================ FILE: source-versions/5.1.3 ================================================ ================================================ FILE: source-versions/5.1.4 ================================================ ================================================ FILE: source-versions/5.1.5 ================================================ ================================================ FILE: source-versions/5.1.6 ================================================ ================================================ FILE: source-versions/5.1.7 ================================================ ================================================ FILE: source-versions/5.1.8 ================================================ ================================================ FILE: source-versions/5.1.9 ================================================ ================================================ FILE: source-versions/5.2.0 ================================================ ================================================ FILE: source-versions/5.2.1 ================================================ ================================================ FILE: source-versions/5.2.10 ================================================ ================================================ FILE: source-versions/5.2.11 ================================================ ================================================ FILE: source-versions/5.2.12 ================================================ ================================================ FILE: source-versions/5.2.13 ================================================ ================================================ FILE: source-versions/5.2.14 ================================================ ================================================ FILE: source-versions/5.2.15 ================================================ ================================================ FILE: source-versions/5.2.16 ================================================ ================================================ FILE: source-versions/5.2.17 ================================================ ================================================ FILE: source-versions/5.2.2 ================================================ ================================================ FILE: source-versions/5.2.6 ================================================ ================================================ FILE: source-versions/5.2.7 ================================================ ================================================ FILE: source-versions/5.2.8 ================================================ ================================================ FILE: source-versions/5.2.9 ================================================ ================================================ FILE: source-versions/5.3.0 ================================================ ================================================ FILE: source-versions/5.3.1 ================================================ ================================================ FILE: source-versions/5.3.2 ================================================ ================================================ FILE: source-versions/5.3.3 ================================================ ================================================ FILE: source-versions/5.4.0 ================================================ ================================================ FILE: source-versions/5.4.1 ================================================ ================================================ FILE: source-versions/5.4.2 ================================================ ================================================ FILE: source-versions/5.4.3 ================================================ ================================================ FILE: source-versions/5.4.4 ================================================ ================================================ FILE: source-versions/5.4.5 ================================================ ================================================ FILE: source-versions/5.4.6 ================================================ ================================================ FILE: source-versions/5.4.7 ================================================ ================================================ FILE: source-versions/5.6.0 ================================================ ================================================ FILE: source-versions/5.6.1 ================================================ ================================================ FILE: source-versions/5.6.11 ================================================ ================================================ FILE: source-versions/5.6.12 ================================================ ================================================ FILE: source-versions/5.6.13 ================================================ ================================================ FILE: source-versions/5.6.14 ================================================ ================================================ FILE: source-versions/5.6.15 ================================================ ================================================ FILE: source-versions/5.6.16 ================================================ ================================================ FILE: source-versions/5.6.17 ================================================ ================================================ FILE: source-versions/5.6.18 ================================================ ================================================ FILE: source-versions/5.6.19 ================================================ ================================================ FILE: source-versions/5.6.2 ================================================ ================================================ FILE: source-versions/5.6.20 ================================================ ================================================ FILE: source-versions/5.6.3 ================================================ ================================================ FILE: source-versions/5.6.4 ================================================ ================================================ FILE: source-versions/5.6.5 ================================================ ================================================ FILE: source-versions/5.6.6 ================================================ ================================================ FILE: source-versions/5.6.7 ================================================ ================================================ FILE: source-versions/5.8.0 ================================================ ================================================ FILE: source-versions/5.8.1 ================================================ ================================================ FILE: source-versions/5.8.10 ================================================ ================================================ FILE: source-versions/5.8.11 ================================================ ================================================ FILE: source-versions/5.8.12 ================================================ ================================================ FILE: source-versions/5.8.13 ================================================ ================================================ FILE: source-versions/5.8.14 ================================================ ================================================ FILE: source-versions/5.8.15 ================================================ ================================================ FILE: source-versions/5.8.16 ================================================ ================================================ FILE: source-versions/5.8.17 ================================================ ================================================ FILE: source-versions/5.8.18 ================================================ ================================================ FILE: source-versions/5.8.19 ================================================ ================================================ FILE: source-versions/5.8.2 ================================================ ================================================ FILE: source-versions/5.8.23 ================================================ ================================================ FILE: source-versions/5.8.24 ================================================ ================================================ FILE: source-versions/5.8.25 ================================================ ================================================ FILE: source-versions/5.8.26 ================================================ ================================================ FILE: source-versions/5.8.27 ================================================ ================================================ FILE: source-versions/5.8.28 ================================================ ================================================ FILE: source-versions/5.8.29 ================================================ ================================================ FILE: source-versions/5.8.3 ================================================ ================================================ FILE: source-versions/5.8.30 ================================================ ================================================ FILE: source-versions/5.8.31 ================================================ ================================================ FILE: source-versions/5.8.32 ================================================ ================================================ FILE: source-versions/5.8.33 ================================================ ================================================ FILE: source-versions/5.8.34 ================================================ ================================================ FILE: source-versions/5.8.35 ================================================ ================================================ FILE: source-versions/5.8.4 ================================================ ================================================ FILE: source-versions/5.8.5 ================================================ ================================================ FILE: source-versions/5.8.6 ================================================ ================================================ FILE: source-versions/5.8.7 ================================================ ================================================ FILE: source-versions/5.8.8 ================================================ ================================================ FILE: source-versions/5.8.9 ================================================ ================================================ FILE: test/test_babel_transpiler.rb ================================================ require 'minitest/autorun' require 'babel/transpiler' class TestBabelTranspiler < MiniTest::Test def test_source_constants assert Babel::Source::VERSION assert Babel::Source::DATE assert Babel::Source::PATH end def test_source_path_directory assert File.directory?("#{Babel::Transpiler.source_path}") assert File.directory?("#{Babel::Transpiler.source_path}/babel") assert File.file?("#{Babel::Transpiler.source_path}/babel.js") assert File.file?("#{Babel::Transpiler.source_path}/babel/external-helpers.js") assert File.file?("#{Babel::Transpiler.source_path}/babel/polyfill.js") end def test_script_path_readable path = Babel::Transpiler.script_path assert File.exist?(path) assert File.read(path) end def test_version assert Babel::Transpiler.version assert Babel::Transpiler.source_version end def test_transform code = Babel::Transpiler.transform("[0, 2, 4].map(v => v + 1)", "blacklist" => ["useStrict"])["code"] assert_equal [1, 3, 5], ExecJS.exec("return #{code}") code = Babel::Transpiler.transform("(function f(x, y = 12) { return x + y; })(3)", "blacklist" => ["useStrict"])["code"] assert_equal 15, ExecJS.exec("return #{code}") end def test_transform_options code = Babel::Transpiler.transform("ary.map(v => v + 1)", "whitelist" => ["useStrict"])["code"] assert_match(/strict/, code) code = Babel::Transpiler.transform("ary.map(v => v + 1)", "blacklist" => ["useStrict"])["code"] refute_match(/strict/, code) assert Babel::Transpiler.transform("ary.map(v => v + 1)", {}.freeze)["code"] end end