Class: Typescript::Monkey::Package

Inherits:
Object
  • Object
show all
Defined in:
lib/typescript/monkey/package.rb

Overview

The Package class.

A class that implements an interface to the Typescript node installation.

Class Method Summary collapse

Class Method Details

.compiler_bin_pathPathname Also known as: compiler_bin

Returns path to Typescript compiler executable

The executable compiler can be used to transform Typescript to Javascript and is used during the asset pipeline compilation stage.

Returns:

  • (Pathname)

    path to Typescript compiler executable



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/typescript/monkey/package.rb', line 18

def self.compiler_bin_path
  compiler_bin_path = npm_bin_path()

  if compiler_bin_path
    compiler_bin_path = compiler_bin_path.join("tsc")
    unless (compiler_bin_path && compiler_bin_path.file? && compiler_bin_path.executable?)
      compiler_bin_path = nil
    end
  end

  compiler_bin_path
end

.compiler_jsString

@TODO: REMOVE compiler_js() Returns content for Typescript compiler source

The compiler can be included with web content to transform embedded Typescript wrapped in <script type=“text/typescript”></script> tags.

Returns:

  • (String)

    javascript Typescript compiler source



60
61
62
63
64
65
66
67
68
69
# File 'lib/typescript/monkey/package.rb', line 60

def self.compiler_js
  compiler_js = ""
  compiler_js_path = self.compiler_js_path()

  unless compiler_js_path.nil?
    compiler_js = compiler_js_path.read()
  end

  compiler_js
end

.compiler_js_pathPathname

@TODO: REMOVE compiler_js_path() Returns path to Typescript compiler source

The compiler can be included with web content to transform embedded Typescript wrapped in <script type=“text/typescript”></script> tags.

Returns:

  • (Pathname)

    path to Typescript javascript compiler source



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/typescript/monkey/package.rb', line 39

def self.compiler_js_path
  compiler_js_path = npm_root_path()

  if compiler_js_path
    compiler_js_path = compiler_js_path.join("typescript/lib/typescriptServices.js")
    unless compiler_js_path.file? && compiler_js_path.readable?
      compiler_js_path = nil
    end
  end

  compiler_js_path
end

.compiler_versionString

Returns package version for Typescript installation

Returns:

  • (String)

    version information



75
76
77
78
79
80
81
82
83
84
# File 'lib/typescript/monkey/package.rb', line 75

def self.compiler_version
  compiler_version = "unknown"
   = self.()

  unless .empty? || !.has_key?('version')
    compiler_version = ['version']
  end

  compiler_version
end

.metadataHash

Returns package metadata contents for Typescript installation

Returns:

  • (Hash)

    hash representation of package metadata contents



110
111
112
113
114
115
116
117
118
119
120
# File 'lib/typescript/monkey/package.rb', line 110

def self.
   = {}
   = self.()

  unless .nil?
     = JSON.parse(.read())
     ||= {}
  end

  
end

.metadata_pathPathname

Returns path to package metadata file for Typescript installation

The package metadata file is the package.json file.

Returns:

  • (Pathname)

    path to Typepackage information file



92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/typescript/monkey/package.rb', line 92

def self.
   = npm_root_path()

  if 
     = .join("typescript/package.json")
    unless .file? && .readable?
       = nil
    end
  end

  
end

.services_jsString

Returns content for Typescript services javascript source

The Typescript services can be included with web content to provide embedded Typescript functionality. This Typescript::Monkey::Transpiler leverages services to transpile <script type=“text/typescript”> tags at runtime.

Returns:

  • (String)

    Typescript services javascript source



153
154
155
156
157
158
159
160
161
162
# File 'lib/typescript/monkey/package.rb', line 153

def self.services_js
  services_js = ""
  services_js_path = self.services_js_path()

  unless services_js_path.nil?
    services_js = services_js_path.read()
  end

  services_js
end

.services_js_pathPathname

Returns path to Typescript services javascript source

The Typescript services can be included with web content to provide embedded Typescript functionality. This Typescript::Monkey::Transpiler leverages services to transpile <script type=“text/typescript”> tags at runtime.

Returns:

  • (Pathname)

    path to Typescript service javascript source



131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/typescript/monkey/package.rb', line 131

def self.services_js_path
  services_js_path = npm_root_path()

  if services_js_path
    services_js_path = services_js_path.join("typescript/lib/typescriptServices.js")
    unless services_js_path.file? && services_js_path.readable?
      services_js_path = nil
    end
  end

  services_js_path
end