Sha256: e71e2ea6f1b7aa6cd468a92a2f1262ce8e1668d8181076bfbb6d6c9be0ad20a4

Contents?: true

Size: 1.52 KB

Versions: 11

Compression:

Stored size: 1.52 KB

Contents

require 'rails/generators'

module Groundworkcss
  module Generators
    class InstallGenerator < ::Rails::Generators::Base

      source_root File.expand_path("../templates", __FILE__)
      desc "This generator installs GroundworkCSS to Asset Pipeline"
      argument :stylesheets_type, :type => :string, :default => 'less', :banner => '*less or static'

      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 = " *= require groundwork-and-overrides\n"
					insert_into_file "app/assets/stylesheets/application.css", style_require_block, :after => "require_self\n"
        else
          copy_file "application.css", "app/assets/stylesheets/application.css"
        end
        
        copy_file "groundwork-and-overrides.scss", "app/assets/stylesheets/groundwork-and-overrides.scss" 

      end

      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
      
		private
      def use_coffeescript?
        ::Rails.configuration.app_generators.rails[:javascript_engine] == :coffee
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
groundworkcss-rails-0.2.12 lib/generators/groundworkcss/install/install_generator.rb~
groundworkcss-rails-0.2.11 lib/generators/groundworkcss/install/install_generator.rb~
groundworkcss-rails-0.2.10 lib/generators/groundworkcss/install/install_generator.rb~
groundworkcss-rails-0.2.9 lib/generators/groundworkcss/install/install_generator.rb~
groundworkcss-rails-0.2.8 lib/generators/groundworkcss/install/install_generator.rb~
groundworkcss-rails-0.2.7 lib/generators/groundworkcss/install/install_generator.rb~
groundworkcss-rails-0.2.6 lib/generators/groundworkcss/install/install_generator.rb~
groundworkcss-rails-0.2.5 lib/generators/groundworkcss/install/install_generator.rb~
groundworkcss-rails-0.2.2 lib/generators/groundworkcss/install/install_generator.rb~
groundworkcss-rails-0.2 lib/generators/groundworkcss/install/install_generator.rb~
groundworkcss-rails-0.1 lib/generators/groundworkcss/install/install_generator.rb~