es6_module_transpiler-rails 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile +3 -0
- data/lib/es6_module_transpiler/rails.rb +8 -0
- data/lib/es6_module_transpiler/rails/version.rb +1 -1
- data/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb +8 -1
- data/test/template_test.rb +21 -0
- data/test/test_helper.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0396a7d9f2b2191ce7cb26673b02c24ff3dba5ad
|
4
|
+
data.tar.gz: 6b82cc19fec563735804cc0410299ba1267d5493
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb8969e1e230b35f3717ce5d2cc0441ef80cd183251090ea569fa275c92648c741f039e88017fadfbc791bf68f12be1fe56516959438b9b3b40437a25278e379
|
7
|
+
data.tar.gz: 335cf0abe9116d67a2d40324b8ba13827f3a1106065157909601f2e99791309da2722b097eb676d0a26a81e8e2b24759673b02d84223322379fd83ded36e9f2a
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -36,11 +36,18 @@ module Tilt
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def module_name(root_path, logical_path)
|
39
|
+
path = ''
|
39
40
|
if prefix = ES6ModuleTranspiler.lookup_prefix(File.join(root_path, logical_path))
|
40
41
|
path = File.join(prefix, logical_path)
|
41
42
|
else
|
42
|
-
logical_path
|
43
|
+
path = logical_path
|
43
44
|
end
|
45
|
+
|
46
|
+
if ES6ModuleTranspiler.transform
|
47
|
+
path = ES6ModuleTranspiler.transform.call(path)
|
48
|
+
end
|
49
|
+
|
50
|
+
path
|
44
51
|
end
|
45
52
|
|
46
53
|
def compiler_method
|
data/test/template_test.rb
CHANGED
@@ -20,6 +20,7 @@ JS
|
|
20
20
|
after do
|
21
21
|
ES6ModuleTranspiler.compile_to = nil
|
22
22
|
ES6ModuleTranspiler.prefix_patterns.clear
|
23
|
+
ES6ModuleTranspiler.transform = nil
|
23
24
|
end
|
24
25
|
|
25
26
|
it 'transpiles es6 into amd by default' do
|
@@ -153,4 +154,24 @@ JS
|
|
153
154
|
template = Tilt::ES6ModuleTranspilerTemplate.new { @source }
|
154
155
|
template.render(@scope).must_equal expected
|
155
156
|
end
|
157
|
+
|
158
|
+
it 'transpiles es6 into amd by default' do
|
159
|
+
expected = <<-JS
|
160
|
+
define("FOO",
|
161
|
+
["exports"],
|
162
|
+
function(__exports__) {
|
163
|
+
"use strict";
|
164
|
+
var foo = function() {
|
165
|
+
console.log('bar');
|
166
|
+
};
|
167
|
+
|
168
|
+
__exports__["default"] = foo;
|
169
|
+
});
|
170
|
+
JS
|
171
|
+
expected.rstrip!
|
172
|
+
|
173
|
+
ES6ModuleTranspiler.transform = lambda { |name| name.upcase }
|
174
|
+
template = Tilt::ES6ModuleTranspilerTemplate.new { @source }
|
175
|
+
template.render(@scope).must_equal expected
|
176
|
+
end
|
156
177
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: es6_module_transpiler-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Cardarella
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: execjs
|