Module: TypeScript::Source

Defined in:
lib/type_script.rb

Constant Summary collapse

COMPILE_FUNCTION_SOURCE =
<<-JS
  ;function compile(script, options) {
    return ts.transpile(script, options);
  }
JS

Class Method Summary collapse

Class Method Details

.contentsObject



25
26
27
# File 'lib/type_script.rb', line 25

def self.contents
  @contents ||= File.read(path) + COMPILE_FUNCTION_SOURCE
end

.contextObject



29
30
31
# File 'lib/type_script.rb', line 29

def self.context
  @context ||= ExecJS.compile(contents)
end

.pathObject



10
11
12
# File 'lib/type_script.rb', line 10

def self.path
  @path ||= ENV['TYPESCRIPT_SOURCE_PATH'] || bundled_path
end

.path=(path) ⇒ Object



14
15
16
17
# File 'lib/type_script.rb', line 14

def self.path=(path)
  @contents = @version = @context = nil
  @path = path
end