typescript-node 1.1.1 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +19 -19
- data/.travis.yml +8 -8
- data/CHANGES.md +17 -13
- data/Gemfile +8 -8
- data/LICENSE +21 -21
- data/README.md +44 -44
- data/Rakefile +11 -11
- data/lib/typescript-node.rb +89 -90
- data/lib/typescript-node/compile_result.rb +29 -29
- data/lib/typescript-node/version.rb +5 -5
- data/test/data/es5.ts +18 -18
- data/test/data/hello.ts +1 -1
- data/test/test_typescript-node.rb +55 -56
- data/typescript-node.gemspec +23 -23
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c1552c2213c8e07925f99cc2689ca8ef695af92
|
4
|
+
data.tar.gz: 1d8f45e658988625adc005e82002e307df43f9e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba61bb3e2b6629c8a24af9aed0558bccb4b16891c261a09b262ab2cd7184259dd3b69d853b17c2b230c57be5c5c1f378cc1e465a1c604541f3a3f0a8fe265c06
|
7
|
+
data.tar.gz: 087e8a04b9ef49bbaf499a341e10ad13bed6e884f782b7cdbef58e9e6c19903a5ec6eabf0d04a32d4945f1e7761e85ef3c2f434ae7a69d2347a3e1cfcdd4b3fe
|
data/.gitignore
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
.rvmrc
|
19
|
-
.idea
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
.rvmrc
|
19
|
+
.idea
|
data/.travis.yml
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 1.9.3
|
4
|
-
- 2.0.0
|
5
|
-
- 2.1.1
|
6
|
-
- rbx-2
|
7
|
-
- jruby-19mode
|
8
|
-
script: bundle exec rake test
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 1.9.3
|
4
|
+
- 2.0.0
|
5
|
+
- 2.1.1
|
6
|
+
- rbx-2
|
7
|
+
- jruby-19mode
|
8
|
+
script: bundle exec rake test
|
data/CHANGES.md
CHANGED
@@ -1,13 +1,17 @@
|
|
1
|
-
## v1.
|
2
|
-
|
3
|
-
*
|
4
|
-
|
5
|
-
## v1.1.
|
6
|
-
|
7
|
-
*
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
1
|
+
## v1.4.1 2015-07-06 22:36:25+0300
|
2
|
+
|
3
|
+
* Added stdout to output when Typescript compilation error occurs
|
4
|
+
|
5
|
+
## v1.1.1 2015-04-19 15:40:00+0900
|
6
|
+
|
7
|
+
* Use capture3 instead of popen3 to handle tsc I/O.
|
8
|
+
|
9
|
+
## v1.1.0 2014-08-09 10:06:10+0900
|
10
|
+
|
11
|
+
* compile_file now takes tsc(1) options (#3):
|
12
|
+
`TypeScript::Node.compile_file('file', '--target', 'ES5')`
|
13
|
+
|
14
|
+
## v1.0.0 2014-08-09 09:06:11+0900
|
15
|
+
|
16
|
+
* Depends on newer versions of typescript-src
|
17
|
+
* No feature change from previous versions
|
data/Gemfile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
group :test do
|
4
|
-
gem 'test-unit', '~> 3.0.0'
|
5
|
-
end
|
6
|
-
|
7
|
-
# Specify your gem's dependencies in typescript-node-ruby.gemspec
|
8
|
-
gemspec
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
group :test do
|
4
|
+
gem 'test-unit', '~> 3.0.0'
|
5
|
+
end
|
6
|
+
|
7
|
+
# Specify your gem's dependencies in typescript-node-ruby.gemspec
|
8
|
+
gemspec
|
data/LICENSE
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
Copyright (c) 2012 KAWACHI Takashi
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
1
|
+
Copyright (c) 2012 KAWACHI Takashi
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
22
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,44 +1,44 @@
|
|
1
|
-
# Typescript::Node [![Build Status](https://secure.travis-ci.org/typescript-ruby/typescript-node-ruby.png?branch=master)](https://travis-ci.org/typescript-ruby/typescript-node-ruby)
|
2
|
-
|
3
|
-
TypeScript compiler in a gem.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'typescript-node'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install typescript-node
|
18
|
-
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
```ruby
|
22
|
-
require 'typescript-node'
|
23
|
-
|
24
|
-
# raises an error if node(1) isn't available
|
25
|
-
TypeScript::Node.check_node
|
26
|
-
|
27
|
-
# compiles a TypeScript source file and returns TypeScript::Node::CompileResult
|
28
|
-
result = TypeScript::Node.compile_file(file, '--target', 'ES5')
|
29
|
-
result.success? # => true if succeeded
|
30
|
-
result.js # => output JavaScript source code
|
31
|
-
result.stdout # => what tsc(1) shows to stdout
|
32
|
-
result.stderr # => what tsc(1) shows to stderr
|
33
|
-
|
34
|
-
# compiles a TypeScript source code string and returns String
|
35
|
-
js_source = TypeScript::Node.compile_file(ts_source, '--target', 'ES5')
|
36
|
-
```
|
37
|
-
|
38
|
-
## Contributing
|
39
|
-
|
40
|
-
1. Fork it
|
41
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
-
3. Commit your changes (`git commit -am 'Added some feature'`)
|
43
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
-
5. Create new Pull Request
|
1
|
+
# Typescript::Node [![Build Status](https://secure.travis-ci.org/typescript-ruby/typescript-node-ruby.png?branch=master)](https://travis-ci.org/typescript-ruby/typescript-node-ruby)
|
2
|
+
|
3
|
+
TypeScript compiler in a gem.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'typescript-node'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install typescript-node
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'typescript-node'
|
23
|
+
|
24
|
+
# raises an error if node(1) isn't available
|
25
|
+
TypeScript::Node.check_node
|
26
|
+
|
27
|
+
# compiles a TypeScript source file and returns TypeScript::Node::CompileResult
|
28
|
+
result = TypeScript::Node.compile_file(file, '--target', 'ES5')
|
29
|
+
result.success? # => true if succeeded
|
30
|
+
result.js # => output JavaScript source code
|
31
|
+
result.stdout # => what tsc(1) shows to stdout
|
32
|
+
result.stderr # => what tsc(1) shows to stderr
|
33
|
+
|
34
|
+
# compiles a TypeScript source code string and returns String
|
35
|
+
js_source = TypeScript::Node.compile_file(ts_source, '--target', 'ES5')
|
36
|
+
```
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
1. Fork it
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
require 'bundler/gem_tasks'
|
3
|
-
require 'rake/testtask'
|
4
|
-
|
5
|
-
Rake::TestTask.new do |test|
|
6
|
-
test.libs << "test"
|
7
|
-
test.test_files = FileList['test/test*.rb']
|
8
|
-
test.verbose = true
|
9
|
-
end
|
10
|
-
|
11
|
-
task :default => :test
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'rake/testtask'
|
4
|
+
|
5
|
+
Rake::TestTask.new do |test|
|
6
|
+
test.libs << "test"
|
7
|
+
test.test_files = FileList['test/test*.rb']
|
8
|
+
test.verbose = true
|
9
|
+
end
|
10
|
+
|
11
|
+
task :default => :test
|
data/lib/typescript-node.rb
CHANGED
@@ -1,90 +1,89 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
|
8
|
-
module TypeScript
|
9
|
-
module Node
|
10
|
-
class << self
|
11
|
-
|
12
|
-
def tsc_version
|
13
|
-
TypeScript::Src.version
|
14
|
-
end
|
15
|
-
|
16
|
-
def tsc(*args)
|
17
|
-
cmd = [node, Src.tsc_path.to_s, *args]
|
18
|
-
Open3.capture3(*cmd)
|
19
|
-
end
|
20
|
-
|
21
|
-
# Compile TypeScript source file.
|
22
|
-
# @param [String] source_file TypeScript source file
|
23
|
-
# @return [TypeScript::Node::CompileResult] compile result
|
24
|
-
def compile_file(source_file, *tsc_options)
|
25
|
-
Dir.mktmpdir do |output_dir|
|
26
|
-
output_file = File.join(output_dir,
|
27
|
-
stdout, stderr, exit_status = tsc(*tsc_options, '--out', output_file, source_file)
|
28
|
-
|
29
|
-
output_js = File.exists?(output_file) ? File.read(output_file) : nil
|
30
|
-
CompileResult.new(
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# Compile TypeScript to JavaScript.
|
40
|
-
# @param [String] source TypeScript to be compiled
|
41
|
-
# @return [String] Resulted JavaScript
|
42
|
-
def compile(source, *tsc_options)
|
43
|
-
js_file = Tempfile.new(
|
44
|
-
begin
|
45
|
-
js_file.write(source)
|
46
|
-
js_file.close
|
47
|
-
result = compile_file(js_file.path, *tsc_options)
|
48
|
-
if result.success?
|
49
|
-
result.js
|
50
|
-
else
|
51
|
-
raise result.stderr
|
52
|
-
end
|
53
|
-
ensure
|
54
|
-
js_file.unlink
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# node command
|
59
|
-
# TS_NODE environmental variable is used when it is set.
|
60
|
-
def node
|
61
|
-
ENV[
|
62
|
-
end
|
63
|
-
|
64
|
-
def locate_executable(cmd)
|
65
|
-
if RbConfig::CONFIG[
|
66
|
-
cmd << ".exe"
|
67
|
-
end
|
68
|
-
|
69
|
-
if File.executable? cmd
|
70
|
-
cmd
|
71
|
-
else
|
72
|
-
path = ENV['PATH'].split(File::PATH_SEPARATOR).find { |p|
|
73
|
-
full_path = File.join(p, cmd)
|
74
|
-
File.executable?(full_path) && File.file?(full_path)
|
75
|
-
}
|
76
|
-
path && File.expand_path(cmd, path)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def check_node
|
81
|
-
unless locate_executable(node)
|
82
|
-
raise "typescript-node requires node command, but it's not found. Please install it. "
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
TypeScript::Node.check_node
|
1
|
+
require 'tmpdir'
|
2
|
+
require 'tempfile'
|
3
|
+
require 'typescript-src'
|
4
|
+
require 'typescript-node/version'
|
5
|
+
require 'typescript-node/compile_result'
|
6
|
+
require 'open3'
|
7
|
+
|
8
|
+
module TypeScript
|
9
|
+
module Node
|
10
|
+
class << self
|
11
|
+
|
12
|
+
def tsc_version
|
13
|
+
TypeScript::Src.version
|
14
|
+
end
|
15
|
+
|
16
|
+
def tsc(*args)
|
17
|
+
cmd = [node, Src.tsc_path.to_s, *args]
|
18
|
+
Open3.capture3(*cmd)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Compile TypeScript source file.
|
22
|
+
# @param [String] source_file TypeScript source file
|
23
|
+
# @return [TypeScript::Node::CompileResult] compile result
|
24
|
+
def compile_file(source_file, *tsc_options)
|
25
|
+
Dir.mktmpdir do |output_dir|
|
26
|
+
output_file = File.join(output_dir, 'out.js')
|
27
|
+
stdout, stderr, exit_status = tsc(*tsc_options, '--out', output_file, source_file)
|
28
|
+
|
29
|
+
output_js = File.exists?(output_file) ? File.read(output_file) : nil
|
30
|
+
CompileResult.new(
|
31
|
+
output_js,
|
32
|
+
exit_status,
|
33
|
+
stdout,
|
34
|
+
stderr,
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Compile TypeScript to JavaScript.
|
40
|
+
# @param [String] source TypeScript to be compiled
|
41
|
+
# @return [String] Resulted JavaScript
|
42
|
+
def compile(source, *tsc_options)
|
43
|
+
js_file = Tempfile.new(%w(typescript-node .ts))
|
44
|
+
begin
|
45
|
+
js_file.write(source)
|
46
|
+
js_file.close
|
47
|
+
result = compile_file(js_file.path, *tsc_options)
|
48
|
+
if result.success?
|
49
|
+
result.js
|
50
|
+
else
|
51
|
+
raise result.stderr + result.stdout
|
52
|
+
end
|
53
|
+
ensure
|
54
|
+
js_file.unlink
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# node command
|
59
|
+
# TS_NODE environmental variable is used when it is set.
|
60
|
+
def node
|
61
|
+
ENV['TS_NODE'] || 'node'
|
62
|
+
end
|
63
|
+
|
64
|
+
def locate_executable(cmd)
|
65
|
+
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ && File.extname(cmd) == ""
|
66
|
+
cmd << ".exe"
|
67
|
+
end
|
68
|
+
|
69
|
+
if File.executable? cmd
|
70
|
+
cmd
|
71
|
+
else
|
72
|
+
path = ENV['PATH'].split(File::PATH_SEPARATOR).find { |p|
|
73
|
+
full_path = File.join(p, cmd)
|
74
|
+
File.executable?(full_path) && File.file?(full_path)
|
75
|
+
}
|
76
|
+
path && File.expand_path(cmd, path)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def check_node
|
81
|
+
unless locate_executable(node)
|
82
|
+
raise "typescript-node requires node command, but it's not found. Please install it. Set TS_NODE environmental variable If you want to use node command in non-standard path."
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
TypeScript::Node.check_node
|
@@ -1,29 +1,29 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
module TypeScript
|
4
|
-
module Node
|
5
|
-
class CompileResult
|
6
|
-
|
7
|
-
# Constructor
|
8
|
-
#
|
9
|
-
# @param [String] js compiled JavaScript
|
10
|
-
# @param [Fixnum] exit_status return code of tsc command
|
11
|
-
# @param [String] stdout Standard out
|
12
|
-
# @return [String] stderr Standard err
|
13
|
-
def initialize(js, exit_status, stdout, stderr)
|
14
|
-
@js = js
|
15
|
-
@exit_status = exit_status
|
16
|
-
@stdout = stdout
|
17
|
-
@stderr = stderr
|
18
|
-
end
|
19
|
-
|
20
|
-
attr_reader :js, :source_map, :exit_status, :stdout, :stderr
|
21
|
-
|
22
|
-
def success?
|
23
|
-
@exit_status == 0
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module TypeScript
|
4
|
+
module Node
|
5
|
+
class CompileResult
|
6
|
+
|
7
|
+
# Constructor
|
8
|
+
#
|
9
|
+
# @param [String] js compiled JavaScript
|
10
|
+
# @param [Fixnum] exit_status return code of tsc command
|
11
|
+
# @param [String] stdout Standard out
|
12
|
+
# @return [String] stderr Standard err
|
13
|
+
def initialize(js, exit_status, stdout, stderr)
|
14
|
+
@js = js
|
15
|
+
@exit_status = exit_status
|
16
|
+
@stdout = stdout
|
17
|
+
@stderr = stderr
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_reader :js, :source_map, :exit_status, :stdout, :stderr
|
21
|
+
|
22
|
+
def success?
|
23
|
+
@exit_status == 0
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -1,5 +1,5 @@
|
|
1
|
-
module TypeScript
|
2
|
-
module Node
|
3
|
-
VERSION = '1.
|
4
|
-
end
|
5
|
-
end
|
1
|
+
module TypeScript
|
2
|
+
module Node
|
3
|
+
VERSION = '1.4.1'
|
4
|
+
end
|
5
|
+
end
|
data/test/data/es5.ts
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
class Person {
|
2
|
-
|
3
|
-
private _name:string = null;
|
4
|
-
|
5
|
-
constructor() {
|
6
|
-
|
7
|
-
}
|
8
|
-
|
9
|
-
public get name():string
|
10
|
-
{
|
11
|
-
return "The person name is " + this._name;
|
12
|
-
}
|
13
|
-
|
14
|
-
public set name(value:string)
|
15
|
-
{
|
16
|
-
this._name = value;
|
17
|
-
}
|
18
|
-
|
1
|
+
class Person {
|
2
|
+
|
3
|
+
private _name:string = null;
|
4
|
+
|
5
|
+
constructor() {
|
6
|
+
|
7
|
+
}
|
8
|
+
|
9
|
+
public get name():string
|
10
|
+
{
|
11
|
+
return "The person name is " + this._name;
|
12
|
+
}
|
13
|
+
|
14
|
+
public set name(value:string)
|
15
|
+
{
|
16
|
+
this._name = value;
|
17
|
+
}
|
18
|
+
|
19
19
|
}
|
data/test/data/hello.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
console.log("Hello TypeScript")
|
1
|
+
console.log("Hello TypeScript")
|
@@ -1,56 +1,55 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'typescript-node'
|
3
|
-
|
4
|
-
|
5
|
-
class TestTypeScriptNode < Test::Unit::TestCase
|
6
|
-
def test_check_node
|
7
|
-
TypeScript::Node.check_node
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_version
|
11
|
-
assert { TypeScript::Node.tsc_version >= '1.0.1' }
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_compile_file_in_success
|
15
|
-
file = File.expand_path('data/hello.ts', File.dirname(__FILE__))
|
16
|
-
subject = TypeScript::Node.compile_file(file)
|
17
|
-
|
18
|
-
assert { subject.exit_status == 0 }
|
19
|
-
assert { subject.success? }
|
20
|
-
assert { subject.js == %Q{console.log("Hello TypeScript");\n} }
|
21
|
-
assert { subject.stdout == '' }
|
22
|
-
assert { subject.stderr == '' }
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_compile_file_in_failure
|
26
|
-
file = File.expand_path('data/bad.ts', File.dirname(__FILE__))
|
27
|
-
subject = TypeScript::Node.compile_file(file)
|
28
|
-
|
29
|
-
assert { subject.exit_status != 0 }
|
30
|
-
assert { !subject.success? }
|
31
|
-
assert { subject.stdout
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
assert { subject !=
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
assert { subject !=
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
1
|
+
require 'test/unit'
|
2
|
+
require 'typescript-node'
|
3
|
+
|
4
|
+
|
5
|
+
class TestTypeScriptNode < Test::Unit::TestCase
|
6
|
+
def test_check_node
|
7
|
+
TypeScript::Node.check_node
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_version
|
11
|
+
assert { TypeScript::Node.tsc_version >= '1.0.1' }
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_compile_file_in_success
|
15
|
+
file = File.expand_path('data/hello.ts', File.dirname(__FILE__))
|
16
|
+
subject = TypeScript::Node.compile_file(file)
|
17
|
+
|
18
|
+
assert { subject.exit_status == 0 }
|
19
|
+
assert { subject.success? }
|
20
|
+
assert { subject.js == %Q{console.log("Hello TypeScript");\n} }
|
21
|
+
assert { subject.stdout == '' }
|
22
|
+
assert { subject.stderr == '' }
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_compile_file_in_failure
|
26
|
+
file = File.expand_path('data/bad.ts', File.dirname(__FILE__))
|
27
|
+
subject = TypeScript::Node.compile_file(file)
|
28
|
+
|
29
|
+
assert { subject.exit_status != 0 }
|
30
|
+
assert { !subject.success? }
|
31
|
+
assert { subject.stdout != '' || subject.stderr != '' }
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_compile_file_with_es5
|
35
|
+
file = File.expand_path('data/es5.ts', File.dirname(__FILE__))
|
36
|
+
subject = TypeScript::Node.compile_file(file, '--target', 'ES5')
|
37
|
+
|
38
|
+
assert { subject.success? }
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_compile
|
42
|
+
subject = TypeScript::Node.compile('class T { say() { console.log("Hello, world!") } }')
|
43
|
+
|
44
|
+
assert { subject != '' }
|
45
|
+
assert { subject != nil }
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_compile_with_es5
|
49
|
+
subject = TypeScript::Node.compile('class T { get name() { return "foo" } }', '--target', 'ES5')
|
50
|
+
|
51
|
+
assert { subject != '' }
|
52
|
+
assert { subject != nil }
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
data/typescript-node.gemspec
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path('../lib/typescript-node/version', __FILE__)
|
3
|
-
|
4
|
-
Gem::Specification.new do |gem|
|
5
|
-
gem.name =
|
6
|
-
|
7
|
-
gem.authors = [
|
8
|
-
gem.email = [
|
9
|
-
gem.description = %q{TypeScript ruby interface using Node.js}
|
10
|
-
gem.summary = gem.description
|
11
|
-
gem.homepage =
|
12
|
-
|
13
|
-
gem.files = `git ls-files`.split($\)
|
14
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
15
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
|
-
gem.require_paths = ["lib"]
|
17
|
-
gem.version = TypeScript::Node::VERSION
|
18
|
-
|
19
|
-
gem.add_dependency 'typescript-src', '~> 1.
|
20
|
-
gem.add_development_dependency 'rake'
|
21
|
-
|
22
|
-
gem.required_ruby_version =
|
23
|
-
end
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/typescript-node/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = 'typescript-node'
|
6
|
+
|
7
|
+
gem.authors = ['KAWACHI Takashi']
|
8
|
+
gem.email = ['tkawachi@gmail.com']
|
9
|
+
gem.description = %q{TypeScript ruby interface using Node.js}
|
10
|
+
gem.summary = gem.description
|
11
|
+
gem.homepage = 'https://github.com/typescript-ruby/typescript-node-ruby'
|
12
|
+
|
13
|
+
gem.files = `git ls-files`.split($\)
|
14
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
15
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
gem.version = TypeScript::Node::VERSION
|
18
|
+
|
19
|
+
gem.add_dependency 'typescript-src', '~> 1.4.1'
|
20
|
+
gem.add_development_dependency 'rake'
|
21
|
+
|
22
|
+
gem.required_ruby_version = '>= 1.9.3'
|
23
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typescript-node
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KAWACHI Takashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typescript-src
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.4.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.4.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
81
|
rubyforge_project:
|
82
|
-
rubygems_version: 2.2.
|
82
|
+
rubygems_version: 2.2.3
|
83
83
|
signing_key:
|
84
84
|
specification_version: 4
|
85
85
|
summary: TypeScript ruby interface using Node.js
|