traceur-rails 0.0.1 → 0.0.2
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 +4 -4
- data/README.md +12 -2
- data/lib/traceur/config.rb +1 -9
- data/lib/traceur/template.rb +5 -12
- data/lib/traceur/version.rb +1 -1
- data/test/fixtures/compiled_register.js +12 -0
- data/test/fixtures/source.tc +7 -0
- data/test/template_test.rb +6 -30
- data/test/test_helper.rb +4 -0
- data/traceur-rails.gemspec +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 701692d3fe09e5b07d6e0d4031d620f3050793d6
|
4
|
+
data.tar.gz: 6cab1f31fcc1ec293ad12a6c8d21314c0285a7d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74248dfa71342627f69aad2cc3a5257e9917fa2c400cb4bba93086ff1ca8bdea2383c89e0d3513bb8f8f387b08a2a8c6e9da96ee50229c56c56d874e65ab4db1
|
7
|
+
data.tar.gz: 77ddf64a3d835c0afee7c6388bcda9e6d2cb85c7535e26224f859e4b03b055426183fa4efc45adaeaa5c9f58c52731a12b9d0f0e802a0939dc3484d194a09088
|
data/README.md
CHANGED
@@ -4,13 +4,23 @@
|
|
4
4
|
gem install traceur-rails
|
5
5
|
```
|
6
6
|
|
7
|
+
[Here on rubygems.org](https://rubygems.org/gems/traceur-rails)
|
8
|
+
|
7
9
|
## Requirements
|
8
10
|
|
9
|
-
Requires `node` to be installed.
|
11
|
+
Requires [`node`](http://nodejs.org) to be installed.
|
10
12
|
|
11
13
|
## Usage
|
12
14
|
|
13
|
-
Despite being named `traceur-rails` this gem can be used with any project that uses `sprockets
|
15
|
+
Despite being named `traceur-rails` this gem can be used with any project that uses [`sprockets`](https://github.com/sstephenson/sprockets). Use `.tc` as the extension for any file that would normally use a `.js` extension and the file will be compiled with `traceur`.
|
16
|
+
|
17
|
+
## traceur modules
|
18
|
+
|
19
|
+
Tracuer offers a `modules` configuration option. Generally this will be set in an initializer. This allows you to specify how modules should be compiled. The options are available in the [traceur-compiler wiki](https://github.com/google/traceur-compiler/wiki/Options-for-Compiling)
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
Traceur::Config.compile_to :amd
|
23
|
+
```
|
14
24
|
|
15
25
|
## Author
|
16
26
|
|
data/lib/traceur/config.rb
CHANGED
@@ -2,7 +2,7 @@ module Traceur
|
|
2
2
|
module Config
|
3
3
|
class << self
|
4
4
|
def compile_to
|
5
|
-
@compile_to || :
|
5
|
+
@compile_to || :register
|
6
6
|
end
|
7
7
|
|
8
8
|
def compile_to=(target)
|
@@ -22,14 +22,6 @@ module Traceur
|
|
22
22
|
prefix
|
23
23
|
end
|
24
24
|
|
25
|
-
def transform=(transform)
|
26
|
-
@transform = transform
|
27
|
-
end
|
28
|
-
|
29
|
-
def transform
|
30
|
-
@transform
|
31
|
-
end
|
32
|
-
|
33
25
|
def compiler_options
|
34
26
|
@compiler_options ||= {}
|
35
27
|
end
|
data/lib/traceur/template.rb
CHANGED
@@ -28,11 +28,11 @@ module Traceur
|
|
28
28
|
var traceur = require("#{traceur_path}");
|
29
29
|
var result = traceur.compile(#{::JSON.generate(data, quirks_mode: true)}, {
|
30
30
|
filename: '#{module_name(scope.root_path, scope.logical_path)}',
|
31
|
-
modules:
|
31
|
+
modules: '#{Traceur::Config.compile_to}'
|
32
32
|
});
|
33
33
|
|
34
|
-
if (result.
|
35
|
-
throw result.
|
34
|
+
if (result.errors && result.errors.length) {
|
35
|
+
throw "\\n" + result.errors.join("\\n");
|
36
36
|
}
|
37
37
|
|
38
38
|
return result.js;
|
@@ -40,18 +40,11 @@ module Traceur
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def module_name(root_path, logical_path)
|
43
|
-
path = ''
|
44
43
|
if prefix = Traceur::Config.lookup_prefix(File.join(root_path, logical_path))
|
45
|
-
|
44
|
+
File.join(prefix, logical_path)
|
46
45
|
else
|
47
|
-
|
46
|
+
logical_path
|
48
47
|
end
|
49
|
-
|
50
|
-
if Traceur::Config.transform
|
51
|
-
path = Traceur::Config.transform.call(path)
|
52
|
-
end
|
53
|
-
|
54
|
-
path
|
55
48
|
end
|
56
49
|
|
57
50
|
def traceur_path
|
data/lib/traceur/version.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
System.register("foo", [], function() {
|
2
|
+
"use strict";
|
3
|
+
var __moduleName = "foo";
|
4
|
+
var dep = $traceurRuntime.assertObject(System.get("dep")).default;
|
5
|
+
var foo = function() {
|
6
|
+
console.log('bar');
|
7
|
+
};
|
8
|
+
var $__default = foo;
|
9
|
+
return {get default() {
|
10
|
+
return $__default;
|
11
|
+
}};
|
12
|
+
});
|
data/test/template_test.rb
CHANGED
@@ -3,43 +3,19 @@ require 'traceur-rails'
|
|
3
3
|
require 'execjs'
|
4
4
|
|
5
5
|
describe Traceur::Template do
|
6
|
+
Scope = Struct.new('Scope', :root_path, :logical_path)
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
before do
|
10
|
-
@source = <<-JS
|
11
|
-
import dep from 'dep';
|
12
|
-
|
13
|
-
var foo = function() {
|
14
|
-
console.log('bar');
|
15
|
-
};
|
16
|
-
|
17
|
-
export default foo;
|
18
|
-
JS
|
8
|
+
before do
|
9
|
+
@source = fixture('source.tc')
|
19
10
|
@source.strip!
|
20
11
|
@scope = Scope.new('', 'foo')
|
21
12
|
end
|
22
13
|
|
23
|
-
|
24
|
-
expected =
|
25
|
-
System.register("foo", [], function() {
|
26
|
-
"use strict";
|
27
|
-
var __moduleName = "foo";
|
28
|
-
var dep = $traceurRuntime.assertObject(System.get("dep")).default;
|
29
|
-
var foo = function() {
|
30
|
-
console.log('bar');
|
31
|
-
};
|
32
|
-
var $__default = foo;
|
33
|
-
return {get default() {
|
34
|
-
return $__default;
|
35
|
-
}};
|
36
|
-
});
|
37
|
-
JS
|
14
|
+
it 'transpiles tc files' do
|
15
|
+
expected = fixture('compiled_register.js')
|
38
16
|
expected.lstrip!
|
39
17
|
|
40
18
|
template = Traceur::Template.new { @source }
|
41
|
-
template.render(@scope).must_equal
|
19
|
+
template.render(@scope).must_equal(expected)
|
42
20
|
end
|
43
|
-
|
44
|
-
|
45
21
|
end
|
data/test/test_helper.rb
CHANGED
data/traceur-rails.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ['Aaron Ackerman']
|
10
10
|
spec.email = ['theron17@gmail.com']
|
11
11
|
spec.summary = %q{Traceur Compiler integration with Sprockets}
|
12
|
-
spec.description = %q{
|
12
|
+
spec.description = %q{Traceur Compiler supported Javascript with Sprockets}
|
13
13
|
spec.homepage = ''
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: traceur-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Ackerman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: execjs
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - ">"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 2.0.0
|
83
|
-
description:
|
83
|
+
description: Traceur Compiler supported Javascript with Sprockets
|
84
84
|
email:
|
85
85
|
- theron17@gmail.com
|
86
86
|
executables: []
|
@@ -119,6 +119,8 @@ files:
|
|
119
119
|
- lib/traceur/template.rb
|
120
120
|
- lib/traceur/tilt.rb
|
121
121
|
- lib/traceur/version.rb
|
122
|
+
- test/fixtures/compiled_register.js
|
123
|
+
- test/fixtures/source.tc
|
122
124
|
- test/template_test.rb
|
123
125
|
- test/test_helper.rb
|
124
126
|
- traceur-rails.gemspec
|
@@ -147,5 +149,7 @@ signing_key:
|
|
147
149
|
specification_version: 4
|
148
150
|
summary: Traceur Compiler integration with Sprockets
|
149
151
|
test_files:
|
152
|
+
- test/fixtures/compiled_register.js
|
153
|
+
- test/fixtures/source.tc
|
150
154
|
- test/template_test.rb
|
151
155
|
- test/test_helper.rb
|