Module: TypeScript::Src

Defined in:
lib/typescript-src.rb,
lib/typescript-src/version.rb

Constant Summary collapse

VERSION =

TypeScript compiler version + gem’s revision

'1.6.2.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.use_external_tscObject

Returns the value of attribute use_external_tsc.



8
9
10
# File 'lib/typescript-src.rb', line 8

def use_external_tsc
  @use_external_tsc
end

Class Method Details

.js_contentString



51
52
53
# File 'lib/typescript-src.rb', line 51

def js_content
  js_path.read
end

.js_pathPathname



29
30
31
32
33
34
35
36
# File 'lib/typescript-src.rb', line 29

def js_path
  bin_tsc = typescript_path.join('lib/tsc.js')
  if ::File.exist?(bin_tsc)
    bin_tsc
  else
    typescript_path.join('bin/tsc.js')
  end
end

.license_pathPathname



44
45
46
# File 'lib/typescript-src.rb', line 44

def license_path
  typescript_path.join('LICENSE.txt')
end

.package_infoHash



56
57
58
# File 'lib/typescript-src.rb', line 56

def package_info
  JSON.parse(package_json_path.read)
end

.package_json_pathPathname



39
40
41
# File 'lib/typescript-src.rb', line 39

def package_json_path
  typescript_path.join('package.json')
end

.tsc_pathPathname



24
25
26
# File 'lib/typescript-src.rb', line 24

def tsc_path
  typescript_path.join('bin/tsc')
end

.typescript_pathPathname



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/typescript-src.rb', line 11

def typescript_path
  unless @typescript_path
    if self.use_external_tsc
      @typescript_path = ::Pathname.new(`npm root -g`.strip! + '/typescript')
    else
      @typescript_path = ::Pathname.new(File.dirname(__FILE__)).join('typescript-src/support/typescript')
    end
  end

  @typescript_path
end

.versionString



61
62
63
# File 'lib/typescript-src.rb', line 61

def version
  package_info['version']
end