Class: Bootstrap::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Bootstrap::Generators::InstallGenerator
- Defined in:
- lib/generators/bootstrap/install/install_generator.rb
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
Instance Method Summary collapse
Instance Attribute Details
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
8 9 10 |
# File 'lib/generators/bootstrap/install/install_generator.rb', line 8 def app_name @app_name end |
Instance Method Details
#add_assets ⇒ Object
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 |
# File 'lib/generators/bootstrap/install/install_generator.rb', line 10 def add_assets js_manifest = 'app/assets/javascripts/application.js' if File.exist?(js_manifest) insert_into_file js_manifest, "//= require jquery3\n//= require popper\n//= require bootstrap-sprockets\n", :after => "turbolinks\n" else copy_file "application.js", js_manifest end css_manifest = 'app/assets/stylesheets/application.css' scss_manifest = 'app/assets/stylesheets/application.scss' if File.exist?(css_manifest) File.delete(css_manifest) if File.exist?(scss_manifest) File.delete(scss_manifest) copy_file "application.scss", "app/assets/stylesheets/application.scss" copy_file "bootstrap_forms.scss", "app/assets/stylesheets/bootstrap_forms.scss" else copy_file "application.scss", "app/assets/stylesheets/application.scss" copy_file "bootstrap_forms.scss", "app/assets/stylesheets/bootstrap_forms.scss" end else copy_file "application.scss", "app/assets/stylesheets/application.scss" copy_file "bootstrap_forms.scss", "app/assets/stylesheets/bootstrap_forms.scss" end app = ::Rails.application @app_name = app.class.to_s.split("::").first ext = app.config.generators.[:rails][:template_engine] || :erb template "layout.html.#{ext}", "app/views/layouts/application.html.#{ext}" template "_navbar.html.#{ext}", "app/views/shared/_navbar.html.#{ext}" template "_footer.html.#{ext}", "app/views/shared/_footer.html.#{ext}" end |