ember-es6_template 0.1.0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ember-es6_template.gemspec +1 -0
- data/lib/ember/es6_template.rb +8 -0
- data/lib/ember/es6_template/coffee_script.rb +7 -0
- data/lib/ember/es6_template/coffee_script_helper.rb +30 -0
- data/lib/ember/es6_template/coffee_script_module.rb +7 -0
- data/lib/ember/es6_template/coffee_script_sprockets2.rb +45 -0
- data/lib/ember/es6_template/es6.rb +9 -5
- data/lib/ember/es6_template/es6module.rb +11 -7
- data/lib/ember/es6_template/version.rb +1 -1
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 661c005dad918587ad5ffa2a738b4a826f484a3a
|
4
|
+
data.tar.gz: 1d6dc39a2036f8eadc4cde6b0e58b0068b557969
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27e48a0469752c936954eb165ec13b517080a631c6f68d5487866177d0fced2e04c01342f1393ac8f6ba25c7cd898a8c764d65d2a379ca76e49425e5a83fb3a5
|
7
|
+
data.tar.gz: 360ded629dfb2979ae65a1801abd8391d893c421781a6da735f0fb5077b4b3219ca4ae9daddb4f3b51d34acaa56fb79b920af4b5fd08e32c40756e0564127ba5
|
data/ember-es6_template.gemspec
CHANGED
@@ -25,4 +25,5 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency 'rake', '~> 10.0'
|
26
26
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
27
27
|
spec.add_development_dependency 'minitest-power_assert'
|
28
|
+
spec.add_development_dependency 'coffee-script', '~> 2.3'
|
28
29
|
end
|
data/lib/ember/es6_template.rb
CHANGED
@@ -9,18 +9,26 @@ module Ember
|
|
9
9
|
when /^2\./
|
10
10
|
autoload :ES6, 'ember/es6_template/es6_sprockets2'
|
11
11
|
autoload :ES6Module, 'ember/es6_template/es6module_sprockets2'
|
12
|
+
autoload :CoffeeScript, 'ember/es6_template/coffee_script_sprockets2'
|
12
13
|
|
13
14
|
def self.setup(env)
|
14
15
|
env.register_engine '.es6', ES6
|
15
16
|
env.register_engine '.module', ES6Module
|
17
|
+
env.register_engine '.coffee', CoffeeScript
|
16
18
|
end
|
17
19
|
when /^3\./
|
18
20
|
autoload :ES6, 'ember/es6_template/es6'
|
19
21
|
autoload :ES6Module, 'ember/es6_template/es6module'
|
22
|
+
autoload :CoffeeScript, 'ember/es6_template/coffee_script'
|
23
|
+
autoload :CoffeeScriptModule, 'ember/es6_template/coffee_script_module'
|
24
|
+
autoload :CoffeeScriptHelper, 'ember/es6_template/coffee_script_helper'
|
20
25
|
|
21
26
|
def self.setup(env)
|
22
27
|
env.register_engine '.es6', ES6, mime_type: 'application/javascript'
|
23
28
|
env.register_engine '.module.es6', ES6Module, mime_type: 'application/javascript'
|
29
|
+
env.register_engine '.module.coffee', CoffeeScriptModule, mime_type: 'application/javascript'
|
30
|
+
env.register_engine '.coffee', CoffeeScript, mime_type: 'application/javascript' # Force parse as ES6
|
31
|
+
|
24
32
|
end
|
25
33
|
else
|
26
34
|
raise "Unsupported sprockets version: #{Sprockets::VERSION}"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Ember
|
2
|
+
module ES6Template
|
3
|
+
module CoffeeScriptHelper
|
4
|
+
def call(input)
|
5
|
+
data = input[:data]
|
6
|
+
|
7
|
+
result = input[:cache].fetch(cache_key + [data]) do
|
8
|
+
transform(
|
9
|
+
Sprockets::Autoload::CoffeeScript.compile(data, bare: true),
|
10
|
+
input
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
result['code']
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def cache_key
|
20
|
+
[
|
21
|
+
self.class.name,
|
22
|
+
VERSION,
|
23
|
+
Babel::Transpiler.version,
|
24
|
+
Babel::Transpiler.source_version,
|
25
|
+
Sprockets::Autoload::CoffeeScript.version
|
26
|
+
]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Ember
|
2
|
+
module ES6Template
|
3
|
+
class CoffeeScript < Tilt::CoffeeScriptTemplate
|
4
|
+
def evaluate(scope, locals, &block)
|
5
|
+
env = scope.environment
|
6
|
+
|
7
|
+
filename = scope.pathname.to_s
|
8
|
+
|
9
|
+
if es6_module?(filename)
|
10
|
+
result = Babel::Transpiler.transform(
|
11
|
+
::CoffeeScript.compile(data, bare: true),
|
12
|
+
'modules' => 'amd',
|
13
|
+
'moduleIds' => true,
|
14
|
+
'sourceRoot' => env.root,
|
15
|
+
'moduleRoot' => '',
|
16
|
+
'filename' => scope.logical_path,
|
17
|
+
'blacklist' => ['es6.modules'] # Next precessor transpile module syntax
|
18
|
+
)
|
19
|
+
elsif es6?(filename)
|
20
|
+
result = Babel::Transpiler.transform(
|
21
|
+
::CoffeeScript.compile(data, bare: true),
|
22
|
+
'sourceRoot' => env.root,
|
23
|
+
'moduleRoot' => '',
|
24
|
+
'filename' => scope.logical_path
|
25
|
+
)
|
26
|
+
else
|
27
|
+
return super
|
28
|
+
end
|
29
|
+
|
30
|
+
result['code']
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def es6_module?(filename)
|
36
|
+
filename =~ /\.module\.(?:es6\.)?coffee/
|
37
|
+
end
|
38
|
+
|
39
|
+
def es6?(filename)
|
40
|
+
filename =~ /\.(?:es6\.)?coffee/
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
@@ -13,11 +13,7 @@ module Ember
|
|
13
13
|
data = input[:data]
|
14
14
|
|
15
15
|
result = input[:cache].fetch(cache_key + [data]) do
|
16
|
-
|
17
|
-
'sourceRoot' => input[:load_path],
|
18
|
-
'moduleRoot' => '',
|
19
|
-
'filename' => input[:filename]
|
20
|
-
)
|
16
|
+
transform(data, input)
|
21
17
|
end
|
22
18
|
|
23
19
|
result['code']
|
@@ -25,6 +21,14 @@ module Ember
|
|
25
21
|
|
26
22
|
private
|
27
23
|
|
24
|
+
def transform(data, input)
|
25
|
+
Babel::Transpiler.transform(data,
|
26
|
+
'sourceRoot' => input[:load_path],
|
27
|
+
'moduleRoot' => '',
|
28
|
+
'filename' => input[:filename]
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
28
32
|
def cache_key
|
29
33
|
[
|
30
34
|
self.class.name,
|
@@ -13,13 +13,7 @@ module Ember
|
|
13
13
|
data = input[:data]
|
14
14
|
|
15
15
|
result = input[:cache].fetch(cache_key + [data]) do
|
16
|
-
|
17
|
-
'modules' => 'amd',
|
18
|
-
'moduleIds' => true,
|
19
|
-
'sourceRoot' => input[:load_path],
|
20
|
-
'moduleRoot' => '',
|
21
|
-
'filename' => input[:name]
|
22
|
-
)
|
16
|
+
transform(data, input)
|
23
17
|
end
|
24
18
|
|
25
19
|
result['code']
|
@@ -27,6 +21,16 @@ module Ember
|
|
27
21
|
|
28
22
|
private
|
29
23
|
|
24
|
+
def transform(data, input)
|
25
|
+
Babel::Transpiler.transform(data,
|
26
|
+
'modules' => 'amd',
|
27
|
+
'moduleIds' => true,
|
28
|
+
'sourceRoot' => input[:load_path],
|
29
|
+
'moduleRoot' => '',
|
30
|
+
'filename' => input[:name]
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
30
34
|
def cache_key
|
31
35
|
[
|
32
36
|
self.class.name,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ember-es6_template
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryunosuke SATO
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: babel-transpiler
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: coffee-script
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.3'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.3'
|
97
111
|
description: The tilt template for Ember specified ES6.
|
98
112
|
email:
|
99
113
|
- tricknotes.rs@gmail.com
|
@@ -111,6 +125,10 @@ files:
|
|
111
125
|
- bin/setup
|
112
126
|
- ember-es6_template.gemspec
|
113
127
|
- lib/ember/es6_template.rb
|
128
|
+
- lib/ember/es6_template/coffee_script.rb
|
129
|
+
- lib/ember/es6_template/coffee_script_helper.rb
|
130
|
+
- lib/ember/es6_template/coffee_script_module.rb
|
131
|
+
- lib/ember/es6_template/coffee_script_sprockets2.rb
|
114
132
|
- lib/ember/es6_template/es6.rb
|
115
133
|
- lib/ember/es6_template/es6_sprockets2.rb
|
116
134
|
- lib/ember/es6_template/es6module.rb
|