Class: Bootstrap::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#copy_form_builderObject



17
18
19
# File 'lib/generators/bootstrap/install/install_generator.rb', line 17

def copy_form_builder
  copy_file "form_builders/form_builder/_form.html.#{options[:template_engine]}", "lib/templates/#{options[:template_engine]}/scaffold/_form.html.#{options[:template_engine]}"
end

#copy_libObject



13
14
15
# File 'lib/generators/bootstrap/install/install_generator.rb', line 13

def copy_lib
  directory "lib/templates/#{options[:template_engine]}"
end

#create_layoutObject



21
22
23
# File 'lib/generators/bootstrap/install/install_generator.rb', line 21

def create_layout
  template "layouts/starter.html.#{options[:template_engine]}", "app/views/layouts/application.html.#{options[:template_engine]}"
end

#create_stylesheetsObject



25
26
27
28
29
30
31
32
33
# File 'lib/generators/bootstrap/install/install_generator.rb', line 25

def create_stylesheets
  stylesheet_extension = options[:stylesheet_engine] || 'css'

  copy_file "assets/stylesheets/starter.#{stylesheet_extension}", "app/assets/stylesheets/bootstrap-generators.#{stylesheet_extension}"

  if [:less, :scss].include?(options[:stylesheet_engine].to_sym)
    copy_file "assets/stylesheets/bootstrap-variables.#{stylesheet_extension}", "app/assets/stylesheets/bootstrap-variables.#{stylesheet_extension}"
  end
end

#inject_backboneObject



35
36
37
38
39
40
41
42
43
# File 'lib/generators/bootstrap/install/install_generator.rb', line 35

def inject_backbone
  application_js_path = 'app/assets/javascripts/application.js'

  if ::File.exists?(::File.join(destination_root, application_js_path))
    inject_into_file application_js_path, before: '//= require_tree' do
      "//= require bootstrap\n"
    end
  end
end