Module: Babel::Transpiler

Defined in:
lib/babel/transpiler.rb,
lib/babel/transpiler/version.rb

Constant Summary collapse

VERSION =
"0.7.0"

Class Method Summary collapse

Class Method Details

.contextObject



23
24
25
# File 'lib/babel/transpiler.rb', line 23

def self.context
  @context ||= ExecJS.compile("var self = this; " + File.read(script_path))
end

.script_pathObject



19
20
21
# File 'lib/babel/transpiler.rb', line 19

def self.script_path
  File.join(source_path, "babel.js")
end

.source_pathObject



15
16
17
# File 'lib/babel/transpiler.rb', line 15

def self.source_path
  Source::PATH
end

.source_versionObject



11
12
13
# File 'lib/babel/transpiler.rb', line 11

def self.source_version
  Source::VERSION
end

.transform(code, options = {}) ⇒ Object



27
28
29
# File 'lib/babel/transpiler.rb', line 27

def self.transform(code, options = {})
  context.call('babel.transform', code, options.merge('ast' => false))
end

.versionObject



7
8
9
# File 'lib/babel/transpiler.rb', line 7

def self.version
  VERSION
end