Sha256: abbefd30e22a89e62d69e4ee3ad14364c5d48745ccff10b38a803f2e13b6135f

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

require 'rails/generators'

module Purecss
  module Generators
    class InstallGenerator < Rails::Generators::Base
      source_root File.join(File.dirname(__FILE__), 'templates')
      argument :stylesheets_type, :type => :string, :default => 'responsive', :banner => '*responsive or nonresponsive'
      
      def add_assets
        if stylesheets_type=='nonresponsive'
          purecss_type = 'purecss-nr'
        elsif stylesheets_type=='responsive'
          purecss_type = 'purecss'
        else
          raise "'#{stylesheets_type}'' is not recognized, use either 'responsive' or 'nonresponsive'"
          
        end

        insert_into_file "app/assets/stylesheets/application#{detect_css_format[0]}", "#{detect_css_format[1]} require #{purecss_type}\n", :after => "require_self\n"              
      end
      
      def detect_css_format
        return ['.css', ' *='] if File.exist?('app/assets/stylesheets/application.css')
        return ['.css.sass', ' //='] if File.exist?('app/assets/stylesheets/application.css.sass')
        return ['.sass', ' //='] if File.exist?('app/assets/stylesheets/application.sass')
        return ['.css.scss', ' //='] if File.exist?('app/assets/stylesheets/application.css.scss')
        return ['.scss', ' //='] if File.exist?('app/assets/stylesheets/application.scss')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
purecss-0.5.0.1 lib/purecss/generators/install_generator.rb