Class: Groundworkcss::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_assetsObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/generators/groundworkcss/install/install_generator.rb', line 11

def add_assets

  if File.exist?('app/assets/javascripts/application.js')
    insert_into_file "app/assets/javascripts/application.js", "//= require groundwork\n", :after => "jquery_ujs\n"
  else
    copy_file "application.js", "app/assets/javascripts/application.js"
  end

  if File.exist?('app/assets/stylesheets/application.css')
					style_require_block = "\n@import \"groundwork-and-overrides\";\n"
					insert_into_file "app/assets/stylesheets/application.css", style_require_block, :after => " */\n"
					File.rename("app/assets/stylesheets/application.css", "app/assets/stylesheets/application.css.scss")
					
				elsif File.exist?("app/assets/stylesheets/application.css.scss")
					style_require_block = "\n@import \"groundwork-and-overrides\";\n"
					insert_into_file "app/assets/stylesheets/application.css.scss", style_require_block, :after => " */\n"
					
  else
    copy_file "application.css.scss", "app/assets/stylesheets/application.css.scss"
  end
  
  copy_file "groundwork-and-overrides.scss", "app/assets/stylesheets/groundwork-and-overrides.scss" 

end

#add_javascriptObject



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

def add_javascript 	
  if use_coffeescript?
    copy_file "groundwork.coffee", "app/assets/javascripts/groundwork.js.coffee"
  else
    copy_file "groundwork.js", "app/assets/javascripts/groundwork.js"
  end
end