Class: Bootsy::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/bootsy/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_assetsObject



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/bootsy/install_generator.rb', line 14

def add_assets
  [
    {
      original: 'app/assets/javascripts/application.js',
      skip_if: 'require bootsy',
      content: "\n//= require bootsy",
      position: {
        after: '//= require jquery_ujs'
      }
    },
    {
      original: 'app/assets/stylesheets/application.css',
      skip_if: 'require bootsy',
      content: "\n *= require bootsy",
      position: {
        after: '*= require_self'
      }
    }
  ].each do |params|
    if File.exists?(params[:original])
      if File.binread(params[:original]).include?(params[:skip_if])
        say_status('skipped', "insert into #{params[:original]}", :yellow)
      else
        insert_into_file(params[:original], params[:content], params[:position])
      end
    else
      say_status('not found', "#{params[:original]} not found. You must manually require Bootsy in your assets pipeline.", :red)
    end
  end
end

#add_routesObject



6
7
8
# File 'lib/generators/bootsy/install_generator.rb', line 6

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

#copy_configObject



45
46
47
# File 'lib/generators/bootsy/install_generator.rb', line 45

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

#copy_localeObject



10
11
12
# File 'lib/generators/bootsy/install_generator.rb', line 10

def copy_locale
  copy_file('../../../../config/locales/en.yml', 'config/locales/bootsy.en.yml')
end