Class: CssCanon::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- CssCanon::Generators::InstallGenerator
- Defined in:
- lib/css_canon/generators/install_generator.rb
Instance Method Summary collapse
- #copy_app_asset_templates ⇒ Object
- #copy_vendor_asset_templates ⇒ Object
- #install_foundation_if_not_installed ⇒ Object
- #modify_zurb_overrides_file ⇒ Object
Instance Method Details
#copy_app_asset_templates ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/css_canon/generators/install_generator.rb', line 13 def copy_app_asset_templates say "setting up app/assets/stylesheets..." if File.exists? "app/assets/stylesheets/application.css" File.rename "app/assets/stylesheets/application.css", "app/assets/stylesheets/TO_MIGRATE.css" end copy_file "app/assets/stylesheets/application.css.scss" copy_file "app/assets/stylesheets/base.css.scss" directory "app/assets/stylesheets/layout" directory "app/assets/stylesheets/module" directory "app/assets/stylesheets/vendor_overrides" end |
#copy_vendor_asset_templates ⇒ Object
25 26 27 28 |
# File 'lib/css_canon/generators/install_generator.rb', line 25 def copy_vendor_asset_templates say "setting up vendor/assets/stylesheets..." directory "vendor/assets/stylesheets" end |
#install_foundation_if_not_installed ⇒ Object
7 8 9 10 11 |
# File 'lib/css_canon/generators/install_generator.rb', line 7 def install_foundation_if_not_installed unless File.exists?("app/assets/stylesheets/foundation_and_overrides.scss") generate "foundation:install" end end |
#modify_zurb_overrides_file ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/css_canon/generators/install_generator.rb', line 30 def modify_zurb_overrides_file say "adding example use of brand variables to foundation_and_overrides..." foundation_file = "app/assets/stylesheets/foundation_and_overrides.scss" color_example_regex = %r{^ *// *\$mainColor:.*} our_color_example = <<-EOCSS \n// override foundation variables with variables defined in base.css.scss, // so that branding can easily be changed in a single place // $mainColor: $brandOne;" EOCSS if File.readlines(foundation_file).grep(color_example_regex).size > 0 gsub_file foundation_file, color_example_regex, our_color_example else inject_into_file foundation_file, our_color_example, after: %r{// Colors Settings} end end |