type-script 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +22 -0
- data/README.md +39 -0
- data/lib/type-script.rb +1 -0
- data/lib/type_script.rb +55 -0
- metadata +76 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 242936501d15a684a7a20f7008c1c1df1026160f
|
4
|
+
data.tar.gz: 8129e3b47eb418b3c5b22d0ec17ee8b74b795520
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1fe564f8801782570d52dca1cfc50c3f2a8b7dc300d699f7b591e4f363c7ee5e42f34a69fb9cbc75b8818a06c661ac98fc4566484aa2134060e7f53ad8b8b3d4
|
7
|
+
data.tar.gz: e801ec9fccee2e40ec59c0bbb078cb6ac41c52cce864429083c38a4f61a5fd76b85d4d7bb6eab85f2b563ea8617201f435c2ea5a284e2aed3ec952502cf8ec32
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2010-2016 Gyuchang Jun
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
Ruby TypeScript
|
2
|
+
=================
|
3
|
+
|
4
|
+
Ruby TypeScript is a bridge to the official TypeScript transpiler.
|
5
|
+
|
6
|
+
TypeScript.compile File.read("script.ts")
|
7
|
+
|
8
|
+
|
9
|
+
Installation
|
10
|
+
------------
|
11
|
+
|
12
|
+
gem install type-script
|
13
|
+
|
14
|
+
|
15
|
+
Credit
|
16
|
+
------------
|
17
|
+
|
18
|
+
General structure, most of the code and documentation was shamelessly lifted from [coffee-scrit gem](https://github.com/rails/ruby-coffee-script).
|
19
|
+
|
20
|
+
|
21
|
+
Dependencies
|
22
|
+
------------
|
23
|
+
|
24
|
+
This library depends on the `type-script-source` gem which is
|
25
|
+
updated any time a new version of TypeScript is released. (The
|
26
|
+
`type-script-source` gem's version number is synced with each
|
27
|
+
official TypeScript release.) This way you can build against
|
28
|
+
different versions of TypeScript by requiring the correct version of
|
29
|
+
the `type-script-source` gem.
|
30
|
+
|
31
|
+
In addition, you can use this library with unreleased versions of
|
32
|
+
TypeScript by setting the `TYPESCRIPT_SOURCE_PATH` environment
|
33
|
+
variable:
|
34
|
+
|
35
|
+
export TYPESCRIPT_SOURCE_PATH=/path/to/TypeScript/lib/typescript.js
|
36
|
+
|
37
|
+
### ExecJS
|
38
|
+
|
39
|
+
The [ExecJS](https://github.com/sstephenson/execjs) library is used to automatically choose the best JavaScript engine for your platform. Check out its [README](https://github.com/sstephenson/execjs/blob/master/README.md) for a complete list of supported engines.
|
data/lib/type-script.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'type_script'
|
data/lib/type_script.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'execjs'
|
2
|
+
require 'type_script/source'
|
3
|
+
|
4
|
+
module TypeScript
|
5
|
+
Error = ExecJS::Error
|
6
|
+
EngineError = ExecJS::RuntimeError
|
7
|
+
CompilationError = ExecJS::ProgramError
|
8
|
+
|
9
|
+
module Source
|
10
|
+
def self.path
|
11
|
+
@path ||= ENV['TYPESCRIPT_SOURCE_PATH'] || bundled_path
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.path=(path)
|
15
|
+
@contents = @version = @context = nil
|
16
|
+
@path = path
|
17
|
+
end
|
18
|
+
|
19
|
+
COMPILE_FUNCTION_SOURCE = <<-JS
|
20
|
+
;function compile(script, options) {
|
21
|
+
return ts.transpile(script, options);
|
22
|
+
}
|
23
|
+
JS
|
24
|
+
|
25
|
+
def self.contents
|
26
|
+
@contents ||= File.read(path) + COMPILE_FUNCTION_SOURCE
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.context
|
30
|
+
@context ||= ExecJS.compile(contents)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class << self
|
35
|
+
def engine
|
36
|
+
end
|
37
|
+
|
38
|
+
def engine=(engine)
|
39
|
+
end
|
40
|
+
|
41
|
+
def version
|
42
|
+
Source.version
|
43
|
+
end
|
44
|
+
|
45
|
+
# Compile typescript source (String or IO) to JavaScript.
|
46
|
+
def compile(script, options = {})
|
47
|
+
script = script.read if script.respond_to?(:read)
|
48
|
+
|
49
|
+
# Stringify keys
|
50
|
+
options = options.inject({}) { |h, (k, v)| h[k.to_s] = v; h }
|
51
|
+
|
52
|
+
Source.context.call("compile", script, options)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: type-script
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gyuchang Jun
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: type-script-source
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: execjs
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: |2
|
42
|
+
Ruby TypeScript is a bridge to the JS TypeScript transpiler.
|
43
|
+
email: gyuchang.jun@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- LICENSE
|
49
|
+
- README.md
|
50
|
+
- lib/type-script.rb
|
51
|
+
- lib/type_script.rb
|
52
|
+
homepage: http://github.com/gyuchang/ruby-type-script
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata: {}
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 2.4.5
|
73
|
+
signing_key:
|
74
|
+
specification_version: 4
|
75
|
+
summary: Ruby TypeScript Transpiler
|
76
|
+
test_files: []
|