Class: Bootsy::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
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

Instance Method Details

#add_assetsObject



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_routesObject



8
9
10
# File 'lib/generators/bootsy/install_generator.rb', line 8

def add_routes
  route "mount Bootsy::Engine => '/bootsy', as: 'bootsy'"
end

#copy_configObject



28
29
30
# File 'lib/generators/bootsy/install_generator.rb', line 28

def copy_config
  template 'bootsy.rb', 'config/initializers/bootsy.rb'
end

#copy_localeObject



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