Class: BootswatchRails::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- BootswatchRails::Generators::InstallGenerator
- Defined in:
- lib/generators/bootswatch_rails/install/install_generator.rb
Instance Method Summary collapse
- #copy_application_js ⇒ Object
- #copy_directories ⇒ Object
- #setup_assets_precompile ⇒ Object
- #setup_head ⇒ Object
- #update_application_controller ⇒ Object
Instance Method Details
#copy_application_js ⇒ Object
37 38 39 40 41 |
# File 'lib/generators/bootswatch_rails/install/install_generator.rb', line 37 def copy_application_js file = "app/assets/javascripts/application.js" remove_file file template "application.js", file end |
#copy_directories ⇒ Object
54 55 56 57 58 |
# File 'lib/generators/bootswatch_rails/install/install_generator.rb', line 54 def copy_directories directory "app", force: true directory "config" directory "lib", force: true end |
#setup_assets_precompile ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/generators/bootswatch_rails/install/install_generator.rb', line 43 def setup_assets_precompile return unless .cdn? initializer "bootswatch_assets.rb" do assets = "jquery.js" assets += " jquery-ui.js" if .ui? assets += " jquery.dataTables.js dataTables.responsive.js" if .dt? assets += " bootstrap.js" "Rails.application.config.assets.precompile += %w( #{assets} )" end end |
#setup_head ⇒ Object
60 61 62 |
# File 'lib/generators/bootswatch_rails/install/install_generator.rb', line 60 def setup_head template "head.html.erb", "app/views/layouts/_head.html.erb" end |
#update_application_controller ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/generators/bootswatch_rails/install/install_generator.rb', line 16 def update_application_controller file = "app/controllers/application_controller.rb" inject_into_file file, "\n\n private", after: /protect_from_forgery.*$/ lines = [ "", " def default_theme", " BootswatchRails::THEMES[BootswatchRails::DEFAULT].to_s", " end", " helper_method :default_theme", "", " def current_theme", " @current_theme = current_user.theme if logged_in?", " @current_theme ||= default_theme", " end", " helper_method :current_theme", "" ] inject_into_file file, lines.join("\n"), before: /^end$/ end |