es6_module_transpiler-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,22 @@
1
+ (function(program, execJS) { execJS(program) })(function(module, exports, console) {
2
+ #{source}
3
+ }, function(program) {
4
+ var output, print = function(string) {
5
+ process.stdout.write('' + string);
6
+ };
7
+ try {
8
+ result = program();
9
+ if (typeof result == 'undefined' && result !== null) {
10
+ print('["ok"]');
11
+ } else {
12
+ try {
13
+ print(JSON.stringify(['ok', result]));
14
+ } catch (err) {
15
+ print('["err"]');
16
+ }
17
+ }
18
+ } catch (err) {
19
+ print(JSON.stringify(['err', '' + err]));
20
+ }
21
+ });
22
+
@@ -0,0 +1,4 @@
1
+ require 'tilt'
2
+ require 'es6_module_transpiler/tilt/es6_module_transpiler_template'
3
+
4
+ Tilt.register Tilt::ES6ModuleTranspilerTemplate, 'es6'
@@ -0,0 +1,34 @@
1
+ module Tilt
2
+ class ES6ModuleTranspilerTemplate < Tilt::Template
3
+ self.default_mime_type = 'application/javascript'
4
+ attr_reader :node
5
+
6
+ def prepare
7
+ @node = ::ExecJS::ExternalRuntime.new(
8
+ name: 'Node.js (V8)',
9
+ command: ['nodejs', 'node'],
10
+ runner_path: File.expand_path('../../support/es6_node_runner.js', __FILE__),
11
+ encoding: 'UTF-8'
12
+ )
13
+ end
14
+
15
+ def evaluate(scope, locals, &block)
16
+ @output ||= @node.exec(generate_source(scope))
17
+ end
18
+
19
+ private
20
+
21
+ def transpiler_path
22
+ File.expand_path('../../support/es6-module-transpiler.js', __FILE__)
23
+ end
24
+
25
+ def generate_source(scope)
26
+ source = <<-SOURCE
27
+ var Compiler, compiler, output;
28
+ Compiler = require("#{transpiler_path}").Compiler;
29
+ compiler = new Compiler(#{::JSON.generate(data, quirks_mode: true)}, '#{scope.logical_path}');
30
+ return output = compiler.toAMD();
31
+ SOURCE
32
+ end
33
+ end
34
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: es6_module_transpiler-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Brian Cardarella
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: execjs
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.4'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Compile ES6 module in the asset pipeline
56
+ email:
57
+ - bcardarella@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - es6_module_transpiler-rails.gemspec
68
+ - lib/es6_module_transpiler/rails.rb
69
+ - lib/es6_module_transpiler/rails/version.rb
70
+ - lib/es6_module_transpiler/sprockets.rb
71
+ - lib/es6_module_transpiler/support/es6-module-transpiler.js
72
+ - lib/es6_module_transpiler/support/es6_node_runner.js
73
+ - lib/es6_module_transpiler/tilt.rb
74
+ - lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb
75
+ homepage: https://github.com/dockyard/es6_module_transpiler-rails
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.1.5
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: ES6 Module Transpiler for Rails
99
+ test_files: []