ember-es6_template 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5792670be73f6489e4dd4a650b8b05e6dd07076
4
- data.tar.gz: 7b9f5e97d3f999e5432d5a83efeadb279a7074cb
3
+ metadata.gz: 41ce7edad979b252d083ced5a0248a14d1fba7f8
4
+ data.tar.gz: 3f45a8f0664aa940f48392352c294c329b7f3691
5
5
  SHA512:
6
- metadata.gz: 71b4134d59cad3ca89d3685f6d2e50c5eb42ba526eb10ddced26d8368239653a25b3ad78a4bc22f969625e76c3e1ef53841f1ff179e617d91331d5b04dd526bd
7
- data.tar.gz: 0153120552fbee7754bb683bc7d3d8799a975dba90b4a239faa26ee01c55b7368bed57c4fa7a1a8c491f66a0329ac7c0c248f0b268efedb4996a459ff5936e2d
6
+ metadata.gz: 98cc626eb44ebbf60c93f08435d33decdd14b4a22814315366cb45848a3b512631821f696e00890acd3473c0b02df1c8cf0a1e9ddf73e46e8a358392df90edd7
7
+ data.tar.gz: df93807593a14cb40de67f36dd89a013b4c1adfc870edb1a864aa4eedb429cde12b9351acf7389d749243f012045bdf8726c62695bbe3c8583dd2c0001dcfe45
@@ -13,5 +13,15 @@ module Ember
13
13
  else
14
14
  raise "Unsupported sprockets version: #{Sprockets::VERSION}"
15
15
  end
16
+
17
+ autoload :Config, 'ember/es6_template/config'
18
+
19
+ def self.configure
20
+ yield config if block_given?
21
+ end
22
+
23
+ def self.config
24
+ @config ||= Config.new
25
+ end
16
26
  end
17
27
  end
@@ -0,0 +1,13 @@
1
+ module Ember
2
+ module ES6Template
3
+ class Config
4
+ attr_accessor :module_prefix
5
+
6
+ def to_hash
7
+ {
8
+ module_prefix: module_prefix
9
+ }
10
+ end
11
+ end
12
+ end
13
+ end
@@ -18,7 +18,7 @@ module Ember
18
18
  'filename' => scope.logical_path
19
19
  )
20
20
 
21
- return result['code']
21
+ result['code']
22
22
  end
23
23
 
24
24
  private
@@ -15,11 +15,17 @@ module Ember
15
15
  'moduleIds' => true,
16
16
  'sourceRoot' => env.root,
17
17
  'moduleRoot' => '',
18
- 'filename' => scope.logical_path
18
+ 'filename' => module_name(scope.logical_path)
19
19
  )
20
20
 
21
21
  result['code']
22
22
  end
23
+
24
+ private
25
+
26
+ def module_name(path)
27
+ [Ember::ES6Template.config.module_prefix, path].compact.join('/')
28
+ end
23
29
  end
24
30
  end
25
31
  end
@@ -2,13 +2,17 @@ module Ember
2
2
  module ES6Template
3
3
  class ES6Module
4
4
  def self.instance
5
- @instance ||= new
5
+ @instance ||= new(Ember::ES6Template.config)
6
6
  end
7
7
 
8
8
  def self.call(input)
9
9
  instance.call(input)
10
10
  end
11
11
 
12
+ def initialize(config = Config.new)
13
+ @config = config
14
+ end
15
+
12
16
  def call(input)
13
17
  data = input[:data]
14
18
 
@@ -28,21 +32,12 @@ module Ember
28
32
  private
29
33
 
30
34
  def transform(data, input)
31
- actual_name = input[:name]
32
- if input[:filename][File.expand_path(input[:name] + '/index', input[:load_path])]
33
- if actual_name == '.'
34
- actual_name = 'index'
35
- else
36
- actual_name += '/index'
37
- end
38
- end
39
-
40
35
  Babel::Transpiler.transform(data,
41
36
  'modules' => 'amd',
42
37
  'moduleIds' => true,
43
38
  'sourceRoot' => input[:load_path],
44
39
  'moduleRoot' => '',
45
- 'filename' => actual_name(input)
40
+ 'filename' => module_name(input)
46
41
  )
47
42
  end
48
43
 
@@ -51,22 +46,23 @@ module Ember
51
46
  self.class.name,
52
47
  VERSION,
53
48
  Babel::Transpiler.version,
54
- Babel::Transpiler.source_version
49
+ Babel::Transpiler.source_version,
50
+ @config.to_hash
55
51
  ]
56
52
  end
57
53
 
58
- def actual_name(input)
59
- actual_name = input[:name]
54
+ def module_name(input)
55
+ module_name = input[:name]
60
56
 
61
57
  if input[:filename][File.expand_path(input[:name] + '/index', input[:load_path])]
62
- if actual_name == '.'
63
- actual_name = 'index'
58
+ if module_name == '.'
59
+ module_name = 'index'
64
60
  else
65
- actual_name += '/index'
61
+ module_name += '/index'
66
62
  end
67
63
  end
68
64
 
69
- actual_name
65
+ [@config.module_prefix, module_name].compact.join('/')
70
66
  end
71
67
  end
72
68
  end
@@ -1,5 +1,5 @@
1
1
  module Ember
2
2
  module ES6Template
3
- VERSION = '0.2.4'
3
+ VERSION = '0.2.5'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ember-es6_template
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryunosuke SATO
@@ -137,6 +137,7 @@ files:
137
137
  - bin/setup
138
138
  - ember-es6_template.gemspec
139
139
  - lib/ember/es6_template.rb
140
+ - lib/ember/es6_template/config.rb
140
141
  - lib/ember/es6_template/sprockets2.rb
141
142
  - lib/ember/es6_template/sprockets2/coffee_script.rb
142
143
  - lib/ember/es6_template/sprockets2/es6.rb