typescript-rails 0.0.4 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NmIwZDQ2MjExNjA5OTYzZTJmMGNiNmM0NTI2ZTQ5NWY5MzQ1NmQzNQ==
5
+ data.tar.gz: !binary |-
6
+ OWE0NjBlZTJiYjYyZTdjMDAzYjA2MGNlMzg0ZGU5MDQ5OGUzYzcyNA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZmVlOTgzYzI3Nzk0OWZlMGQ4ZjVlNjE1ZWVmMmRjOWQ5YmU1NGI3NjY0YjM1
10
+ NDA2OTM2NWRlZDBmYjQxYzQ2YjVkNTZlZWI2Y2MzNDM3MTQzYTcyNmEwYTM3
11
+ NmJmYzdlZGRiMDMyOWI3NTcyODk3NDM2ZWQxOGIwZmY0NTk5OGE=
12
+ data.tar.gz: !binary |-
13
+ MTQzNmQ0OTRlYzMwMjYwZWRhMTIwZjY1YjM0YjVlMjBlODhiM2Y3MGRkNjYw
14
+ YjUzNjRkYTk2YWY5OGIzN2VkMTQyNWI0OGMwMDFkOTVjODI2YmVmNTUxNmEx
15
+ MzNjNzFjZTk3ZWI3YTZiZmRmNDU5NmYwNjczYTRhMTUzOGVhZWU=
@@ -1,5 +1,4 @@
1
1
  rvm:
2
- - 1.8.7
3
2
  - 1.9.2
4
3
  - 1.9.3
5
4
  - ree
data/README.md CHANGED
@@ -1,10 +1,27 @@
1
- # TypeScript for Rails ![Travis Build State](https://travis-ci.org/klaustopher/typescript-rails.png)
1
+ # TypeScript for Rails [![Build Status](https://travis-ci.org/klaustopher/typescript-rails.png?branch=master)](https://travis-ci.org/klaustopher/typescript-rails)
2
2
 
3
3
  This is a wrapper for the [TypeScript](http://www.typescriptlang.org/) JavaScript superset language by Microsoft.
4
4
 
5
5
  It enables you to use the `.ts` extension in the Asset Pipeline and also in ActionView Templates.
6
6
 
7
+ This gem uses the
8
+ [typescript-node-ruby](https://github.com/tkawachi/typescript-node-ruby)
9
+ library by KAWACHI Takashi for the typescript parsing with node js.
10
+
7
11
  The credit for the overall structure and the tests goes to the people that wrote the [coffee-rails](https://github.com/rails/coffee-rails) Gem, since I shamelessly copy&pasted some of their code.
12
+
13
+ ## Requirements
14
+
15
+ The current version requires that [node.js](http://nodejs.org/) is
16
+ installed on the system.
17
+
18
+ The requirement for node is tested upon starting the application. If
19
+ the node command is not available you get the following error message:
20
+
21
+ ```
22
+ 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.
23
+ ```
24
+
8
25
  ## Installation
9
26
 
10
27
  Add this line to your application's Gemfile:
@@ -16,7 +33,6 @@ And then execute:
16
33
  $ bundle
17
34
 
18
35
  ## Usage
19
-
20
36
  Just add a `.js.ts` file in your `app/assets/javascripts` directory and include it just like you are used to do.
21
37
 
22
38
  ## Contributing
@@ -1 +1 @@
1
- <%= TypeScript::Source.contents %>
1
+ <%= TypeScript::Src.js_content %>
@@ -1,4 +1,7 @@
1
- require "typescript"
1
+ require "open3"
2
+
3
+ require "typescript-node"
4
+
2
5
  require "typescript/rails/railtie"
3
6
  require "typescript/rails/engine"
4
7
  require "typescript/rails/template_handler"
@@ -41,7 +41,7 @@ module Typescript
41
41
  end
42
42
 
43
43
  def evaluate(scope, locals, &block)
44
- @output ||= TypeScript.compile(data, options)
44
+ @output ||= TypeScript::Node.compile(data)
45
45
  end
46
46
 
47
47
  def allows_script?
@@ -51,13 +51,13 @@ module Typescript
51
51
 
52
52
  class TemplateHandler
53
53
 
54
- def self.erb_handler
54
+ def self.erb_handler
55
55
  @@erb_handler ||= ActionView::Template.registered_template_handler(:erb)
56
56
  end
57
57
 
58
58
  def self.call(template)
59
59
  compiled_source = erb_handler.call(template)
60
- "TypeScript.compile(begin;#{compiled_source};end)"
60
+ "TypeScript::Node.compile(begin;#{compiled_source};end)"
61
61
  end
62
62
  end
63
63
  end
@@ -1,5 +1,5 @@
1
1
  module Typescript
2
2
  module Rails
3
- VERSION = "0.0.4"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -0,0 +1,3 @@
1
+ var f = function(x: number, y: number): number {
2
+ return x + y
3
+ }
@@ -0,0 +1,3 @@
1
+ /// <reference path="<%= File.join(File.dirname(__FILE__), "ref1_1.js.ts") %>" />
2
+
3
+ f(1, 2)
@@ -0,0 +1 @@
1
+ var f: (x: number, y: number) => number;
@@ -0,0 +1,3 @@
1
+ /// <reference path="<%= File.join(File.dirname(__FILE__), "ref2_1.d.ts") %>" />
2
+
3
+ f(1, 2)
@@ -9,6 +9,10 @@ end
9
9
  DummyApp = ActionDispatch::Routing::RouteSet.new
10
10
  DummyApp.draw do
11
11
  get "site/index"
12
+ get "site/ref1_1"
13
+ get "site/ref1_2"
14
+ get "site/ref2_1"
15
+ get "site/ref2_2"
12
16
  end
13
17
 
14
18
  class TemplateHandlerTest < ActiveSupport::TestCase
@@ -21,6 +25,17 @@ class TemplateHandlerTest < ActiveSupport::TestCase
21
25
  test "typescript views are served as javascript" do
22
26
  get "/site/index.js"
23
27
 
24
- assert_match "var x = 5;\n", last_response.body
28
+ assert_match "var x = 5;\r\n", last_response.body
25
29
  end
26
- end
30
+
31
+ test "<reference> to other .ts file works" do
32
+ get "/site/ref1_2.js"
33
+ assert_match "var f = function (x, y) {\r\n return x + y;\r\n};\r\nf(1, 2);\r\n", last_response.body
34
+ end
35
+
36
+ test "<reference> to other .d.ts file works" do
37
+ get "/site/ref2_2.js"
38
+ assert_match "f(1, 2);\r\n", last_response.body
39
+ end
40
+
41
+ end
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
16
16
 
17
17
  gem.rubyforge_project = "typescript-rails"
18
18
 
19
- gem.add_runtime_dependency 'typescript', '~> 0.1.1'
19
+ gem.add_runtime_dependency 'typescript-node', '~> 0.0'
20
20
  gem.add_runtime_dependency 'tilt', '~> 1.3'
21
21
  gem.add_runtime_dependency 'railties'
22
22
 
@@ -24,4 +24,6 @@ Gem::Specification.new do |gem|
24
24
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
25
25
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
26
26
  gem.require_paths = ["lib"]
27
+
28
+ gem.required_ruby_version = ">= 1.9.2"
27
29
  end
metadata CHANGED
@@ -1,36 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typescript-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 0.1.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Klaus Zanders
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-10-04 00:00:00.000000000 Z
11
+ date: 2013-03-31 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: typescript
14
+ name: typescript-node
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: 0.1.1
19
+ version: '0.0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: 0.1.1
26
+ version: '0.0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: tilt
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: railties
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
@@ -81,42 +74,43 @@ files:
81
74
  - test/assets_test.rb
82
75
  - test/support/routes.rb
83
76
  - test/support/site/index.js.ts
77
+ - test/support/site/ref1_1.js.ts
78
+ - test/support/site/ref1_2.js.ts
79
+ - test/support/site/ref2_1.d.ts
80
+ - test/support/site/ref2_2.js.ts
84
81
  - test/template_handler_test.rb
85
82
  - test/test_helper.rb
86
83
  - typescript-rails.gemspec
87
84
  homepage: http://github.com/klaustopher/typescript-rails
88
85
  licenses: []
86
+ metadata: {}
89
87
  post_install_message:
90
88
  rdoc_options: []
91
89
  require_paths:
92
90
  - lib
93
91
  required_ruby_version: !ruby/object:Gem::Requirement
94
- none: false
95
92
  requirements:
96
93
  - - ! '>='
97
94
  - !ruby/object:Gem::Version
98
- version: '0'
99
- segments:
100
- - 0
101
- hash: -980725228147315620
95
+ version: 1.9.2
102
96
  required_rubygems_version: !ruby/object:Gem::Requirement
103
- none: false
104
97
  requirements:
105
98
  - - ! '>='
106
99
  - !ruby/object:Gem::Version
107
100
  version: '0'
108
- segments:
109
- - 0
110
- hash: -980725228147315620
111
101
  requirements: []
112
102
  rubyforge_project: typescript-rails
113
- rubygems_version: 1.8.23
103
+ rubygems_version: 2.0.2
114
104
  signing_key:
115
- specification_version: 3
105
+ specification_version: 4
116
106
  summary: Adds Typescript to the Rails Asset pipeline
117
107
  test_files:
118
108
  - test/assets_test.rb
119
109
  - test/support/routes.rb
120
110
  - test/support/site/index.js.ts
111
+ - test/support/site/ref1_1.js.ts
112
+ - test/support/site/ref1_2.js.ts
113
+ - test/support/site/ref2_1.d.ts
114
+ - test/support/site/ref2_2.js.ts
121
115
  - test/template_handler_test.rb
122
116
  - test/test_helper.rb