typescript-rails 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.travis.yml +1 -3
- data/CHANGES.md +5 -0
- data/Gemfile +7 -2
- data/README.md +10 -2
- data/lib/typescript/rails/compiler.rb +3 -4
- data/lib/typescript/rails/version.rb +1 -1
- data/test/assets_test.rb +26 -15
- data/test/fixtures/assets/javascripts/hello.js.ts +2 -0
- data/test/{support → fixtures}/routes.rb +0 -0
- data/test/{support → fixtures}/site/es5.js.ts +0 -0
- data/test/{support → fixtures}/site/index.js.ts +0 -0
- data/test/{support → fixtures}/site/ref1_1.js.ts +0 -0
- data/test/{support → fixtures}/site/ref1_2.js.ts +0 -0
- data/test/{support → fixtures}/site/ref2_1.d.ts +0 -0
- data/test/{support → fixtures}/site/ref2_2.js.ts +0 -0
- data/test/{support → fixtures}/site/ref3_1.js.ts +0 -0
- data/test/{support → fixtures}/site/ref3_2.ts +0 -0
- data/test/{support → fixtures}/site/ref3_3.ts +0 -0
- data/test/template_handler_test.rb +1 -1
- data/test/test_helper.rb +14 -1
- data/typescript-rails.gemspec +1 -1
- metadata +26 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d716f7abc650659d6d0265678a5a085144c53106
|
4
|
+
data.tar.gz: dc6a563215325cec71abfab77557f64835cb6fb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13286cd68dc352b52e6822aa36999fa9499492dcd7c3d98d7bcbe42c15cc70e49e3af5222f5df748aa58cb640e5e4f5e367157c11fcab8defc8c511d299f32c7
|
7
|
+
data.tar.gz: 5ce4c3dc47c79cc660fc911b6d8573a71abb2496e33324d1c1e05606ea74865298715383979b778193f7004750a1a20fb585eafd3e0e65596557995f5c4c63cd
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
data/Gemfile
CHANGED
@@ -3,5 +3,10 @@ source 'https://rubygems.org'
|
|
3
3
|
# Specify your gem's dependencies in typescript-rails.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
|
7
|
-
gem '
|
6
|
+
group :test do
|
7
|
+
gem 'rails', '~> 4.0'
|
8
|
+
gem 'minitest-power_assert'
|
9
|
+
gem 'coveralls'
|
10
|
+
gem 'simplecov'
|
11
|
+
end
|
12
|
+
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# TypeScript for Rails [![Build Status](https://travis-ci.org/typescript-ruby/typescript-rails.svg?branch=master)](https://travis-ci.org/typescript-ruby/typescript-rails)
|
1
|
+
# TypeScript for Rails [![Build Status](https://travis-ci.org/typescript-ruby/typescript-rails.svg?branch=master)](https://travis-ci.org/typescript-ruby/typescript-rails) [![Coverage Status](https://coveralls.io/repos/typescript-ruby/typescript-rails/badge.png)](https://coveralls.io/r/typescript-ruby/typescript-rails)
|
2
2
|
|
3
|
-
This is a wrapper for the [TypeScript](http://www.typescriptlang.org/) JavaScript superset language by Microsoft.
|
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
|
|
@@ -36,6 +36,14 @@ And then execute:
|
|
36
36
|
|
37
37
|
Just add a `.js.ts` file in your `app/assets/javascripts` directory and include it just like you are used to do.
|
38
38
|
|
39
|
+
Configurations:
|
40
|
+
|
41
|
+
```
|
42
|
+
# Its defaults are `--target ES5 --noImplicitAny`.
|
43
|
+
Typescript::Rails::Compiler.default_options = [ ... ]
|
44
|
+
```
|
45
|
+
|
46
|
+
|
39
47
|
## Contributing
|
40
48
|
|
41
49
|
1. Fork it
|
@@ -17,13 +17,12 @@ module Typescript::Rails::Compiler
|
|
17
17
|
|
18
18
|
# Why don't we just use gsub? Because it display odd behavior with File.join on Ruby 2.0
|
19
19
|
# So we go the long way around.
|
20
|
-
output =
|
21
|
-
source.each_line do |l|
|
20
|
+
output = (source.each_line.map do |l|
|
22
21
|
if l.starts_with?('///') && !(m = %r!^///\s*<reference\s+path="([^"]+)"\s*/>\s*!.match(l)).nil?
|
23
22
|
l = l.sub(m.captures[0], File.join(escaped_dir, m.captures[0]))
|
24
23
|
end
|
25
|
-
|
26
|
-
end
|
24
|
+
next l
|
25
|
+
end).join
|
27
26
|
|
28
27
|
output
|
29
28
|
end
|
data/test/assets_test.rb
CHANGED
@@ -1,36 +1,47 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'typescript-rails'
|
3
3
|
|
4
|
+
require "action_controller/railtie"
|
5
|
+
require "sprockets/railtie"
|
6
|
+
|
7
|
+
|
4
8
|
class AssetsTest < ActiveSupport::TestCase
|
9
|
+
include Minitest::PowerAssert::Assertions
|
10
|
+
|
5
11
|
def setup
|
6
|
-
|
7
|
-
require 'tzinfo'
|
8
|
-
require "action_controller/railtie"
|
9
|
-
require "sprockets/railtie"
|
12
|
+
FileUtils.mkdir_p tmp_path
|
10
13
|
|
11
14
|
@app = Class.new(Rails::Application)
|
15
|
+
|
12
16
|
@app.config.eager_load = false
|
13
17
|
@app.config.active_support.deprecation = :stderr
|
14
|
-
@app.config.assets.
|
15
|
-
|
18
|
+
@app.config.assets.configure do |env|
|
19
|
+
env.cache = ActiveSupport::Cache.lookup_store(:memory_store)
|
20
|
+
end
|
21
|
+
@app.config.assets.paths << "#{File.dirname(__FILE__)}/fixtures/assets"
|
16
22
|
@app.paths["log"] = "#{tmp_path}/log/test.log"
|
17
23
|
@app.initialize!
|
18
24
|
end
|
19
25
|
|
20
26
|
def teardown
|
21
|
-
FileUtils.rm_rf
|
22
|
-
FileUtils.rm_rf "#{tmp_path}/log"
|
23
|
-
#File.delete "#{tmp_path}/typescript.js"
|
27
|
+
FileUtils.rm_rf tmp_path
|
24
28
|
end
|
25
29
|
|
26
|
-
|
27
|
-
|
30
|
+
def tmp_path
|
31
|
+
"#{File.dirname(__FILE__)}/tmp"
|
32
|
+
end
|
28
33
|
|
29
|
-
|
30
|
-
|
34
|
+
def assets
|
35
|
+
@app.assets
|
31
36
|
end
|
32
37
|
|
33
|
-
|
34
|
-
"
|
38
|
+
test "typescript.js is included in Sprockets environment" do
|
39
|
+
assert { assets["typescript"].pathname.to_s.end_with?('/lib/assets/javascripts/typescript.js.erb') }
|
40
|
+
assert { assets["typescript"].body.include?('var TypeScript') }
|
41
|
+
end
|
42
|
+
|
43
|
+
test "assets .js.ts is compiled from TypeScript to JavaScript" do
|
44
|
+
assert { assets["javascripts/hello"].present? }
|
45
|
+
assert { assets["javascripts/hello"].body.include?('var s = "Hello, world!";') }
|
35
46
|
end
|
36
47
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -3,7 +3,7 @@ require 'action_controller'
|
|
3
3
|
require 'typescript-rails'
|
4
4
|
|
5
5
|
class SiteController < ActionController::Base
|
6
|
-
self.view_paths = File.expand_path("../
|
6
|
+
self.view_paths = File.expand_path("../fixtures", __FILE__)
|
7
7
|
end
|
8
8
|
|
9
9
|
DummyApp = ActionDispatch::Routing::RouteSet.new
|
data/test/test_helper.rb
CHANGED
@@ -1,4 +1,17 @@
|
|
1
|
-
# Configure
|
1
|
+
# Configure coveralls environment
|
2
|
+
|
3
|
+
require 'coveralls'
|
4
|
+
require 'simplecov'
|
5
|
+
|
6
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
7
|
+
SimpleCov::Formatter::HTMLFormatter,
|
8
|
+
Coveralls::SimpleCov::Formatter
|
9
|
+
]
|
10
|
+
SimpleCov.start do
|
11
|
+
add_filter '.bundle/'
|
12
|
+
end
|
13
|
+
|
14
|
+
# Configure Rails environment
|
2
15
|
ENV["RAILS_ENV"] = "test"
|
3
16
|
|
4
17
|
require 'rails'
|
data/typescript-rails.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typescript-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- FUJI, Goro
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-11-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: typescript-node
|
@@ -61,6 +61,7 @@ executables: []
|
|
61
61
|
extensions: []
|
62
62
|
extra_rdoc_files: []
|
63
63
|
files:
|
64
|
+
- ".coveralls.yml"
|
64
65
|
- ".gitignore"
|
65
66
|
- ".travis.yml"
|
66
67
|
- CHANGES.md
|
@@ -78,16 +79,17 @@ files:
|
|
78
79
|
- lib/typescript/rails/template_handler.rb
|
79
80
|
- lib/typescript/rails/version.rb
|
80
81
|
- test/assets_test.rb
|
81
|
-
- test/
|
82
|
-
- test/
|
83
|
-
- test/
|
84
|
-
- test/
|
85
|
-
- test/
|
86
|
-
- test/
|
87
|
-
- test/
|
88
|
-
- test/
|
89
|
-
- test/
|
90
|
-
- test/
|
82
|
+
- test/fixtures/assets/javascripts/hello.js.ts
|
83
|
+
- test/fixtures/routes.rb
|
84
|
+
- test/fixtures/site/es5.js.ts
|
85
|
+
- test/fixtures/site/index.js.ts
|
86
|
+
- test/fixtures/site/ref1_1.js.ts
|
87
|
+
- test/fixtures/site/ref1_2.js.ts
|
88
|
+
- test/fixtures/site/ref2_1.d.ts
|
89
|
+
- test/fixtures/site/ref2_2.js.ts
|
90
|
+
- test/fixtures/site/ref3_1.js.ts
|
91
|
+
- test/fixtures/site/ref3_2.ts
|
92
|
+
- test/fixtures/site/ref3_3.ts
|
91
93
|
- test/template_handler_test.rb
|
92
94
|
- test/test_helper.rb
|
93
95
|
- typescript-rails.gemspec
|
@@ -102,7 +104,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
104
|
requirements:
|
103
105
|
- - ">="
|
104
106
|
- !ruby/object:Gem::Version
|
105
|
-
version:
|
107
|
+
version: 2.0.0
|
106
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
109
|
requirements:
|
108
110
|
- - ">="
|
@@ -116,15 +118,16 @@ specification_version: 4
|
|
116
118
|
summary: Adds Typescript to the Rails Asset pipeline
|
117
119
|
test_files:
|
118
120
|
- test/assets_test.rb
|
119
|
-
- test/
|
120
|
-
- test/
|
121
|
-
- test/
|
122
|
-
- test/
|
123
|
-
- test/
|
124
|
-
- test/
|
125
|
-
- test/
|
126
|
-
- test/
|
127
|
-
- test/
|
128
|
-
- test/
|
121
|
+
- test/fixtures/assets/javascripts/hello.js.ts
|
122
|
+
- test/fixtures/routes.rb
|
123
|
+
- test/fixtures/site/es5.js.ts
|
124
|
+
- test/fixtures/site/index.js.ts
|
125
|
+
- test/fixtures/site/ref1_1.js.ts
|
126
|
+
- test/fixtures/site/ref1_2.js.ts
|
127
|
+
- test/fixtures/site/ref2_1.d.ts
|
128
|
+
- test/fixtures/site/ref2_2.js.ts
|
129
|
+
- test/fixtures/site/ref3_1.js.ts
|
130
|
+
- test/fixtures/site/ref3_2.ts
|
131
|
+
- test/fixtures/site/ref3_3.ts
|
129
132
|
- test/template_handler_test.rb
|
130
133
|
- test/test_helper.rb
|