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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 639759a9d30458af30037fc958972eda4e2b0e70
4
- data.tar.gz: beb903750ce56f442fb41e1c3eae7f42886d446c
3
+ metadata.gz: d716f7abc650659d6d0265678a5a085144c53106
4
+ data.tar.gz: dc6a563215325cec71abfab77557f64835cb6fb4
5
5
  SHA512:
6
- metadata.gz: 6e1d22dadd5071c9e5a7474f94685d21a65de75262645b03aa00c4b43e732051561165b968cf1eafea6daa474ca662a3d287c9bed99895a4910f860db21f5c03
7
- data.tar.gz: 1e5c93df7961015f52c7263cec06440c61386cf43b2fe7b0f582fade7dfca4865efada88793f56223df506acb15352088f32f136e66564e1cfa21a19b8c51eb5
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
@@ -1,11 +1,9 @@
1
1
  rvm:
2
- - 1.9.3
3
2
  - 2.0.0
4
3
  - 2.1.1
5
- - jruby
6
4
  notifications:
7
5
  email: false
8
6
  script: bundle exec rake test
9
7
  matrix:
10
8
  allow_failures:
11
- - rvm: jruby
9
+ - rvm:
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v0.4.2 2014-11-26 07:30:12+0900
2
+
3
+ * Fix newlines (#15)
4
+ * Mention to `default_options` in README (#18)
5
+
1
6
  ## v0.4.1 2014-08-12 00:05:17+0900
2
7
 
3
8
  * Fix a runtime error
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
- gem 'rails', '~> 4.0'
7
- gem 'minitest-power_assert'
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
- output = output + l + $/
26
- end
24
+ next l
25
+ end).join
27
26
 
28
27
  output
29
28
  end
@@ -1,5 +1,5 @@
1
1
  module Typescript
2
2
  module Rails
3
- VERSION = '0.4.1'
3
+ VERSION = '0.4.2'
4
4
  end
5
5
  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
- require "rails"
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.enabled = true
15
- @app.config.assets.cache_store = [ :file_store, "#{tmp_path}/cache" ]
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 "#{tmp_path}/cache"
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
- test "typescript.js is included in Sprockets environment" do
27
- @app.assets["typescript"].write_to("#{tmp_path}/typescript.js")
30
+ def tmp_path
31
+ "#{File.dirname(__FILE__)}/tmp"
32
+ end
28
33
 
29
- assert_match "/lib/assets/javascripts/typescript.js.erb", @app.assets["typescript"].pathname.to_s
30
- assert_match "var TypeScript", File.open("#{tmp_path}/typescript.js").read
34
+ def assets
35
+ @app.assets
31
36
  end
32
37
 
33
- def tmp_path
34
- "#{File.dirname(__FILE__)}/tmp"
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
@@ -0,0 +1,2 @@
1
+ var s: string = "Hello, world!";
2
+ console.log(s)
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("../support", __FILE__)
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 Rails Envinronment
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'
@@ -23,5 +23,5 @@ Gem::Specification.new do |gem|
23
23
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
24
24
  gem.require_paths = ["lib"]
25
25
 
26
- gem.required_ruby_version = ">= 1.9.3"
26
+ gem.required_ruby_version = ">= 2.0.0"
27
27
  end
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.1
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-08-11 00:00:00.000000000 Z
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/support/routes.rb
82
- - test/support/site/es5.js.ts
83
- - test/support/site/index.js.ts
84
- - test/support/site/ref1_1.js.ts
85
- - test/support/site/ref1_2.js.ts
86
- - test/support/site/ref2_1.d.ts
87
- - test/support/site/ref2_2.js.ts
88
- - test/support/site/ref3_1.js.ts
89
- - test/support/site/ref3_2.ts
90
- - test/support/site/ref3_3.ts
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: 1.9.3
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/support/routes.rb
120
- - test/support/site/es5.js.ts
121
- - test/support/site/index.js.ts
122
- - test/support/site/ref1_1.js.ts
123
- - test/support/site/ref1_2.js.ts
124
- - test/support/site/ref2_1.d.ts
125
- - test/support/site/ref2_2.js.ts
126
- - test/support/site/ref3_1.js.ts
127
- - test/support/site/ref3_2.ts
128
- - test/support/site/ref3_3.ts
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