typescript-node 0.0.6 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NjhlNDBmNTgwZWI2ZDczNjQzOTA5MmQ3NGRmOThmNzU3YWVmZDYzNw==
5
- data.tar.gz: !binary |-
6
- MWQ0NDg0NjM4YjI0MDhlZTRlMTE2NTcyMjIwYmRlZjhlMDQwN2ZmNQ==
2
+ SHA1:
3
+ metadata.gz: a9bed1f037cba9d2d5f15c927159d82a8e27169f
4
+ data.tar.gz: aa3d3904333ee0bf4f525c67ddc90416372f8219
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MzAwMjNlZWRkZGIyNjhkZjg1MGEzYzcwYmJjMTQwYjE0YmY5N2RlNGNlN2Zj
10
- MzE3NjZkNTdlNzhlNzVlMWY5ZmI0YTg3OGY0NTg4Mjg1OWFhNzhkMDg4NWMx
11
- YWQ5OGRlYmJlMjlhMDFlNGZlZTJlYmFjYTA0YWY3M2RlODNlNmM=
12
- data.tar.gz: !binary |-
13
- ZTgxNjhmOGUwZDFiNDc5ZjBjZDM2ODY0YTVhODgzMGMwMDEwY2RkMzZjMjY1
14
- YWIzM2FlMmY2ZmJkZjA2ZjMyNTdhYzI5OTE4NjJjNTg2MjI0Y2JjNWI2Mjcw
15
- MGU1NDY5ZTkyZWJhOTYxZmUyNzI0NzhjZmQxMjRiNTQ3N2EwYzM=
6
+ metadata.gz: cf92e83c99c402cd3d6b5a14d419ef861d438256178237590c3de440e138618903a083414bee23fa06fefde1c3a4286a537bef1f455f94256e87facae6d0f678
7
+ data.tar.gz: d9ce011f3bd3704f05ec0cbd14c3622bcfb7df270f05300e21dc7270717bf44d02bdf546a8c8fc3ea9127aa0f209d0e4c97ccc68685c17971ed2ba52616a93ec
data/.travis.yml CHANGED
@@ -4,7 +4,8 @@ rvm:
4
4
  - 1.9.3
5
5
  - 1.9.2
6
6
  - 2.0.0
7
- - rbx-19mode
7
+ - 2.1.0
8
+ - rbx-2.1.1
8
9
  - jruby-18mode
9
10
  - jruby-19mode
10
11
  - ree
data/CHANGES.md ADDED
@@ -0,0 +1,4 @@
1
+ ## v1.0.0 2014-08-09 09:06:11+0900
2
+
3
+ * Depends on newer versions of typescript-src
4
+ * No feature change from previous versions
data/Gemfile CHANGED
@@ -1,8 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- group :development do
4
- gem "rake"
5
- gem "rspec"
3
+ group :test do
4
+ gem 'test-unit', '~> 3.0.0'
6
5
  end
7
6
 
8
7
  # Specify your gem's dependencies in typescript-node-ruby.gemspec
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Typescript::Node
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
2
 
3
- [![Build Status](https://secure.travis-ci.org/tkawachi/typescript-node-ruby.png?branch=master)](https://travis-ci.org/tkawachi/typescript-node-ruby)
3
+ TypeScript compiler in a gem.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,23 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
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)
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)
36
+ ```
37
+
22
38
 
23
39
  ## Contributing
24
40
 
data/Rakefile CHANGED
@@ -1,2 +1,11 @@
1
1
  #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
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
@@ -7,16 +7,19 @@ require "open3"
7
7
 
8
8
  module TypeScript
9
9
  module Node
10
-
11
10
  class << self
12
11
 
12
+ def tsc_version
13
+ TypeScript::Src.version
14
+ end
15
+
13
16
  # Compile TypeScript source file.
14
17
  # @param [String] source_file TypeScript source file
15
18
  # @return [TypeScript::Node::CompileResult] compile result
16
19
  def compile_file(source_file)
17
20
  Dir.mktmpdir do |output_dir|
18
21
  output_file = File.join(output_dir, "out.js")
19
- cmd = [node, Src.tsc_path, "--out", output_file, source_file]
22
+ cmd = [node, Src.tsc_path.to_s, "--out", output_file, source_file]
20
23
  Open3.popen3(*cmd) do |stdin, stdout, stderr, wait_thr|
21
24
  exit_status = wait_thr.value
22
25
  output_js = File.exists?(output_file) ? File.read(output_file) : nil
@@ -72,7 +75,7 @@ module TypeScript
72
75
  end
73
76
 
74
77
  def check_node
75
- unless locate_executable(self.node)
78
+ unless locate_executable(node)
76
79
  raise "typescript-node requires node command, but it's not found. Please install it. " +
77
80
  "Set TS_NODE environmental variable If you want to use node command in non-standard path."
78
81
  end
@@ -1,5 +1,5 @@
1
1
  module TypeScript
2
2
  module Node
3
- VERSION = "0.0.6"
3
+ VERSION = '1.0.0'
4
4
  end
5
5
  end
data/test/data/bad.ts ADDED
@@ -0,0 +1 @@
1
+ with syntax errors
File without changes
@@ -0,0 +1,41 @@
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
+ assert { subject.stderr != '' }
33
+ end
34
+
35
+ def test_compile
36
+ subject = TypeScript::Node.compile('class T { say() { console.log("Hello, world!") } }')
37
+
38
+ assert { subject != '' }
39
+ assert { subject != nil }
40
+ end
41
+ end
@@ -2,18 +2,20 @@
2
2
  require File.expand_path('../lib/typescript-node/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
+ gem.name = "typescript-node"
6
+
5
7
  gem.authors = ["KAWACHI Takashi"]
6
8
  gem.email = ["tkawachi@gmail.com"]
7
9
  gem.description = %q{TypeScript ruby interface using Node.js}
8
- gem.summary = %q{TypeScript ruby interface using Node.js}
9
- gem.homepage = "https://github.com/tkawachi/typescript-node-ruby"
10
+ gem.summary = gem.description
11
+ gem.homepage = "https://github.com/typescript-ruby/typescript-node-ruby"
10
12
 
11
13
  gem.files = `git ls-files`.split($\)
12
14
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
15
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
- gem.name = "typescript-node"
15
16
  gem.require_paths = ["lib"]
16
17
  gem.version = TypeScript::Node::VERSION
17
18
 
18
- gem.add_dependency 'typescript-src', '~> 1.0'
19
+ gem.add_dependency 'typescript-src', '~> 1.0.1'
20
+ gem.add_development_dependency 'rake'
19
21
  end
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typescript-node
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - KAWACHI Takashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-05 00:00:00.000000000 Z
11
+ date: 2014-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typescript-src
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: 1.0.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.0'
26
+ version: 1.0.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: TypeScript ruby interface using Node.js
28
42
  email:
29
43
  - tkawachi@gmail.com
@@ -31,8 +45,9 @@ executables: []
31
45
  extensions: []
32
46
  extra_rdoc_files: []
33
47
  files:
34
- - .gitignore
35
- - .travis.yml
48
+ - ".gitignore"
49
+ - ".travis.yml"
50
+ - CHANGES.md
36
51
  - Gemfile
37
52
  - LICENSE
38
53
  - README.md
@@ -40,10 +55,11 @@ files:
40
55
  - lib/typescript-node.rb
41
56
  - lib/typescript-node/compile_result.rb
42
57
  - lib/typescript-node/version.rb
43
- - spec/data/hello.ts
44
- - spec/typescript-node_spec.rb
58
+ - test/data/bad.ts
59
+ - test/data/hello.ts
60
+ - test/test_typescript-node.rb
45
61
  - typescript-node.gemspec
46
- homepage: https://github.com/tkawachi/typescript-node-ruby
62
+ homepage: https://github.com/typescript-ruby/typescript-node-ruby
47
63
  licenses: []
48
64
  metadata: {}
49
65
  post_install_message:
@@ -52,20 +68,21 @@ require_paths:
52
68
  - lib
53
69
  required_ruby_version: !ruby/object:Gem::Requirement
54
70
  requirements:
55
- - - ! '>='
71
+ - - ">="
56
72
  - !ruby/object:Gem::Version
57
73
  version: '0'
58
74
  required_rubygems_version: !ruby/object:Gem::Requirement
59
75
  requirements:
60
- - - ! '>='
76
+ - - ">="
61
77
  - !ruby/object:Gem::Version
62
78
  version: '0'
63
79
  requirements: []
64
80
  rubyforge_project:
65
- rubygems_version: 2.2.0
81
+ rubygems_version: 2.2.2
66
82
  signing_key:
67
83
  specification_version: 4
68
84
  summary: TypeScript ruby interface using Node.js
69
85
  test_files:
70
- - spec/data/hello.ts
71
- - spec/typescript-node_spec.rb
86
+ - test/data/bad.ts
87
+ - test/data/hello.ts
88
+ - test/test_typescript-node.rb
@@ -1,18 +0,0 @@
1
- require "typescript-node"
2
-
3
- module TypeScript
4
- module Node
5
- describe "#compile_file" do
6
- subject do
7
- hello_ts = File.expand_path("data/hello.ts", File.dirname(__FILE__))
8
- Node.compile_file(hello_ts)
9
- end
10
-
11
- its(:exit_status) { should == 0 }
12
- it { should be_success }
13
- its(:js) { should == "console.log(\"Hello TypeScript\");\n" }
14
- its(:stdout) { should == "" }
15
- its(:stderr) { should == "" }
16
- end
17
- end
18
- end