typescript-rails 0.6.2.3 → 0.6.2.4

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: 923b75039608701df33b61e2019e9d50fb7ec7eb
4
- data.tar.gz: e3eaf645e9f61af98daa6c00b18512ffda5ce35e
3
+ metadata.gz: 6ba55625d79bfc90c48a9f2ffc7bff39451b9fc9
4
+ data.tar.gz: fba7be46b49d00e0176cfb3c10b1246336c516bf
5
5
  SHA512:
6
- metadata.gz: 9bc69a4d44eef1ae5e18592b269a7055736ddac3ebcba27fff89ec1a08ea5722e62c16cd81f102ddee2c07640d04219d9c26049c8a8a3251abbe1ef417260555
7
- data.tar.gz: 791b48d6b8b52ba9b0d0bf5535bb7a53f5dacb00847096a0ea6b792df069d564e64a00a54e4f67adf69eac6616d7930130152064f6f36337e6f6470b2d8270a8
6
+ metadata.gz: 16013c661b36ad9e59afa8b048c50f2927bf30db9bf4a0fc7b8d29cdb66075d421f0fa3c6f9a9ff322c89a08daf427c38ef18d7f36c51f4ed4bc32237f047f48
7
+ data.tar.gz: 06ca3adb3994e6a532c04910dd6373abc0c6b150e94857b175e54703ae3f06775a82643aab58c97db29fb2c3c5545ba84b8a180124602ccbccb0e7fb275168d5
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.6.2.4 2016-09-12 13:48:00+0300
2
+
3
+ * Add typescript template generator (not defaulted). Thanks to @mjfaga
4
+
1
5
  ## v0.6.2.3 2016-07-27 17:25:00+0300
2
6
 
3
7
  * Fixed incorrect value of register_mime_type (@mihai-dinculescu)
data/README.md CHANGED
@@ -43,6 +43,23 @@ Configurations:
43
43
  Typescript::Rails::Compiler.default_options = [ ... ]
44
44
  ```
45
45
 
46
+ ## Default Javascript Compilation
47
+
48
+ Add this line to your `config/application.rb` as show below, above the `config.assets.enabled = true`:
49
+
50
+ ```ruby
51
+ config.app_generators.javascript_engine :typescript
52
+
53
+ # Enable the asset pipeline
54
+ config.assets.enabled = true
55
+ ```
56
+
57
+ If you don't want it to be the default javascript engine, you can also use it adhoc as show below:
58
+
59
+ ```ruby
60
+ rails g controller MyController --javascript_engine=typescript
61
+ ```
62
+
46
63
  ## Referenced TypeScript dependencies
47
64
 
48
65
  `typescript-rails` recurses through all [TypeScript-style](https://github.com/teppeis/typescript-spec-md/blob/master/en/ch11.md#1111-source-files-dependencies) referenced files and tells its [`Sprockets::Context`](https://github.com/sstephenson/sprockets/blob/master/lib/sprockets/context.rb) that the TS file being processed [`depend`s`_on`](https://github.com/sstephenson/sprockets#the-depend_on-directive) each file listed as a reference. This activates Sprocket’s cache-invalidation behavior when any of the descendant references of the root TS file is changed.
@@ -0,0 +1,13 @@
1
+ require "rails/generators/named_base"
2
+
3
+ module Typescript
4
+ module Generators
5
+ class AssetsGenerator < ::Rails::Generators::NamedBase
6
+ source_root File.expand_path("../templates", __FILE__)
7
+
8
+ def copy_typescript
9
+ template "javascript.ts", File.join('app/assets/javascripts', class_path, "#{file_name}.ts")
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
3
+ // You can use TypeScript in this file: www.typescriptlang.org
@@ -1,6 +1,18 @@
1
1
  require 'rails/engine'
2
+ require 'rails/generators'
3
+ require 'typescript/rails/js_hook'
2
4
 
3
5
  class Typescript::Rails::Engine < Rails::Engine
4
- # For now, let's not be the default generator ...
5
- # config.app_generators.javascript_engine :ts
6
- end
6
+ # To become the default generator...
7
+ # config.app_generators.javascript_engine :typescript
8
+
9
+ if config.respond_to?(:annotations)
10
+ config.annotations.register_extensions(".ts") { |annotation| /#\s*(#{annotation}):?\s*(.*)$/ }
11
+ end
12
+
13
+ initializer 'override js_template hook' do |app|
14
+ if app.config.generators.rails[:javascript_engine] == :typescript
15
+ ::Rails::Generators::NamedBase.send :include, Typescript::Rails::JsHook
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ module Typescript
2
+ module Rails
3
+ module JsHook
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ no_tasks do
8
+ redefine_method :js_template do |source, destination|
9
+ template(source + '.ts', destination + '.ts')
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  module Typescript
2
2
  module Rails
3
- VERSION = '0.6.2.3'
3
+ VERSION = '0.6.2.4'
4
4
  end
5
5
  end
@@ -0,0 +1,15 @@
1
+ require 'test_helper'
2
+ require 'rails/generators/typescript/assets/assets_generator'
3
+
4
+ class AssetGeneratorTest < Rails::Generators::TestCase
5
+ tests Typescript::Generators::AssetsGenerator
6
+
7
+ destination File.expand_path("../tmp", __FILE__)
8
+ setup :prepare_destination
9
+
10
+ def test_assets
11
+ run_generator %w(posts)
12
+ assert_no_file "app/assets/javascripts/posts.js"
13
+ assert_file "app/assets/javascripts/posts.ts"
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ require 'test_helper'
2
+ require 'rails/generators/rails/controller/controller_generator'
3
+ require 'rails/generators/typescript/assets/assets_generator'
4
+
5
+ class ControllerGeneratorTest < Rails::Generators::TestCase
6
+ tests Rails::Generators::ControllerGenerator
7
+
8
+ destination File.expand_path("../tmp", __FILE__)
9
+ setup do
10
+ prepare_destination
11
+ copy_routes
12
+ end
13
+
14
+ def test_assets
15
+ run_generator %w(posts --javascript-engine=typescript --orm=false)
16
+ assert_no_file "app/assets/javascripts/posts.js"
17
+ assert_file "app/assets/javascripts/posts.ts"
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ require 'test_helper'
2
+ require 'rails/generators/rails/scaffold/scaffold_generator'
3
+ require 'rails/generators/typescript/assets/assets_generator'
4
+
5
+ class ScaffoldGeneratorTest < Rails::Generators::TestCase
6
+ tests Rails::Generators::ScaffoldGenerator
7
+
8
+ destination File.expand_path("../tmp", __FILE__)
9
+ setup do
10
+ prepare_destination
11
+ copy_routes
12
+ end
13
+
14
+ def test_assets
15
+ run_generator %w(posts --javascript-engine=typescript --orm=false)
16
+ assert_no_file "app/assets/javascripts/posts.js"
17
+ assert_file "app/assets/javascripts/posts.ts"
18
+ end
19
+ end
@@ -0,0 +1 @@
1
+ # routes dummy file
@@ -18,6 +18,9 @@ require 'rails'
18
18
  require 'rails/test_help'
19
19
  require 'minitest-power_assert'
20
20
 
21
+ # For generators
22
+ require 'rails/generators/test_case'
23
+
21
24
  def copy_routes
22
25
  routes = File.expand_path('../support/routes.rb', __FILE__)
23
26
  destination = File.join(destination_root, 'config')
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.6.2.3
4
+ version: 0.6.2.4
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: 2016-07-27 00:00:00.000000000 Z
12
+ date: 2016-09-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: typescript-node
@@ -70,16 +70,21 @@ files:
70
70
  - README.md
71
71
  - Rakefile
72
72
  - lib/assets/javascripts/typescript.js.erb
73
+ - lib/rails/generators/typescript/assets/assets_generator.rb
74
+ - lib/rails/generators/typescript/assets/templates/javascript.ts
73
75
  - lib/typescript-rails.rb
74
76
  - lib/typescript/rails.rb
75
77
  - lib/typescript/rails/compiler.rb
76
78
  - lib/typescript/rails/engine.rb
79
+ - lib/typescript/rails/js_hook.rb
77
80
  - lib/typescript/rails/railtie.rb
78
81
  - lib/typescript/rails/template.rb
79
82
  - lib/typescript/rails/template_handler.rb
80
83
  - lib/typescript/rails/transformer.rb
81
84
  - lib/typescript/rails/version.rb
85
+ - test/assets_generator_test.rb
82
86
  - test/assets_test.rb
87
+ - test/controller_generator_test.rb
83
88
  - test/fixtures/assets/javascripts/hello.js.ts
84
89
  - test/fixtures/assets/javascripts/included.ts
85
90
  - test/fixtures/assets/javascripts/reference.ts
@@ -93,6 +98,8 @@ files:
93
98
  - test/fixtures/site/ref3_1.js.ts
94
99
  - test/fixtures/site/ref3_2.ts
95
100
  - test/fixtures/site/ref3_3.ts
101
+ - test/scaffold_generator_test.rb
102
+ - test/support/routes.rb
96
103
  - test/template_handler_test.rb
97
104
  - test/test_helper.rb
98
105
  - typescript-rails.gemspec
@@ -120,7 +127,9 @@ signing_key:
120
127
  specification_version: 4
121
128
  summary: Adds Typescript to the Rails Asset pipeline
122
129
  test_files:
130
+ - test/assets_generator_test.rb
123
131
  - test/assets_test.rb
132
+ - test/controller_generator_test.rb
124
133
  - test/fixtures/assets/javascripts/hello.js.ts
125
134
  - test/fixtures/assets/javascripts/included.ts
126
135
  - test/fixtures/assets/javascripts/reference.ts
@@ -134,6 +143,8 @@ test_files:
134
143
  - test/fixtures/site/ref3_1.js.ts
135
144
  - test/fixtures/site/ref3_2.ts
136
145
  - test/fixtures/site/ref3_3.ts
146
+ - test/scaffold_generator_test.rb
147
+ - test/support/routes.rb
137
148
  - test/template_handler_test.rb
138
149
  - test/test_helper.rb
139
150
  has_rdoc: