Class: Starter::StyleGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/starter/style/style_generator.rb

Instance Method Summary collapse

Instance Method Details

#generate_layoutObject



38
39
40
# File 'lib/generators/starter/style/style_generator.rb', line 38

def generate_layout
  template "layout.html.erb", "app/views/layouts/#{layout_file}.html.erb" if options[:layout]
end

#inject_stylesObject



11
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/starter/style/style_generator.rb', line 11

def inject_styles
  template 'bootstrap_overrides.css', 'app/assets/stylesheets/bootstrap_overrides.css', verbose: false

  if bootswatch_theme?
    log :insert, "Bootswatch theme '#{theme_name}'"
    inject_into_file "app/assets/stylesheets/application.css", "\n *= require bootstrap_overrides\n", before: /^\s*\*\//, verbose: false
    log :insert, 'Bootstrap customizations'
    gsub_file 'app/assets/stylesheets/application.css', /^\s*\*= require bootstrap.min \./, ''

  else
    gsub_file 'app/assets/stylesheets/application.css', /^\s*\*= require_tree \./, ''
    template 'bootstrap.min.css', 'app/assets/stylesheets/bootstrap.min.css', verbose: false
    inject_into_file "app/assets/stylesheets/application.css", " *= require bootstrap.min\n", before: /^\s*\*\//, verbose: false
    log :insert, 'Bootstrap CSS framework'
    inject_into_file "app/assets/stylesheets/application.css", " *= require bootstrap_overrides\n", before: /^\s*\*\//, verbose: false
    log :insert, 'Bootstrap customizations'
  end

  log :insert, 'FontAwesome support'

  template 'bootstrap.min.js', 'app/assets/javascripts/bootstrap.min.js', verbose: false
  inject_into_file 'app/assets/javascripts/application.js',
                   "\n//= require bootstrap.min",
                   after: /^\/\/= require jquery$/,
                   verbose: false
end