module TraceurCompiler::Source
Public Class Methods
contents()
click to toggle source
# File lib/traceur_compiler.rb, line 16 def self.contents @contents ||= File.read(path) end
context()
click to toggle source
# File lib/traceur_compiler.rb, line 20 def self.context return @context unless @context.nil? @context = ExecJS.compile(contents) @context.exec <<-stubs console = { error: function () { }, log: function () { } }; stubs @context.exec <<-compile compile = function (contents, options) { for (var key in options) { traceur.options[key] = options[key]; } var project = new traceur.semantics.symbols.Project(''), reporter = new traceur.util.ErrorReporter(); reporter.reportMessageInternal = function (location, format, args) { throw new Error(traceur.util.ErrorReporter.format(location, format, args)); }; project.addFile(new traceur.syntax.SourceFile('unknown', contents)); var response = traceur.codegeneration.Compiler.compile(reporter, project, false); return traceur.outputgeneration.ProjectWriter.write(response, {}); } compile @context end
path()
click to toggle source
# File lib/traceur_compiler.rb, line 7 def self.path @path ||= ENV['TRACEUR_COMPILER_SOURCE_PATH'] || bundled_path end
path=(path)
click to toggle source
# File lib/traceur_compiler.rb, line 11 def self.path=(path) @contents = @context = nil @path = path end