Class: Typescript::Monkey::Package
- Inherits:
-
Object
- Object
- Typescript::Monkey::Package
- 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
-
.compiler_bin_path ⇒ Pathname
(also: compiler_bin)
Returns path to Typescript compiler executable.
-
.compiler_js ⇒ String
@TODO: REMOVE compiler_js() Returns content for Typescript compiler source.
-
.compiler_js_path ⇒ Pathname
@TODO: REMOVE compiler_js_path() Returns path to Typescript compiler source.
-
.compiler_version ⇒ String
Returns package version for Typescript installation.
-
.metadata ⇒ Hash
Returns package metadata contents for Typescript installation.
-
.metadata_path ⇒ Pathname
Returns path to package metadata file for Typescript installation.
-
.services_js ⇒ String
Returns content for Typescript services javascript source.
-
.services_js_path ⇒ Pathname
Returns path to Typescript services javascript source.
Class Method Details
.compiler_bin_path ⇒ Pathname 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.
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_js ⇒ String
@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.
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_path ⇒ Pathname
@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.
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_version ⇒ String
Returns package version for Typescript installation
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 |
.metadata ⇒ Hash
Returns package metadata contents for Typescript installation
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_path ⇒ Pathname
Returns path to package metadata file for Typescript installation
The package metadata file is the package.json 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_js ⇒ String
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.
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_path ⇒ Pathname
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.
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 |