embork 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +5 -0
- data/TODO.md +16 -0
- data/bin/embork +63 -0
- data/blueprint/Borkfile +42 -0
- data/blueprint/Gemfile +13 -0
- data/blueprint/README.md +25 -0
- data/blueprint/app/app.js +11 -0
- data/blueprint/app/components/.gitkeep +0 -0
- data/blueprint/app/controllers/.gitkeep +0 -0
- data/blueprint/app/helpers/.gitkeep +0 -0
- data/blueprint/app/index.html.erb +18 -0
- data/blueprint/app/initializers/.gitkeep +0 -0
- data/blueprint/app/mixins/.gitkeep +0 -0
- data/blueprint/app/models/.gitkeep +0 -0
- data/blueprint/app/router.js +8 -0
- data/blueprint/app/routes/.gitkeep +0 -0
- data/blueprint/app/routes/index.js +1 -0
- data/blueprint/app/styles/.gitkeep +0 -0
- data/blueprint/app/styles/app.scss +3 -0
- data/blueprint/app/templates/.gitkeep +0 -0
- data/blueprint/app/templates/application.hbs +3 -0
- data/blueprint/app/templates/components/.gitkeep +0 -0
- data/blueprint/app/utils/.gitkeep +0 -0
- data/blueprint/app/views/.gitkeep +0 -0
- data/blueprint/bower.json +16 -0
- data/blueprint/bowerrc +3 -0
- data/blueprint/config/development/application.css +0 -0
- data/blueprint/config/development/application.js +12 -0
- data/blueprint/config/production/application.css +0 -0
- data/blueprint/config/production/application.js +12 -0
- data/blueprint/dotfiles +3 -0
- data/blueprint/erbfiles +5 -0
- data/blueprint/gitignore +17 -0
- data/blueprint/jshintrc +40 -0
- data/blueprint/package.json +15 -0
- data/blueprint/static/.gitkeep +0 -0
- data/blueprint/tests/.jshintrc +71 -0
- data/blueprint/tests/helpers/resolver.js +7 -0
- data/blueprint/tests/helpers/start-app.js +29 -0
- data/blueprint/tests/index.html +44 -0
- data/blueprint/tests/test-helper.js +6 -0
- data/blueprint/tests/test-loader.js +8 -0
- data/blueprint/tests/unit/.gitkeep +0 -0
- data/embork.gemspec +41 -0
- data/lib/embork.rb +23 -0
- data/lib/embork/borkfile.rb +148 -0
- data/lib/embork/build_versions.rb +21 -0
- data/lib/embork/builder.rb +156 -0
- data/lib/embork/environment.rb +90 -0
- data/lib/embork/forwarder.rb +23 -0
- data/lib/embork/generator.rb +184 -0
- data/lib/embork/logger.rb +40 -0
- data/lib/embork/pushstate.rb +16 -0
- data/lib/embork/server.rb +80 -0
- data/lib/embork/sprockets.rb +6 -0
- data/lib/embork/sprockets/ember_handlebars_compiler.rb +75 -0
- data/lib/embork/sprockets/es6_module_transpiler.rb +120 -0
- data/lib/embork/sprockets/frameworks.rb +34 -0
- data/lib/embork/sprockets/helpers.rb +45 -0
- data/lib/embork/sprockets/support/es6-module-transpiler.js +7190 -0
- data/lib/embork/sprockets/support/node_runner.js +22 -0
- data/lib/embork/version.rb +3 -0
- data/lib/string/strip.rb +27 -0
- data/spec/embork/borkfile/Borkfile.empty +0 -0
- data/spec/embork/borkfile/Borkfile.full +32 -0
- data/spec/embork/borkfile/Borkfile.rack +5 -0
- data/spec/embork/borkfile/Borkfile.relative +3 -0
- data/spec/embork/borkfile_spec.rb +119 -0
- data/spec/embork/builder/Borkfile +20 -0
- data/spec/embork/builder/app/index.html.erb +9 -0
- data/spec/embork/builder/config/production/application.css +0 -0
- data/spec/embork/builder/config/production/application.js +0 -0
- data/spec/embork/builder/config/production/deeply/nested/asset.js +0 -0
- data/spec/embork/builder/static/images/image.png +0 -0
- data/spec/embork/builder_spec.rb +95 -0
- data/spec/embork/environment_spec.rb +78 -0
- data/spec/embork/generator_spec.rb +84 -0
- data/spec/embork/server/example_app/Borkfile +1 -0
- data/spec/embork/server/example_app/app/app.js.erb +3 -0
- data/spec/embork/server/example_app/app/css/main.sass +3 -0
- data/spec/embork/server/example_app/app/index.html +9 -0
- data/spec/embork/server/example_app/build/development/application-12345.js +14 -0
- data/spec/embork/server/example_app/build/development/index.html +9 -0
- data/spec/embork/server/example_app/components/some/component.js +6 -0
- data/spec/embork/server/example_app/config/development/application.css +4 -0
- data/spec/embork/server/example_app/config/development/application.js +2 -0
- data/spec/embork/server/example_app/config/production/application.css +4 -0
- data/spec/embork/server/example_app/config/production/application.js +4 -0
- data/spec/embork/server/example_app/static/fonts/.gitkeep +0 -0
- data/spec/embork/server/example_app/static/images/.gitkeep +0 -0
- data/spec/embork/server/example_app/static/images/image.png +0 -0
- data/spec/embork/server/specimen.css +7 -0
- data/spec/embork/server/specimen.js +14 -0
- data/spec/embork/server_spec.rb +152 -0
- data/spec/embork/sprockets/ember_handlebars_compiler/amd_template.js +26 -0
- data/spec/embork/sprockets/ember_handlebars_compiler/cjs_template.js +24 -0
- data/spec/embork/sprockets/ember_handlebars_compiler/global_handlebars_template.js +17 -0
- data/spec/embork/sprockets/ember_handlebars_compiler/global_hbs_template.js +17 -0
- data/spec/embork/sprockets/ember_handlebars_compiler/my/hbs/template.hbs +5 -0
- data/spec/embork/sprockets/ember_handlebars_compiler/my_handlebars_template.js.handlebars +5 -0
- data/spec/embork/sprockets/ember_handlebars_compiler/my_hbs_template.js.hbs +5 -0
- data/spec/embork/sprockets/ember_handlebars_compiler/transformed_template.js +26 -0
- data/spec/embork/sprockets/ember_handlebars_compiler_spec.rb +82 -0
- data/spec/embork/sprockets/es6_module_transpiler/app/my/transformed/module.js +13 -0
- data/spec/embork/sprockets/es6_module_transpiler/app/my_fancy_module.js +13 -0
- data/spec/embork/sprockets/es6_module_transpiler/compiled_amd.js +20 -0
- data/spec/embork/sprockets/es6_module_transpiler/compiled_cjs.js +20 -0
- data/spec/embork/sprockets/es6_module_transpiler/component.js +1 -0
- data/spec/embork/sprockets/es6_module_transpiler/components/some_component.js +1 -0
- data/spec/embork/sprockets/es6_module_transpiler/config/application.js +1 -0
- data/spec/embork/sprockets/es6_module_transpiler/manifest.js +20 -0
- data/spec/embork/sprockets/es6_module_transpiler/namespaced.js +20 -0
- data/spec/embork/sprockets/es6_module_transpiler/transformed.js +20 -0
- data/spec/embork/sprockets/es6_module_transpiler_spec.rb +97 -0
- data/spec/spec_helper.rb +13 -0
- metadata +468 -0
@@ -0,0 +1 @@
|
|
1
|
+
# vim: set ft=ruby:
|
@@ -0,0 +1,14 @@
|
|
1
|
+
define("some/component",
|
2
|
+
["exports"],
|
3
|
+
function(__exports__) {
|
4
|
+
"use strict";
|
5
|
+
__exports__["default"] = function SomeComponentFunction(){ alert('Woohoo'); };
|
6
|
+
});
|
7
|
+
define("app",
|
8
|
+
["my-app/some_component","exports"],
|
9
|
+
function(__dependency1__, __exports__) {
|
10
|
+
"use strict";
|
11
|
+
var SomeComponent = __dependency1__["default"];
|
12
|
+
|
13
|
+
__exports__["default"] = Ember.Application.create("development");
|
14
|
+
});
|
File without changes
|
File without changes
|
Binary file
|
@@ -0,0 +1,14 @@
|
|
1
|
+
define("some/component",
|
2
|
+
["exports"],
|
3
|
+
function(__exports__) {
|
4
|
+
"use strict";
|
5
|
+
__exports__["default"] = function SomeComponentFunction(){ alert('Woohoo'); };
|
6
|
+
});
|
7
|
+
define("app",
|
8
|
+
["my-app/some_component","exports"],
|
9
|
+
function(__dependency1__, __exports__) {
|
10
|
+
"use strict";
|
11
|
+
var SomeComponent = __dependency1__["default"];
|
12
|
+
|
13
|
+
__exports__["default"] = Ember.Application.create("development");
|
14
|
+
});
|
@@ -0,0 +1,152 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'embork/server'
|
3
|
+
|
4
|
+
require 'base64'
|
5
|
+
|
6
|
+
project_root = File.expand_path '../server/example_app', __FILE__
|
7
|
+
borkfile_path = File.expand_path 'Borkfile', project_root
|
8
|
+
index_specimen = File.read File.expand_path('app/index.html', project_root)
|
9
|
+
|
10
|
+
image_path = File.expand_path 'static/images/image.png', project_root
|
11
|
+
image_data = IO.binread(image_path)
|
12
|
+
|
13
|
+
class MyRackBackend
|
14
|
+
attr_reader :app
|
15
|
+
def initialize(app = nil, options = {})
|
16
|
+
@app = app
|
17
|
+
end
|
18
|
+
|
19
|
+
def call(env)
|
20
|
+
body = %{You visited '%s'.} % [ env['PATH_INFO'] ]
|
21
|
+
status = 200
|
22
|
+
headers = Hash.new
|
23
|
+
[ status, headers, body ]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
js_specimen = nil
|
28
|
+
File.open(File.expand_path('../server/specimen.js', __FILE__), 'r:UTF-8') { |f| js_specimen = f.read.strip }
|
29
|
+
|
30
|
+
css_specimen = nil
|
31
|
+
File.open(File.expand_path('../server/specimen.css', __FILE__), 'r:UTF-8') { |f| css_specimen = f.read.strip }
|
32
|
+
|
33
|
+
describe 'Embork::Server' do
|
34
|
+
|
35
|
+
before(:each) { FileUtils.rm_rf File.join(project_root, '.cache') }
|
36
|
+
let(:borkfile) { Embork::Borkfile.new borkfile_path }
|
37
|
+
|
38
|
+
context 'pushState backed' do
|
39
|
+
|
40
|
+
let(:server) { Embork::Server.new borkfile }
|
41
|
+
let(:app) { server.app }
|
42
|
+
|
43
|
+
it 'serves out compiled js' do
|
44
|
+
get '/application.js'
|
45
|
+
expect(last_response).to be_ok
|
46
|
+
expect(last_response.body.strip).to eq(js_specimen)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'serves out compiled css' do
|
50
|
+
get '/application.css'
|
51
|
+
expect(last_response).to be_ok
|
52
|
+
expect(last_response.body.strip).to eq(css_specimen)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'serves out static files' do
|
56
|
+
get '/images/image.png'
|
57
|
+
expect(last_response).to be_ok
|
58
|
+
expect(last_response.body).to eq(image_data)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'responds with index.html at the root path' do
|
62
|
+
get '/'
|
63
|
+
expect(last_response).to be_ok
|
64
|
+
expect(last_response.body).to eq(index_specimen)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'responds with index.html for arbitrary paths' do
|
68
|
+
get '/foo/bar'
|
69
|
+
expect(last_response).to be_ok
|
70
|
+
expect(last_response.body).to eq(index_specimen)
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'rack backed' do
|
76
|
+
let(:rack_backed_borkfile) { b = borkfile.dup; b.instance_eval { @backend = MyRackBackend }; b }
|
77
|
+
let(:server) { Embork::Server.new rack_backed_borkfile }
|
78
|
+
let(:app) { server.app }
|
79
|
+
|
80
|
+
it 'serves out the index using the rack app' do
|
81
|
+
get '/'
|
82
|
+
expect(last_response).to be_ok
|
83
|
+
expect(last_response.body).to eq(%{You visited '/'.})
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'serves out arbitrary paths using rack' do
|
87
|
+
get '/foo/bar'
|
88
|
+
expect(last_response).to be_ok
|
89
|
+
expect(last_response.body).to eq(%{You visited '/foo/bar'.})
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'continues to serve out sprockets assets' do
|
93
|
+
get '/application.css'
|
94
|
+
expect(last_response).to be_ok
|
95
|
+
expect(last_response.body.strip).to eq(css_specimen)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context 'bundled assets' do
|
100
|
+
let(:server) { Embork::Server.new borkfile, :bundle_version => '12345' }
|
101
|
+
let(:app) { server.app }
|
102
|
+
|
103
|
+
it 'serves out bundled assets' do
|
104
|
+
get '/application-12345.js'
|
105
|
+
expect(last_response).to be_ok
|
106
|
+
expect(last_response.body.strip).to eq(js_specimen)
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'serves out the index' do
|
110
|
+
get '/index.html'
|
111
|
+
expect(last_response).to be_ok
|
112
|
+
expect(last_response.body).to eq(index_specimen)
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'serves out the index for the root path' do
|
116
|
+
get '/'
|
117
|
+
expect(last_response).to be_ok
|
118
|
+
expect(last_response.body).to eq(index_specimen)
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'servers out the index for arbitrary paths' do
|
122
|
+
get '/foo/bar'
|
123
|
+
expect(last_response).to be_ok
|
124
|
+
expect(last_response.body).to eq(index_specimen)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
context 'bundled assets and rack backend' do
|
129
|
+
let(:rack_backed_borkfile) { b = borkfile.dup; b.instance_eval { @backend = MyRackBackend }; b }
|
130
|
+
let(:server) { Embork::Server.new rack_backed_borkfile, :bundle_version => '12345' }
|
131
|
+
let(:app) { server.app }
|
132
|
+
|
133
|
+
it 'serves out bundled assets' do
|
134
|
+
get '/application-12345.js'
|
135
|
+
expect(last_response).to be_ok
|
136
|
+
expect(last_response.body.strip).to eq(js_specimen)
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'serves out the index using the rack app' do
|
140
|
+
get '/'
|
141
|
+
expect(last_response).to be_ok
|
142
|
+
expect(last_response.body).to eq(%{You visited '/'.})
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'serves out arbitrary paths using rack' do
|
146
|
+
get '/foo/bar'
|
147
|
+
expect(last_response).to be_ok
|
148
|
+
expect(last_response.body).to eq(%{You visited '/foo/bar'.})
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
define("my-package/my_hbs_template",
|
2
|
+
["exports"],
|
3
|
+
function(__exports__) {
|
4
|
+
|
5
|
+
"use strict";
|
6
|
+
var template = Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data) {
|
7
|
+
this.compilerInfo = [4,'>= 1.0.0'];
|
8
|
+
helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {};
|
9
|
+
var buffer = '', stack1, escapeExpression=this.escapeExpression;
|
10
|
+
|
11
|
+
|
12
|
+
data.buffer.push("<p>\n Hello ");
|
13
|
+
stack1 = helpers._triageMustache.call(depth0, "name", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data});
|
14
|
+
if(stack1 || stack1 === 0) { data.buffer.push(stack1); }
|
15
|
+
data.buffer.push(", here is a horrible picure:\n <br />\n <img ");
|
16
|
+
data.buffer.push(escapeExpression(helpers['bind-attr'].call(depth0, {hash:{
|
17
|
+
'src': ("horriblePictureUrl")
|
18
|
+
},hashTypes:{'src': "ID"},hashContexts:{'src': depth0},contexts:[],types:[],data:data})));
|
19
|
+
data.buffer.push(" />\n</p>\n");
|
20
|
+
return buffer;
|
21
|
+
|
22
|
+
});
|
23
|
+
|
24
|
+
__exports__["default"] = template;
|
25
|
+
|
26
|
+
});
|
@@ -0,0 +1,24 @@
|
|
1
|
+
window.require.define({"my-package/my_hbs_template": function(exports, require, module) {
|
2
|
+
|
3
|
+
"use strict";
|
4
|
+
var template = Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data) {
|
5
|
+
this.compilerInfo = [4,'>= 1.0.0'];
|
6
|
+
helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {};
|
7
|
+
var buffer = '', stack1, escapeExpression=this.escapeExpression;
|
8
|
+
|
9
|
+
|
10
|
+
data.buffer.push("<p>\n Hello ");
|
11
|
+
stack1 = helpers._triageMustache.call(depth0, "name", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data});
|
12
|
+
if(stack1 || stack1 === 0) { data.buffer.push(stack1); }
|
13
|
+
data.buffer.push(", here is a horrible picure:\n <br />\n <img ");
|
14
|
+
data.buffer.push(escapeExpression(helpers['bind-attr'].call(depth0, {hash:{
|
15
|
+
'src': ("horriblePictureUrl")
|
16
|
+
},hashTypes:{'src': "ID"},hashContexts:{'src': depth0},contexts:[],types:[],data:data})));
|
17
|
+
data.buffer.push(" />\n</p>\n");
|
18
|
+
return buffer;
|
19
|
+
|
20
|
+
});
|
21
|
+
|
22
|
+
exports["default"] = template;
|
23
|
+
|
24
|
+
}});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Ember.TEMPLATES['my-package/my_handlebars_template'] = Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data) {
|
2
|
+
this.compilerInfo = [4,'>= 1.0.0'];
|
3
|
+
helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {};
|
4
|
+
var buffer = '', stack1, escapeExpression=this.escapeExpression;
|
5
|
+
|
6
|
+
|
7
|
+
data.buffer.push("<p>\n Hello ");
|
8
|
+
stack1 = helpers._triageMustache.call(depth0, "name", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data});
|
9
|
+
if(stack1 || stack1 === 0) { data.buffer.push(stack1); }
|
10
|
+
data.buffer.push(", here is a horrible picure:\n <br />\n <img ");
|
11
|
+
data.buffer.push(escapeExpression(helpers['bind-attr'].call(depth0, {hash:{
|
12
|
+
'src': ("horriblePictureUrl")
|
13
|
+
},hashTypes:{'src': "ID"},hashContexts:{'src': depth0},contexts:[],types:[],data:data})));
|
14
|
+
data.buffer.push(" />\n</p>\n");
|
15
|
+
return buffer;
|
16
|
+
|
17
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Ember.TEMPLATES['my-package/my_hbs_template'] = Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data) {
|
2
|
+
this.compilerInfo = [4,'>= 1.0.0'];
|
3
|
+
helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {};
|
4
|
+
var buffer = '', stack1, escapeExpression=this.escapeExpression;
|
5
|
+
|
6
|
+
|
7
|
+
data.buffer.push("<p>\n Hello ");
|
8
|
+
stack1 = helpers._triageMustache.call(depth0, "name", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data});
|
9
|
+
if(stack1 || stack1 === 0) { data.buffer.push(stack1); }
|
10
|
+
data.buffer.push(", here is a horrible picure:\n <br />\n <img ");
|
11
|
+
data.buffer.push(escapeExpression(helpers['bind-attr'].call(depth0, {hash:{
|
12
|
+
'src': ("horriblePictureUrl")
|
13
|
+
},hashTypes:{'src': "ID"},hashContexts:{'src': depth0},contexts:[],types:[],data:data})));
|
14
|
+
data.buffer.push(" />\n</p>\n");
|
15
|
+
return buffer;
|
16
|
+
|
17
|
+
});
|
@@ -0,0 +1,26 @@
|
|
1
|
+
define("my-package/hbs_template",
|
2
|
+
["exports"],
|
3
|
+
function(__exports__) {
|
4
|
+
|
5
|
+
"use strict";
|
6
|
+
var template = Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data) {
|
7
|
+
this.compilerInfo = [4,'>= 1.0.0'];
|
8
|
+
helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {};
|
9
|
+
var buffer = '', stack1, escapeExpression=this.escapeExpression;
|
10
|
+
|
11
|
+
|
12
|
+
data.buffer.push("<p>\n Hello ");
|
13
|
+
stack1 = helpers._triageMustache.call(depth0, "name", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data});
|
14
|
+
if(stack1 || stack1 === 0) { data.buffer.push(stack1); }
|
15
|
+
data.buffer.push(", here is a horrible picure:\n <br />\n <img ");
|
16
|
+
data.buffer.push(escapeExpression(helpers['bind-attr'].call(depth0, {hash:{
|
17
|
+
'src': ("horriblePictureUrl")
|
18
|
+
},hashTypes:{'src': "ID"},hashContexts:{'src': depth0},contexts:[],types:[],data:data})));
|
19
|
+
data.buffer.push(" />\n</p>\n");
|
20
|
+
return buffer;
|
21
|
+
|
22
|
+
});
|
23
|
+
|
24
|
+
__exports__["default"] = template;
|
25
|
+
|
26
|
+
});
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'embork/sprockets/ember_handlebars_compiler'
|
4
|
+
|
5
|
+
require 'pry'
|
6
|
+
|
7
|
+
|
8
|
+
describe 'Embork::Sprockets::EmberHandlebarsCompiler' do
|
9
|
+
before(:all) { Embork::Sprockets::EmberHandlebarsCompiler.namespace = 'my-package' }
|
10
|
+
after(:all) { Embork::Sprockets::EmberHandlebarsCompiler.namespace = nil }
|
11
|
+
let(:root_path) { File.expand_path('../ember_handlebars_compiler', __FILE__) }
|
12
|
+
|
13
|
+
let(:app) do
|
14
|
+
s = Sprockets::Environment.new root_path
|
15
|
+
s.register_engine '.handlebars', Embork::Sprockets::EmberHandlebarsCompiler
|
16
|
+
s.register_engine '.hbs', Embork::Sprockets::EmberHandlebarsCompiler
|
17
|
+
s.append_path '.'
|
18
|
+
Rack::Builder.new do
|
19
|
+
run s
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'Globals' do
|
24
|
+
before(:all) { Embork::Sprockets::EmberHandlebarsCompiler.compile_to = :globals }
|
25
|
+
after(:all) { Embork::Sprockets::EmberHandlebarsCompiler.compile_to = :amd }
|
26
|
+
|
27
|
+
let(:global_hbs_specimen) { File.read(File.join(root_path, 'global_hbs_template.js')).strip }
|
28
|
+
let(:global_handlebars_specimen) { File.read(File.join(root_path, 'global_handlebars_template.js')).strip }
|
29
|
+
it 'compiles handlebars source to ember handlebars' do
|
30
|
+
get '/my_handlebars_template.js'
|
31
|
+
expect(last_response).to be_ok
|
32
|
+
expect(last_response.body).to eq(global_handlebars_specimen)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'compiles hbs source to ember handlebars' do
|
36
|
+
get '/my_hbs_template.js'
|
37
|
+
expect(last_response).to be_ok
|
38
|
+
expect(last_response.body).to eq(global_hbs_specimen)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'CommonJS' do
|
43
|
+
before(:all) { Embork::Sprockets::EmberHandlebarsCompiler.compile_to = :cjs }
|
44
|
+
after(:all) { Embork::Sprockets::EmberHandlebarsCompiler.compile_to = :amd }
|
45
|
+
|
46
|
+
let(:cjs_specimen) { File.read(File.join(root_path, 'cjs_template.js')).strip }
|
47
|
+
|
48
|
+
it 'compiles hbs source to ember handlebars' do
|
49
|
+
get '/my_hbs_template.js'
|
50
|
+
expect(last_response).to be_ok
|
51
|
+
expect(last_response.body.strip).to eq(cjs_specimen)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'AMD' do
|
56
|
+
let(:amd_specimen) { File.read(File.join(root_path, 'amd_template.js')).strip }
|
57
|
+
|
58
|
+
it 'compiles hbs source to ember handlebars' do
|
59
|
+
get '/my_hbs_template.js'
|
60
|
+
expect(last_response).to be_ok
|
61
|
+
expect(last_response.body.strip).to eq(amd_specimen)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'Transformed names' do
|
66
|
+
before(:all) do
|
67
|
+
transform = Proc.new do |module_name|
|
68
|
+
module_name.split('/').tap{ |parts| parts.shift }.join('_')
|
69
|
+
end
|
70
|
+
Embork::Sprockets::EmberHandlebarsCompiler.transform = transform
|
71
|
+
end
|
72
|
+
after(:all) { Embork::Sprockets::EmberHandlebarsCompiler.transform = nil }
|
73
|
+
|
74
|
+
let(:transformed_specimen) { File.read(File.join(root_path, 'transformed_template.js')).strip }
|
75
|
+
|
76
|
+
it 'transforms module names with a given proc' do
|
77
|
+
get '/my/hbs/template.js'
|
78
|
+
expect(last_response).to be_ok
|
79
|
+
expect(last_response.body.strip).to eq(transformed_specimen)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|