Class: Bootsy::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Bootsy::Generators::InstallGenerator
- Defined in:
- lib/generators/bootsy/install_generator.rb
Overview
Public: A Rails Generator to copy translations, assets and routes to the host app.
Instance Method Summary collapse
- #add_assets ⇒ Object
- #add_routes ⇒ Object
- #copy_config ⇒ Object
- #copy_locale ⇒ Object
- #insert_into_file(params) ⇒ Object
Instance Method Details
#add_assets ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/generators/bootsy/install_generator.rb', line 17 def add_assets assets_entries.each do |params| if File.exist?(params[:original]) insert_into_file(params) else say_status('not found', "#{params[:original]} not found. You must manually require Bootsy in your assets pipeline.", :red) end end end |
#add_routes ⇒ Object
8 9 10 |
# File 'lib/generators/bootsy/install_generator.rb', line 8 def add_routes route "mount Bootsy::Engine => '/bootsy', as: 'bootsy'" end |
#copy_config ⇒ Object
28 29 30 |
# File 'lib/generators/bootsy/install_generator.rb', line 28 def copy_config template 'bootsy.rb', 'config/initializers/bootsy.rb' end |
#copy_locale ⇒ Object
12 13 14 15 |
# File 'lib/generators/bootsy/install_generator.rb', line 12 def copy_locale copy_file '../../../../config/locales/bootsy.en.yml', 'config/locales/bootsy.en.yml' end |
#insert_into_file(params) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/generators/bootsy/install_generator.rb', line 32 def insert_into_file(params) if File.binread(params[:original]).include?(params[:skip_if]) say_status('skipped', "insert into #{params[:original]}", :yellow) else super( params[:original], params[:content], params[:position] ) end end |