typescript-rails 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/README.md +1 -0
- data/Rakefile +11 -1
- data/lib/typescript/rails/version.rb +1 -1
- data/test/assets_test.rb +35 -0
- data/test/support/routes.rb +0 -0
- data/test/support/site/index.js.ts +1 -0
- data/test/template_handler_test.rb +26 -0
- data/test/test_helper.rb +14 -0
- data/typescript-rails.gemspec +8 -1
- metadata +64 -6
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,7 @@ This is a wrapper for the [TypeScript](http://www.typescriptlang.org/) JavaScrip
|
|
4
4
|
|
5
5
|
It enables you to use the `.ts` extension in the Asset Pipeline and also in ActionView Templates.
|
6
6
|
|
7
|
+
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.
|
7
8
|
## Installation
|
8
9
|
|
9
10
|
Add this line to your application's Gemfile:
|
data/Rakefile
CHANGED
data/test/assets_test.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'typescript-rails'
|
3
|
+
|
4
|
+
class AssetsTest < ActiveSupport::TestCase
|
5
|
+
def setup
|
6
|
+
require "rails"
|
7
|
+
require 'tzinfo'
|
8
|
+
require "action_controller/railtie"
|
9
|
+
require "sprockets/railtie"
|
10
|
+
|
11
|
+
@app = Class.new(Rails::Application)
|
12
|
+
@app.config.active_support.deprecation = :stderr
|
13
|
+
@app.config.assets.enabled = true
|
14
|
+
@app.config.assets.cache_store = [ :file_store, "#{tmp_path}/cache" ]
|
15
|
+
@app.paths["log"] = "#{tmp_path}/log/test.log"
|
16
|
+
@app.initialize!
|
17
|
+
end
|
18
|
+
|
19
|
+
def teardown
|
20
|
+
FileUtils.rm_rf "#{tmp_path}/cache"
|
21
|
+
FileUtils.rm_rf "#{tmp_path}/log"
|
22
|
+
#File.delete "#{tmp_path}/typescript.js"
|
23
|
+
end
|
24
|
+
|
25
|
+
test "typescript.js is included in Sprockets environment" do
|
26
|
+
@app.assets["typescript"].write_to("#{tmp_path}/typescript.js")
|
27
|
+
|
28
|
+
assert_match "/lib/assets/javascripts/typescript.js.erb", @app.assets["typescript"].pathname.to_s
|
29
|
+
assert_match "var TypeScript", File.open("#{tmp_path}/typescript.js").read
|
30
|
+
end
|
31
|
+
|
32
|
+
def tmp_path
|
33
|
+
"#{File.dirname(__FILE__)}/tmp"
|
34
|
+
end
|
35
|
+
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
var x:number = 5
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'action_controller'
|
3
|
+
require 'typescript-rails'
|
4
|
+
|
5
|
+
class SiteController < ActionController::Base
|
6
|
+
self.view_paths = File.expand_path("../support", __FILE__)
|
7
|
+
end
|
8
|
+
|
9
|
+
DummyApp = ActionDispatch::Routing::RouteSet.new
|
10
|
+
DummyApp.draw do
|
11
|
+
get "site/index"
|
12
|
+
end
|
13
|
+
|
14
|
+
class TemplateHandlerTest < ActiveSupport::TestCase
|
15
|
+
include Rack::Test::Methods
|
16
|
+
|
17
|
+
def app
|
18
|
+
@app ||= DummyApp
|
19
|
+
end
|
20
|
+
|
21
|
+
test "typescript views are served as javascript" do
|
22
|
+
get "/site/index.js"
|
23
|
+
|
24
|
+
assert_match "var x = 5;\n", last_response.body
|
25
|
+
end
|
26
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Configure Rails Envinronment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require 'rails'
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
|
8
|
+
def copy_routes
|
9
|
+
routes = File.expand_path("../support/routes.rb", __FILE__)
|
10
|
+
destination = File.join(destination_root, "config")
|
11
|
+
|
12
|
+
FileUtils.mkdir_p(destination)
|
13
|
+
FileUtils.cp routes, destination
|
14
|
+
end
|
data/typescript-rails.gemspec
CHANGED
@@ -1,18 +1,25 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
4
5
|
require 'typescript/rails/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |gem|
|
7
8
|
gem.name = "typescript-rails"
|
8
9
|
gem.version = Typescript::Rails::VERSION
|
10
|
+
gem.platform = Gem::Platform::RUBY
|
9
11
|
gem.authors = ["Klaus Zanders"]
|
10
12
|
gem.email = ["klaus.zanders@gmail.com"]
|
11
13
|
gem.description = %q{Adds Typescript to the Rails Asset pipeline}
|
12
14
|
gem.summary = %q{Adds Typescript to the Rails Asset pipeline}
|
13
|
-
gem.homepage = ""
|
15
|
+
gem.homepage = "http://github.com/klaustopher/typescript-rails"
|
16
|
+
|
17
|
+
gem.rubyforge_project = "typescript-rails"
|
14
18
|
|
15
19
|
gem.add_runtime_dependency 'typescript'
|
20
|
+
gem.add_runtime_dependency 'tilt', '~> 1.3'
|
21
|
+
gem.add_runtime_dependency 'railties'
|
22
|
+
gem.add_runtime_dependency 'sprockets-rails'
|
16
23
|
|
17
24
|
gem.files = `git ls-files`.split($/)
|
18
25
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
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.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -27,6 +27,54 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: tilt
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.3'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.3'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: railties
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: sprockets-rails
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
30
78
|
description: Adds Typescript to the Rails Asset pipeline
|
31
79
|
email:
|
32
80
|
- klaus.zanders@gmail.com
|
@@ -45,8 +93,13 @@ files:
|
|
45
93
|
- lib/typescript/rails/railtie.rb
|
46
94
|
- lib/typescript/rails/template_handler.rb
|
47
95
|
- lib/typescript/rails/version.rb
|
96
|
+
- test/assets_test.rb
|
97
|
+
- test/support/routes.rb
|
98
|
+
- test/support/site/index.js.ts
|
99
|
+
- test/template_handler_test.rb
|
100
|
+
- test/test_helper.rb
|
48
101
|
- typescript-rails.gemspec
|
49
|
-
homepage:
|
102
|
+
homepage: http://github.com/klaustopher/typescript-rails
|
50
103
|
licenses: []
|
51
104
|
post_install_message:
|
52
105
|
rdoc_options: []
|
@@ -60,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
60
113
|
version: '0'
|
61
114
|
segments:
|
62
115
|
- 0
|
63
|
-
hash: -
|
116
|
+
hash: -3799657635995712802
|
64
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
118
|
none: false
|
66
119
|
requirements:
|
@@ -69,11 +122,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
122
|
version: '0'
|
70
123
|
segments:
|
71
124
|
- 0
|
72
|
-
hash: -
|
125
|
+
hash: -3799657635995712802
|
73
126
|
requirements: []
|
74
|
-
rubyforge_project:
|
127
|
+
rubyforge_project: typescript-rails
|
75
128
|
rubygems_version: 1.8.23
|
76
129
|
signing_key:
|
77
130
|
specification_version: 3
|
78
131
|
summary: Adds Typescript to the Rails Asset pipeline
|
79
|
-
test_files:
|
132
|
+
test_files:
|
133
|
+
- test/assets_test.rb
|
134
|
+
- test/support/routes.rb
|
135
|
+
- test/support/site/index.js.ts
|
136
|
+
- test/template_handler_test.rb
|
137
|
+
- test/test_helper.rb
|