Class: Jquery::InstallGenerator

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

Constant Summary collapse

PATH =
source_root File.expand_path('../templates', __FILE__)
JS_DEST =
"public/javascripts"
CSS_DEST =
"public/stylesheets"

Instance Method Summary collapse

Instance Method Details

#install_jqueryObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/generators/jquery/install/install_generator.rb', line 21

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

#remove_prototypeObject



13
14
15
16
17
18
19
# File 'lib/generators/jquery/install/install_generator.rb', line 13

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