ember-es6_template 0.0.1 → 0.0.2

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: 941ac43d85ff8fb8561cb500ed6c6bf62592eb6a
4
- data.tar.gz: e52a1e15df88ab795553cae0d0adad690c66ae9e
3
+ metadata.gz: 86db4eb2a5854bd44a33b7278a96f93840fc856d
4
+ data.tar.gz: 60c0f71270a55e39c4385e339db91aa4651e4b1d
5
5
  SHA512:
6
- metadata.gz: 95c2a66a365871aaac59b61e8cb8358bc6f1e6d2e4e71974d48a6e3fab3b98d7b6613714e235712cb4611d4f28a7bd471895b2fd39caf57cefd324931e82786a
7
- data.tar.gz: 7ebf88dcf1909fd9193d95257bde462211472d6aa8ee0b16cf6f1203bba2a0f717a8ea74d870dd2982e39744a5e20a71f8b0fc940f538d23f6bc995a2f8f187a
6
+ metadata.gz: 2d35450b30b74463f271687cd17f7e6f7d17002b4ef8345fa3b4e56f528d31838fc244ee896e62b3df10e38a8d18db6993a0c07243231977e32c836004e02575
7
+ data.tar.gz: b591ea35778aa767208a0022cec84b716c2ce05c30129251f6e2892182625c3c4058c62cba824041540138f2cd7c99b3e30c28b95da55879cbb70e5ac5265657
data/.travis.yml CHANGED
@@ -6,3 +6,8 @@ rvm:
6
6
  - 2.0.0
7
7
  - 2.1
8
8
  - 2.2
9
+
10
+ env:
11
+ matrix:
12
+ - SPROCKETS_VERSION="~> 2.12.0"
13
+ - SPROCKETS_VERSION="~> 3.0.0.beta.10"
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ gem 'sprockets', ENV['SPROCKETS_VERSION'] if ENV['SPROCKETS_VERSION']
@@ -19,11 +19,10 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency 'babel-transpiler', '~> 0.6.0'
22
- spec.add_dependency 'tilt', '~> 1.0'
22
+ spec.add_dependency 'sprockets'
23
23
 
24
- spec.add_development_dependency 'bundler', '~> 1.8'
24
+ spec.add_development_dependency 'bundler', '~> 1.7'
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 'sprockets', '~> 2.12'
29
28
  end
@@ -1,23 +1,38 @@
1
1
  module Ember
2
2
  module ES6Template
3
- class ES6 < ::Tilt::Template
4
- def self.default_mime_type
5
- 'application/javascript'
3
+ class ES6
4
+ def self.instance
5
+ @instance ||= new
6
6
  end
7
7
 
8
- def prepare; end
8
+ def self.call(input)
9
+ instance.call(input)
10
+ end
9
11
 
10
- def evaluate(scope, locals, &block)
11
- env = scope.environment
12
+ def call(input)
13
+ data = input[:data]
12
14
 
13
- result = Babel::Transpiler.transform(data,
14
- 'sourceRoot' => env.root,
15
- 'moduleRoot' => '',
16
- 'filename' => scope.logical_path
17
- )
15
+ result = input[:cache].fetch(cache_key + [data]) do
16
+ Babel::Transpiler.transform(data,
17
+ 'sourceRoot' => input[:load_path],
18
+ 'moduleRoot' => '',
19
+ 'filename' => input[:filename]
20
+ )
21
+ end
18
22
 
19
23
  result['code']
20
24
  end
25
+
26
+ private
27
+
28
+ def cache_key
29
+ [
30
+ self.class.name,
31
+ VERSION,
32
+ Babel::Transpiler.version,
33
+ Babel::Transpiler.source_version
34
+ ]
35
+ end
21
36
  end
22
37
  end
23
38
  end
@@ -0,0 +1,23 @@
1
+ module Ember
2
+ module ES6Template
3
+ class ES6 < ::Tilt::Template
4
+ def self.default_mime_type
5
+ 'application/javascript'
6
+ end
7
+
8
+ def prepare; end
9
+
10
+ def evaluate(scope, locals, &block)
11
+ env = scope.environment
12
+
13
+ result = Babel::Transpiler.transform(data,
14
+ 'sourceRoot' => env.root,
15
+ 'moduleRoot' => '',
16
+ 'filename' => scope.logical_path
17
+ )
18
+
19
+ result['code']
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,25 +1,40 @@
1
1
  module Ember
2
2
  module ES6Template
3
- class ES6Module < ::Tilt::Template
4
- def self.default_mime_type
5
- 'application/javascript'
3
+ class ES6Module
4
+ def self.instance
5
+ @instance ||= new
6
6
  end
7
7
 
8
- def prepare; end
8
+ def self.call(input)
9
+ instance.call(input)
10
+ end
9
11
 
10
- def evaluate(scope, locals, &block)
11
- env = scope.environment
12
+ def call(input)
13
+ data = input[:data]
12
14
 
13
- result = Babel::Transpiler.transform(data,
14
- 'modules' => 'amd',
15
- 'moduleIds' => true,
16
- 'sourceRoot' => env.root,
17
- 'moduleRoot' => '',
18
- 'filename' => scope.logical_path
19
- )
15
+ result = input[:cache].fetch(cache_key + [data]) do
16
+ Babel::Transpiler.transform(data,
17
+ 'modules' => 'amd',
18
+ 'moduleIds' => true,
19
+ 'sourceRoot' => input[:load_path],
20
+ 'moduleRoot' => '',
21
+ 'filename' => input[:filename]
22
+ )
23
+ end
20
24
 
21
25
  result['code']
22
26
  end
27
+
28
+ private
29
+
30
+ def cache_key
31
+ [
32
+ self.class.name,
33
+ VERSION,
34
+ Babel::Transpiler.version,
35
+ Babel::Transpiler.source_version
36
+ ]
37
+ end
23
38
  end
24
39
  end
25
40
  end
@@ -0,0 +1,25 @@
1
+ module Ember
2
+ module ES6Template
3
+ class ES6Module < ::Tilt::Template
4
+ def self.default_mime_type
5
+ 'application/javascript'
6
+ end
7
+
8
+ def prepare; end
9
+
10
+ def evaluate(scope, locals, &block)
11
+ env = scope.environment
12
+
13
+ result = Babel::Transpiler.transform(data,
14
+ 'modules' => 'amd',
15
+ 'moduleIds' => true,
16
+ 'sourceRoot' => env.root,
17
+ 'moduleRoot' => '',
18
+ 'filename' => scope.logical_path
19
+ )
20
+
21
+ result['code']
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,5 @@
1
1
  module Ember
2
2
  module ES6Template
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  end
@@ -1,11 +1,19 @@
1
1
  require 'ember/es6_template/version'
2
2
 
3
- require 'tilt'
3
+ require 'sprockets'
4
4
  require 'babel/transpiler'
5
5
 
6
6
  module Ember
7
7
  module ES6Template
8
- autoload :ES6, 'ember/es6_template/es6'
9
- autoload :ES6Module, 'ember/es6_template/es6module'
8
+ case Sprockets::VERSION
9
+ when /^2\./
10
+ autoload :ES6, 'ember/es6_template/es6_sprockets2'
11
+ autoload :ES6Module, 'ember/es6_template/es6module_sprockets2'
12
+ when /^3\./
13
+ autoload :ES6, 'ember/es6_template/es6'
14
+ autoload :ES6Module, 'ember/es6_template/es6module'
15
+ else
16
+ raise "Unsupported sprockets version: #{Sprockets::VERSION}"
17
+ end
10
18
  end
11
19
  end
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.0.1
4
+ version: 0.0.2
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-03-10 00:00:00.000000000 Z
11
+ date: 2015-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: babel-transpiler
@@ -25,33 +25,33 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.6.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: tilt
28
+ name: sprockets
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.8'
47
+ version: '1.7'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.8'
54
+ version: '1.7'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -94,20 +94,6 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: sprockets
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '2.12'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '2.12'
111
97
  description: The tilt template for Ember specified ES6.
112
98
  email:
113
99
  - tricknotes.rs@gmail.com
@@ -126,7 +112,9 @@ files:
126
112
  - ember-es6_template.gemspec
127
113
  - lib/ember/es6_template.rb
128
114
  - lib/ember/es6_template/es6.rb
115
+ - lib/ember/es6_template/es6_sprockets2.rb
129
116
  - lib/ember/es6_template/es6module.rb
117
+ - lib/ember/es6_template/es6module_sprockets2.rb
130
118
  - lib/ember/es6_template/version.rb
131
119
  homepage: https://github.com/tricknotes/ember-es6_template
132
120
  licenses: