typescript-node 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9bed1f037cba9d2d5f15c927159d82a8e27169f
4
- data.tar.gz: aa3d3904333ee0bf4f525c67ddc90416372f8219
3
+ metadata.gz: ce6af8b1e3c9570a286f6f1f314e5555f12750d4
4
+ data.tar.gz: cd729825096bd4721f6321313a10378532716219
5
5
  SHA512:
6
- metadata.gz: cf92e83c99c402cd3d6b5a14d419ef861d438256178237590c3de440e138618903a083414bee23fa06fefde1c3a4286a537bef1f455f94256e87facae6d0f678
7
- data.tar.gz: d9ce011f3bd3704f05ec0cbd14c3622bcfb7df270f05300e21dc7270717bf44d02bdf546a8c8fc3ea9127aa0f209d0e4c97ccc68685c17971ed2ba52616a93ec
6
+ metadata.gz: fc8a3325a12473151713c1517c9a970f639221ccbc62043079fe981f3c9d6256d854e5c13c3359fd9fa97d5e20d2a241e54a2b277df22b53019b8dd3a262c3ad
7
+ data.tar.gz: 46e6209b9086ca589f14d83f342790167cc6e51f20749d95cacdefbf0b2727cd7ac0d7d1b26dc10c9ea2941143845c3c750255f9b158367c82c7a24232983b9b
@@ -1,18 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.8.7
4
3
  - 1.9.3
5
- - 1.9.2
6
4
  - 2.0.0
7
- - 2.1.0
8
- - rbx-2.1.1
9
- - jruby-18mode
5
+ - 2.1.1
6
+ - rbx-2
10
7
  - jruby-19mode
11
- - ree
12
- script: bundle exec rspec
13
- matrix:
14
- allow_failures:
15
- - rvm: 1.8.7
16
- - rvm: jruby-18mode
17
- - rvm: jruby-19mode
18
- - rvm: ree
8
+ script: bundle exec rake test
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v1.1.0 2014-08-09 10:06:10+0900
2
+
3
+ * compile_file now takes tsc(1) options (#3):
4
+ `TypeScript::Node.compile_file('file', '--target', 'ES5')`
5
+
1
6
  ## v1.0.0 2014-08-09 09:06:11+0900
2
7
 
3
8
  * Depends on newer versions of typescript-src
data/README.md CHANGED
@@ -25,17 +25,16 @@ require 'typescript-node'
25
25
  TypeScript::Node.check_node
26
26
 
27
27
  # compiles a TypeScript source file and returns TypeScript::Node::CompileResult
28
- result = TypeScript::Node.compile_file(file)
28
+ result = TypeScript::Node.compile_file(file, '--target', 'ES5')
29
29
  result.success? # => true if succeeded
30
30
  result.js # => output JavaScript source code
31
31
  result.stdout # => what tsc(1) shows to stdout
32
32
  result.stderr # => what tsc(1) shows to stderr
33
33
 
34
34
  # compiles a TypeScript source code string and returns String
35
- js_source = TypeScript::Node.compile_file(ts_source)
35
+ js_source = TypeScript::Node.compile_file(ts_source, '--target', 'ES5')
36
36
  ```
37
37
 
38
-
39
38
  ## Contributing
40
39
 
41
40
  1. Fork it
@@ -13,35 +13,42 @@ module TypeScript
13
13
  TypeScript::Src.version
14
14
  end
15
15
 
16
+
17
+ def tsc(*args)
18
+ cmd = [node, Src.tsc_path.to_s, *args]
19
+ Open3.popen3(*cmd) do |stdin, stdout, stderr, wait_thr|
20
+ stdin.close
21
+ [wait_thr.value, stdout.read, stderr.read]
22
+ end
23
+ end
24
+
16
25
  # Compile TypeScript source file.
17
26
  # @param [String] source_file TypeScript source file
18
27
  # @return [TypeScript::Node::CompileResult] compile result
19
- def compile_file(source_file)
28
+ def compile_file(source_file, *tsc_options)
20
29
  Dir.mktmpdir do |output_dir|
21
30
  output_file = File.join(output_dir, "out.js")
22
- cmd = [node, Src.tsc_path.to_s, "--out", output_file, source_file]
23
- Open3.popen3(*cmd) do |stdin, stdout, stderr, wait_thr|
24
- exit_status = wait_thr.value
25
- output_js = File.exists?(output_file) ? File.read(output_file) : nil
26
- CompileResult.new(
27
- output_js,
28
- exit_status,
29
- stdout.read,
30
- stderr.read
31
- )
32
- end
31
+ exit_status, stdout, stderr = tsc(*tsc_options, '--out', output_file, source_file)
32
+
33
+ output_js = File.exists?(output_file) ? File.read(output_file) : nil
34
+ CompileResult.new(
35
+ output_js,
36
+ exit_status,
37
+ stdout,
38
+ stderr,
39
+ )
33
40
  end
34
41
  end
35
42
 
36
43
  # Compile TypeScript to JavaScript.
37
44
  # @param [String] source TypeScript to be compiled
38
45
  # @return [String] Resulted JavaScript
39
- def compile(source)
46
+ def compile(source, *tsc_options)
40
47
  js_file = Tempfile.new(["typescript-node", ".ts"])
41
48
  begin
42
49
  js_file.write(source)
43
50
  js_file.close
44
- result = compile_file(js_file.path)
51
+ result = compile_file(js_file.path, *tsc_options)
45
52
  if result.success?
46
53
  result.js
47
54
  else
@@ -77,7 +84,7 @@ module TypeScript
77
84
  def check_node
78
85
  unless locate_executable(node)
79
86
  raise "typescript-node requires node command, but it's not found. Please install it. " +
80
- "Set TS_NODE environmental variable If you want to use node command in non-standard path."
87
+ "Set TS_NODE environmental variable If you want to use node command in non-standard path."
81
88
  end
82
89
  end
83
90
  end
@@ -1,5 +1,5 @@
1
1
  module TypeScript
2
2
  module Node
3
- VERSION = '1.0.0'
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
@@ -0,0 +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
+
19
+ }
@@ -32,10 +32,25 @@ class TestTypeScriptNode < Test::Unit::TestCase
32
32
  assert { subject.stderr != '' }
33
33
  end
34
34
 
35
+ def test_compile_file_with_es5
36
+ file = File.expand_path('data/es5.ts', File.dirname(__FILE__))
37
+ subject = TypeScript::Node.compile_file(file, '--target', 'ES5')
38
+
39
+ assert { subject.success? }
40
+ end
41
+
35
42
  def test_compile
36
43
  subject = TypeScript::Node.compile('class T { say() { console.log("Hello, world!") } }')
37
44
 
38
45
  assert { subject != '' }
39
46
  assert { subject != nil }
40
47
  end
48
+
49
+ def test_compile_with_es5
50
+ subject = TypeScript::Node.compile('class T { get name() { return "foo" } }', '--target', 'ES5')
51
+
52
+ assert { subject != '' }
53
+ assert { subject != nil }
54
+ end
55
+
41
56
  end
@@ -18,4 +18,6 @@ Gem::Specification.new do |gem|
18
18
 
19
19
  gem.add_dependency 'typescript-src', '~> 1.0.1'
20
20
  gem.add_development_dependency 'rake'
21
+
22
+ gem.required_ruby_version = ">= 1.9.3"
21
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typescript-node
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - KAWACHI Takashi
@@ -56,6 +56,7 @@ files:
56
56
  - lib/typescript-node/compile_result.rb
57
57
  - lib/typescript-node/version.rb
58
58
  - test/data/bad.ts
59
+ - test/data/es5.ts
59
60
  - test/data/hello.ts
60
61
  - test/test_typescript-node.rb
61
62
  - typescript-node.gemspec
@@ -70,7 +71,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
70
71
  requirements:
71
72
  - - ">="
72
73
  - !ruby/object:Gem::Version
73
- version: '0'
74
+ version: 1.9.3
74
75
  required_rubygems_version: !ruby/object:Gem::Requirement
75
76
  requirements:
76
77
  - - ">="
@@ -84,5 +85,6 @@ specification_version: 4
84
85
  summary: TypeScript ruby interface using Node.js
85
86
  test_files:
86
87
  - test/data/bad.ts
88
+ - test/data/es5.ts
87
89
  - test/data/hello.ts
88
90
  - test/test_typescript-node.rb