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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df247f64aa23e630a5f7a2b1a8ddae37d896fe88
4
- data.tar.gz: 47b694121e3470f4f0d3dfac9cd2ab56fd2481ec
3
+ metadata.gz: 0396a7d9f2b2191ce7cb26673b02c24ff3dba5ad
4
+ data.tar.gz: 6b82cc19fec563735804cc0410299ba1267d5493
5
5
  SHA512:
6
- metadata.gz: 0f0f433a5c78e59b54719322aa81d3360faf9a715e5ff811d03e3ba53eddb0f1ae7e949c4ae449b288bbca69a670ee5e46191cb3b22663544a2345a0b46e31e5
7
- data.tar.gz: cc11c327dca5ec9f92c0662055c9ac601944cc6c2fb30b27d06a90f80dc4673286dc9503721f7117c40d512d020d5fb6314215a5b3fcefe3967e053063f85497
6
+ metadata.gz: bb8969e1e230b35f3717ce5d2cc0441ef80cd183251090ea569fa275c92648c741f039e88017fadfbc791bf68f12be1fe56516959438b9b3b40437a25278e379
7
+ data.tar.gz: 335cf0abe9116d67a2d40324b8ba13827f3a1106065157909601f2e99791309da2722b097eb676d0a26a81e8e2b24759673b02d84223322379fd83ded36e9f2a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.3.0
2
+
3
+ * Added ES6ModuleTranspiler.transform for custom transforming of the
4
+ name
5
+
1
6
  ## 0.2.0
2
7
 
3
8
  * Accept multiple prefix pattern matching
data/Gemfile CHANGED
@@ -2,3 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in es6_module_transpiler-rails.gemspec
4
4
  gemspec
5
+
6
+ gem 'byebug'
7
+ gem 'm'
@@ -24,4 +24,12 @@ module ES6ModuleTranspiler
24
24
 
25
25
  prefix
26
26
  end
27
+
28
+ def self.transform=(transform)
29
+ @transform = transform
30
+ end
31
+
32
+ def self.transform
33
+ @transform
34
+ end
27
35
  end
@@ -1,5 +1,5 @@
1
1
  module ES6ModuleTranspiler
2
2
  module Rails
3
- VERSION = '0.2.0'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
@@ -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
@@ -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
@@ -1,4 +1,5 @@
1
1
  require 'bundler/setup'
2
+ require 'byebug'
2
3
  require 'es6_module_transpiler/rails'
3
4
 
4
5
  if defined?(M)
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.2.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-29 00:00:00.000000000 Z
11
+ date: 2013-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: execjs