Skip to content

Generate bootstrap with ember.prefix_dirs #519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/generators/ember/bootstrap_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def inject_ember
end

def create_dir_layout
%W{models controllers views routes helpers components templates templates/components mixins adapters}.each do |dir|
ember_prefix_dirs.each do |dir|
empty_directory "#{ember_path}/#{dir}"
create_file "#{ember_path}/#{dir}/.gitkeep" unless options[:skip_git]
end
Expand Down Expand Up @@ -78,6 +78,17 @@ def get_options_from_contents(contents)
{:after => regex}
end
end

def ember_prefix_dirs
dirs =
if configuration
Array(configuration.prefix_dirs)
else
%w(models controllers views routes components helpers mixins serializers adapters transforms)
end

dirs + %w(templates templates/components)
end
end
end
end
15 changes: 14 additions & 1 deletion test/generators/bootstrap_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ def prepare_destination
assert_new_dirs(:skip_git => true)
end

test "Assert folder layout with `ember.prefix_dirs`" do
begin
old, ::Rails.configuration.ember.prefix_dirs = ::Rails.configuration.ember.prefix_dirs, %w(foo)

run_generator %w(-g)

%w{foo templates templates/components}.each do |dir|
assert_directory ember_path(dir)
end
ensure
::Rails.configuration.ember.prefix_dirs = old
end
end

%w(js coffee em es6).each do |engine|

test "create bootstrap with #{engine} engine" do
Expand Down Expand Up @@ -152,7 +166,6 @@ def assert_new_dirs(options = {})
assert_directory "#{path}/#{dir}"
assert_file "#{path}/#{dir}/.gitkeep" unless options[:skip_git]
end

end

def application_name
Expand Down