Class: Bshelper::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_assetsObject



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
# File 'lib/generators/bshelper/install/install_generator.rb', line 12

def add_assets

  js_manifest = 'app/assets/javascripts/application.js'

  if File.exist?(js_manifest)
    insert_into_file js_manifest, :before => "//= require_tree .\n" do
      <<-JS
//= require bs-modal/bootstrap-modal
//= require bs-modal/bootstrap-modalmanager
//= require bootbox
//= require pnotify
//= require init-bshelper
      JS
    end

    if with_bootbox && with_bootbox == 'with-bootbox'
      insert_into_file js_manifest, :after => "//= require init-bshelper\n" do
        "//= require init-bootbox\n"
      end
    end
  end

  style_require_block = <<-CSS
 *= require bs-modal/bootstrap-modal
 *= require jquery.pnotify.default
 *= require jquery.pnotify.default.icons
  CSS

  insert_into_file 'app/assets/stylesheets/application.css', style_require_block, :after => "require_self\n" if File.exist?('app/assets/stylesheets/application.css')
  insert_into_file 'app/assets/stylesheets/application.css.scss', style_require_block, :after => "require_self\n" if File.exist?('app/assets/stylesheets/application.css.scss')
end