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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/generators/dutchman/install/install_generator.rb', line 13
def add_assets
css_inject = " *= require #{options[:captain]}/#{options[:captain]}\n"
app_scss = File.join(Rails.root, 'app', 'assets', 'stylesheets', 'application.scss')
app_css = File.join(Rails.root, 'app', 'assets', 'stylesheets', 'application.css')
app_js = 'app/assets/javascripts/application.js'
captain = options[:captain]
custom = options[:custom]
if captain.nil?
puts "Arr. The Dutchman must have a captain."
puts "Rerun with --captain=normalize/skeleton/bootstrap"
else
puts ""
puts "===> The Flying Dutchman"
puts "===> Your Captain is #{options[:captain]}."
puts ""
if File.exist?(app_scss)
insert_into_file app_scss, css_inject, :after => "require_self\n"
elsif File.exist?(app_css)
insert_into_file app_css, css_inject, :after => "require_self\n"
else
say_status('','The Dutchman was unable to locate an application.css or application.scss.')
end
if captain=="bootstrap"
if ::File.exists?(::File.join(destination_root, app_js))
inject_into_file app_js, before: '//= require_tree' do
"//= require bootstrap/tether.min\n//= require bootstrap/bootstrap.min\n"
end
else
say_status('','The Dutchman was unable to locate an application.js.')
end
end
if custom=="yes"
if captain=="normalize"
puts ""
puts "===> Arrr. You can't customize Normalize."
puts "===> Try custom with Bootstrap or Skeleton."
else
copy_file "assets/stylesheets/#{options[:captain]}/#{options[:captain]}-custom.scss", "vendor/assets/stylesheets/#{options[:captain]}/#{options[:captain]}.scss"
copy_file "assets/stylesheets/#{options[:captain]}/_custom.scss", "vendor/assets/stylesheets/#{options[:captain]}/_custom.scss"
end
end
puts ""
puts "===> Your ship is built."
puts "===> Welcome Aboard!"
puts ""
end
end
|