Class: Bootstrap::ComponentHelper::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/bootstrap/component_helper/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
# File 'lib/generators/bootstrap/component_helper/install/install_generator.rb', line 12

def add_assets

  copy_file "index.css.scss", "app/assets/stylesheets/bootstrap_component_helper/index.css.scss"
  copy_file "index.js", "app/assets/javascripts/bootstrap_component_helper/index.js"

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

  if File.exist?(js_manifest)
    insert_into_file js_manifest, :before => "//= require_tree .\n" do
      <<-JS
//= require bootstrap_component_helper
      JS
    end
  end

  css_manifest = 'app/assets/stylesheets/application.css'

  if File.exist?(css_manifest)
    insert_into_file css_manifest, :before => " *= require_self\n" do
      <<-CSS
 *= require bootstrap_component_helper
      CSS
    end
  end
end