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,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
|
+
|
data/lib/string/strip.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Borrowed from activesupport, but without the :try method
|
2
|
+
|
3
|
+
class String
|
4
|
+
# Strips indentation in heredocs.
|
5
|
+
#
|
6
|
+
# For example in
|
7
|
+
#
|
8
|
+
# if options[:usage]
|
9
|
+
# puts <<-USAGE.strip_heredoc
|
10
|
+
# This command does such and such.
|
11
|
+
#
|
12
|
+
# Supported options are:
|
13
|
+
# -h This message
|
14
|
+
# ...
|
15
|
+
# USAGE
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# the user would see the usage message aligned against the left margin.
|
19
|
+
#
|
20
|
+
# Technically, it looks for the least indented line in the whole string, and removes
|
21
|
+
# that amount of leading whitespace.
|
22
|
+
def strip_heredoc
|
23
|
+
matches = scan(/^[ \t]*(?=\S)/).min
|
24
|
+
indent = (matches.respond_to? :size) ? matches.size : 0
|
25
|
+
gsub(/^[ \t]{#{indent}}/, '')
|
26
|
+
end
|
27
|
+
end
|
File without changes
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# vim: set ft=ruby:
|
2
|
+
|
3
|
+
keep_old_versions 10
|
4
|
+
|
5
|
+
set_project_root '/tmp/project_root'
|
6
|
+
|
7
|
+
append_asset_path 'foo/css'
|
8
|
+
|
9
|
+
es6_namespace 'my-package'
|
10
|
+
|
11
|
+
add_sprockets_helpers do
|
12
|
+
def empty_span
|
13
|
+
'<span></span>'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
register_postprocessor 'application/javascript', class MyPostProcessor; end
|
18
|
+
register_engine '.stuff', class MyEngine; end
|
19
|
+
|
20
|
+
compile_html [ 'index.html' ]
|
21
|
+
|
22
|
+
use_framework :bootstrap
|
23
|
+
|
24
|
+
configure :development do
|
25
|
+
append_asset_path 'foo/dev/js'
|
26
|
+
compile_html 'dev.html'
|
27
|
+
end
|
28
|
+
|
29
|
+
configure :production do
|
30
|
+
append_asset_path 'foo/prod/js'
|
31
|
+
compile_html 'prod.html'
|
32
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'embork/borkfile'
|
3
|
+
|
4
|
+
borkfile_dir = File.expand_path '../borkfile', __FILE__
|
5
|
+
empty_borkfile_path = File.join borkfile_dir, 'Borkfile.empty'
|
6
|
+
full_borkfile_path = File.join borkfile_dir, 'Borkfile.full'
|
7
|
+
relative_root_borkfile_path = File.join borkfile_dir, 'Borkfile.relative'
|
8
|
+
rack_based_borkfile_path = File.join borkfile_dir, 'Borkfile.rack'
|
9
|
+
|
10
|
+
describe 'Embork::Borkfile' do
|
11
|
+
describe 'defaults' do
|
12
|
+
let(:borkfile) { Embork::Borkfile.new empty_borkfile_path }
|
13
|
+
|
14
|
+
it 'uses the files directory as project root' do
|
15
|
+
expect(borkfile.project_root).to match(/.*\/embork\/spec\/embork\/borkfile$/)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'includes source path' do
|
19
|
+
expect(borkfile.asset_paths).to include('app')
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'includes :development config in path' do
|
23
|
+
expect(borkfile.asset_paths).to include('config/development')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'includes components path' do
|
27
|
+
expect(borkfile.asset_paths).to include('components')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'has no defined helpers' do
|
31
|
+
expect(borkfile.helpers).to be_empty
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'has no html files' do
|
35
|
+
expect(borkfile.html).to be_empty
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'keeps five old versions' do
|
39
|
+
expect(borkfile.keep_old_versions).to eq(5)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'has no es6 module namespace defined' do
|
43
|
+
expect(borkfile.es6_namespace).to eq(nil)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'basic config' do
|
48
|
+
let(:borkfile) { Embork::Borkfile.new full_borkfile_path }
|
49
|
+
|
50
|
+
it 'doesn\'t expand absolute paths' do
|
51
|
+
expect(borkfile.project_root).to eq('/tmp/project_root')
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'adds arbitrary asset_paths' do
|
55
|
+
expect(borkfile.asset_paths).to include('foo/css')
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'adds arbitrary helpers' do
|
59
|
+
expect(borkfile.helpers[0].call).to eq(:empty_span)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'evaluates code in the current enviroment' do
|
63
|
+
expect(borkfile.asset_paths).to include('foo/dev/js')
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'does not evaluate code from other environments' do
|
67
|
+
expect(borkfile.asset_paths).not_to include('foo/prod/js')
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'registered sprockets post-processor' do
|
71
|
+
expect(borkfile.sprockets_postprocessors.length).to eq(1)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'registered sprockets engines' do
|
75
|
+
expect(borkfile.sprockets_engines.length).to eq(1)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'specifies html files to build by environment' do
|
79
|
+
expect(borkfile.html).to match_array [ 'index.html', 'dev.html' ]
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'does not pick up other environment\'s html files' do
|
83
|
+
expect(borkfile.html).not_to include 'prod.html'
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'uses pushstate middleware to respond with index.html' do
|
87
|
+
expect(borkfile.backend).to eq(:static_index)
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'keeps the specified number of old versions' do
|
91
|
+
expect(borkfile.keep_old_versions).to eq(10)
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'sets up an es6 module namespace' do
|
95
|
+
expect(borkfile.es6_namespace).to eq('my-package')
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'includes frameworks' do
|
99
|
+
expect(borkfile.frameworks).to include 'bootstrap'
|
100
|
+
expect(borkfile.frameworks).not_to include 'compass'
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe 'relative root' do
|
105
|
+
let(:borkfile) { Embork::Borkfile.new relative_root_borkfile_path }
|
106
|
+
|
107
|
+
it 'expands the relative path' do
|
108
|
+
expect(borkfile.project_root).to match(/.*\/embork\/spec\/embork\/borkfile\/project_root$/)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe 'rack backed' do
|
113
|
+
let(:borkfile) { Embork::Borkfile.new rack_based_borkfile_path }
|
114
|
+
|
115
|
+
it 'specifies that any missing routes are driven by a rack app' do
|
116
|
+
expect(borkfile.backend.class.name.to_sym).to eq(:MyRackApp)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# vim: set ft=ruby:
|
2
|
+
# Borkfile
|
3
|
+
|
4
|
+
set_project_root '.'
|
5
|
+
|
6
|
+
add_sprockets_helpers do
|
7
|
+
end
|
8
|
+
|
9
|
+
compile_html 'index.html'
|
10
|
+
|
11
|
+
es6_namespace 'my-package'
|
12
|
+
|
13
|
+
configure :development do
|
14
|
+
end
|
15
|
+
|
16
|
+
configure :production do
|
17
|
+
end
|
18
|
+
|
19
|
+
set_backend :static_index
|
20
|
+
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'embork/borkfile'
|
4
|
+
require 'embork/environment'
|
5
|
+
require 'embork/builder'
|
6
|
+
|
7
|
+
require 'pathname'
|
8
|
+
|
9
|
+
describe 'Embork::Builder' do
|
10
|
+
let(:root_path) { File.expand_path '../builder', __FILE__ }
|
11
|
+
let(:borkfile) { Embork::Borkfile.new File.join(root_path, 'Borkfile'), :production }
|
12
|
+
let(:builder) { Embork::Builder.new borkfile }
|
13
|
+
let(:build_directory) { File.join(root_path, 'build', 'production') }
|
14
|
+
let(:expected_files) do
|
15
|
+
[
|
16
|
+
'application-%s.css',
|
17
|
+
'application-%s.js',
|
18
|
+
'deeply/nested/asset-%s.js',
|
19
|
+
'images/image.png',
|
20
|
+
'index-%s.html',
|
21
|
+
'index.html'
|
22
|
+
]
|
23
|
+
end
|
24
|
+
|
25
|
+
after(:each) { FileUtils.rm_rf File.join(root_path, '.cache') }
|
26
|
+
after(:all) do
|
27
|
+
Embork::Sprockets::ES6ModuleTranspiler.namespace = nil
|
28
|
+
Embork::Sprockets::ES6ModuleTranspiler.transform = nil
|
29
|
+
end
|
30
|
+
|
31
|
+
let(:built_files) do
|
32
|
+
[].tap do |files|
|
33
|
+
Dir.glob(File.join(build_directory, '**/*')) do |file|
|
34
|
+
if !File.directory? file
|
35
|
+
path = Pathname.new(file)
|
36
|
+
files.push path.relative_path_from(Pathname.new build_directory).to_s
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
before(:each) { @asset_bundle_version = builder.build }
|
43
|
+
after(:each) { builder.clean! }
|
44
|
+
|
45
|
+
it 'builds assets' do
|
46
|
+
expect(File.exists? build_directory).to be true
|
47
|
+
|
48
|
+
expect(built_files).to match_array(expected_files.map{ |f| f % [ @asset_bundle_version ] })
|
49
|
+
end
|
50
|
+
|
51
|
+
context '#clean' do
|
52
|
+
|
53
|
+
let(:older_stamp) { Time.now - 10 }
|
54
|
+
let(:expected_files) do
|
55
|
+
(1..4).map do |delta|
|
56
|
+
version = (older_stamp - delta).to_s.gsub(/ -| |-|:/, '.')
|
57
|
+
"application-#{version}.js"
|
58
|
+
end.push "application-#{@asset_bundle_version}.js"
|
59
|
+
end
|
60
|
+
|
61
|
+
let(:unexpected_files) do
|
62
|
+
(5..10).map do |delta|
|
63
|
+
version = (older_stamp - delta).to_s.gsub(/ -| |-|:/, '.')
|
64
|
+
"application-#{version}.js"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
before(:each) do
|
69
|
+
(1..10).each do |delta|
|
70
|
+
version = (older_stamp - delta).to_s.gsub(/ -| |-|:/, '.')
|
71
|
+
FileUtils.touch File.join(build_directory, "application-#{version}.js")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'keeps :keep_old_versions number of versions' do
|
76
|
+
# This is what we're testing
|
77
|
+
builder.clean
|
78
|
+
|
79
|
+
expect(built_files).to include(*expected_files)
|
80
|
+
expect(built_files).not_to include(*unexpected_files)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'asset_helpers' do
|
85
|
+
let(:index_read) { File.read File.join(build_directory, 'index.html') }
|
86
|
+
|
87
|
+
it 'it compiles javascript tags to use bundled assets' do
|
88
|
+
expect(index_read).to include(%{<script src="/application-#{@asset_bundle_version}.js"></script>})
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'it compiles style tags to use bundled assets' do
|
92
|
+
expect(index_read).to include(%{<link href="/application-#{@asset_bundle_version}.css" rel="stylesheet" type="text/css" media="all"></link>})
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'embork/environment'
|
3
|
+
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
|
7
|
+
describe 'Embork::Environment' do
|
8
|
+
|
9
|
+
let(:my_postprocessor) { class MyPostProcessor; end }
|
10
|
+
let(:my_preprocessor) { class MyPreProcessor; end }
|
11
|
+
|
12
|
+
let(:my_engine) { class MyEngine; end }
|
13
|
+
|
14
|
+
let(:borkfile) { OpenStruct.new({
|
15
|
+
:asset_paths => [ 'foo/bar/assets' ],
|
16
|
+
:helpers => [ Proc.new { def my_helper; end; } ],
|
17
|
+
:project_root => '/project_root',
|
18
|
+
:sprockets_postprocessors => [
|
19
|
+
{ :mime_type => 'application/bork', :klass => my_postprocessor }
|
20
|
+
],
|
21
|
+
:sprockets_preprocessors => [
|
22
|
+
{ :mime_type => 'application/bork', :klass => my_preprocessor }
|
23
|
+
],
|
24
|
+
:sprockets_engines => [
|
25
|
+
{ :extension => '.bork', :klass => my_engine }
|
26
|
+
],
|
27
|
+
:es6_namespace => 'my-package',
|
28
|
+
:frameworks => [ 'bootstrap', 'compass' ]
|
29
|
+
})}
|
30
|
+
|
31
|
+
let (:environment) { Embork::Environment.new borkfile }
|
32
|
+
|
33
|
+
after(:all) do
|
34
|
+
Embork::Sprockets::ES6ModuleTranspiler.namespace = nil
|
35
|
+
Embork::Sprockets::ES6ModuleTranspiler.transform = nil
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'respects the project root' do
|
39
|
+
expect(environment.sprockets_environment.root).to eq('/project_root')
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'respects asset paths' do
|
43
|
+
expect(environment.sprockets_environment.paths).to include('/project_root/foo/bar/assets')
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'adds helpers to the context class' do
|
47
|
+
expect(environment.sprockets_environment.context_class.instance_methods).to include(:my_helper)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'adds post-processers by mime type' do
|
51
|
+
expect(environment.sprockets_environment.postprocessors('application/bork')).to include(my_postprocessor)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'adds pre-processers by mime type' do
|
55
|
+
expect(environment.sprockets_environment.preprocessors('application/bork')).to include(my_preprocessor)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'adds engines my extension' do
|
59
|
+
expect(environment.sprockets_environment.engines('.bork')).to eq(my_engine)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'uses a file-based persistent cache' do
|
63
|
+
expect(environment.sprockets_environment.cache.class).to eq(Embork::Environment::ErblessCache)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'sets up a namespace on the es6 processor' do
|
67
|
+
expect(Embork::Sprockets::ES6ModuleTranspiler.namespace).to eq('my-package')
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'adds compass to the asset path' do
|
71
|
+
expect(environment.sprockets_environment.paths.to_s).to match /\/compass-.*?\/frameworks\/compass\/stylesheets/
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'adds bootstrap to the asset path' do
|
75
|
+
expect(environment.sprockets_environment.paths.to_s).to match /\/bootstrap-sass-.*?\/vendor\/assets\/stylesheets/
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'embork/generator'
|
3
|
+
|
4
|
+
describe 'Embork::Generator' do
|
5
|
+
|
6
|
+
let(:app_name) { 'my-app' }
|
7
|
+
let(:working_dir) { File.expand_path '../generator', __FILE__ }
|
8
|
+
let(:project_dir) { File.join working_dir, app_name }
|
9
|
+
let(:generator) do
|
10
|
+
Embork::Generator.new app_name, {
|
11
|
+
:use_ember_data => false,
|
12
|
+
:directory => project_dir
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'loads the list of files to be processed by ERB' do
|
17
|
+
expect(generator.erb_files).to match_array([
|
18
|
+
"Borkfile", "app/app.js", "app/index.html.erb", "bower.json", "package.json"
|
19
|
+
])
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'loads the list of files to be moved to dot-files' do
|
23
|
+
expect(generator.dot_files).to match_array([
|
24
|
+
"bowerrc", "gitignore", "jshintrc"
|
25
|
+
])
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'defaults to the correct directory' do
|
29
|
+
expect(generator.project_path).to eq(project_dir)
|
30
|
+
end
|
31
|
+
|
32
|
+
context '#project_path' do
|
33
|
+
it 'defaults to a path named for the package, relative to the caller' do
|
34
|
+
g = Embork::Generator.new(app_name, use_ember_data: false, directory: nil)
|
35
|
+
expected_path = File.join(Dir.pwd, app_name)
|
36
|
+
expect(g.project_path).to eq(expected_path)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'expands a relative path' do
|
40
|
+
directory = 'some/other/dir'
|
41
|
+
g = Embork::Generator.new(app_name, use_ember_data: false, directory: directory)
|
42
|
+
expected_path = File.expand_path directory, Dir.pwd
|
43
|
+
expect(g.project_path).to eq(expected_path)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context '#generate' do
|
48
|
+
before(:each) { generator.generate }
|
49
|
+
after(:each) { FileUtils.rm_rf project_dir }
|
50
|
+
|
51
|
+
it 'generates a blank project' do
|
52
|
+
Dir.chdir project_dir do
|
53
|
+
files = [ '.',
|
54
|
+
'..',
|
55
|
+
'.git',
|
56
|
+
'.bowerrc',
|
57
|
+
'.gitignore',
|
58
|
+
'.jshintrc',
|
59
|
+
'Borkfile',
|
60
|
+
'Gemfile',
|
61
|
+
'Gemfile.lock',
|
62
|
+
'README.md',
|
63
|
+
'app',
|
64
|
+
'bower.json',
|
65
|
+
'components',
|
66
|
+
'config',
|
67
|
+
'dotfiles',
|
68
|
+
'erbfiles',
|
69
|
+
'node_modules',
|
70
|
+
'package.json',
|
71
|
+
'static',
|
72
|
+
'tests' ]
|
73
|
+
expect(Dir.glob('*', File::FNM_DOTMATCH)).to match_array(files)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'processes erb' do
|
78
|
+
Dir.chdir project_dir do
|
79
|
+
expect(File.read('app/app.js')).to include('my-app')
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|