Class: Fuelux::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#generate_installObject



9
10
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
# File 'lib/generators/fuelux/install_generator.rb', line 9

def generate_install

				conf = File.read("config/environments/production.rb")
				insert_into_file "config/environments/production.rb", "  config.assets.precompile += %w( *.png )\n", :after => %(# Precompile additional assets.\n) unless conf.match(/config\.assets\.precompile\s\+=\s%w\(.*\*\.png.*\)$/)
					
  if File.exist?('app/assets/stylesheets/bootstrap_and_overrides.css.less')
    insert_into_file "app/assets/stylesheets/bootstrap_and_overrides.css.less", "@import 'fuelux.less';\n", :after => %(@import "fontawesome";\n)
    insert_into_file "app/assets/stylesheets/bootstrap_and_overrides.css.less", "@import 'fuelux.less';\n", :after => %(@import "fontawesome/font-awesome";\n)
  else
    puts <<-EOM
    Warning:
      app/assets/stylesheets/bootstrap_overrides.css.less does not exist
      Run "rails generate bootstrap:install" and then rerun "rails generate fuelux:install"
    EOM
  end

  if File.exist?('app/assets/javascripts/application.js')
    # Add our own require:
    content = File.read("app/assets/javascripts/application.js")
    if content.match(/require\s+fuelux\.js\s*$/)
      # Good enough - that'll include our Fuel UX js
    else
      insert_into_file "app/assets/javascripts/application.js", "//= require fuelux.js\n", :after => "jquery_ujs\n"
    end
  end

end