Sha256: 0db02b8725cbe6b6f205c7046dd18316c1df94e560846b9e7040750af09f8267

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

module Jquery
  class InstallGenerator < Rails::Generators::Base
    PATH = source_root File.expand_path('../templates', __FILE__)
    # Options
    class_option :ui, :type => :boolean, :defalut => false, :desc => "Add jquery-ui components to application."
    class_option :ui_version, :type => :string, :defalut => "1", :desc => "Version of jquery-ui components to application."
    class_option :version, :type => :string, :defalut => "1", :desc => "Version of jquery used in application."
    OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
    
    JS_DEST = "public/javascripts"
    CSS_DEST = "public/stylesheets"
    
    def remove_prototype
      old_scripts = %w(controls dragdrop effects prototype)
      old_scripts.each do |script|
        path = "#{JS_DEST}/#{script}.js"
        remove_file path if File.exist? path 
      end
    end
  
    def install_jquery
      version = (options[:version].nil?)? "1" :  options[:version]
      ui_version = (options[:ui_version].nil?)? "1" :  options[:ui_version]
      url = "http://ajax.googleapis.com/ajax/libs/jquery/#{version}/jquery.min.js"
      #puts url
      get url, "#{JS_DEST}/jquery.js"
      
      get "https://github.com/rails/jquery-ujs/raw/master/src/rails.js", "#{JS_DEST}/rails.js"
      url = "http://ajax.googleapis.com/ajax/libs/jqueryui/#{ui_version}/jquery-ui.min.js"
      #puts url
      if options.ui?      
        get url, "#{JS_DEST}/jquery-ui.js"  
      end
      
    end
  
    
  
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jquery_rails3-1.6.1 lib/generators/jquery/install/install_generator.rb