-
Notifications
You must be signed in to change notification settings - Fork 5
/
template.rb
executable file
·55 lines (49 loc) · 1.85 KB
/
template.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# frozen_string_literal: true
run 'bundle remove tzinfo-data'
run 'bundle install'
template '~/driftingruby/template/drifting_ruby.css', 'app/assets/stylesheets/drifting_ruby.css'
run 'rm public/favicon.ico'
template '~/driftingruby/template/favicon.ico', 'public/favicon.ico'
template '~/driftingruby/template/logo.png', 'app/assets/images/logo.png'
generate(:controller, 'welcome', 'index')
gsub_file 'app/views/layouts/application.html.erb', '<body>', "<body class='bg-light'>"
gsub_file 'app/views/layouts/application.html.erb', '<title>Template</title>', '<title>Drifting Ruby</title>'
gsub_file 'app/views/layouts/application.html.erb', '<%= yield %>' do
<<~RUBY
<div class="container bg-white border pb-3">
<%= render 'layouts/navigation' %>
<% flash.each do |type, msg| %>
<% if type == 'alert' %>
<%= content_tag :div, msg, class: "alert alert-danger", role: :alert %>
<% else %>
<%= content_tag :div, msg, class: "alert alert-primary", role: :alert %>
<% end %>
<% end %>
<%= yield %>
</div>
RUBY
end
template '~/driftingruby/template/_navigation.html.erb', 'app/views/layouts/_navigation.html.erb'
template '~/driftingruby/template/_navigation_links.html.erb', 'app/views/layouts/_navigation_links.html.erb'
run 'cp -R ~/driftingruby/template/templates lib/templates'
inject_into_file 'config/application.rb', before: ' end' do
<<-CODE
config.generators do |g|
g.assets false
g.helper false
g.test_framework nil
g.jbuilder false
end
CODE
end
route "root to: 'welcome#index'"
after_bundle do
inject_into_file 'app/assets/stylesheets/application.bootstrap.scss' do
<<~CODE
@import 'drifting_ruby';
CODE
end
git :init
git add: '.'
git commit: %( -m 'base')
end