Created
February 27, 2011 22:01
-
-
Save jonbuda/846589 to your computer and use it in GitHub Desktop.
Simple Rake task for Rails3 to install/update to the latest version of jQuery and the rails.js UJS driver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :jquery do | |
desc "Installs the latest version of jQuery and the rails.js UJS jQuery Adapter" | |
task :install => :update do | |
puts "Installed jQuery and the rails.js UJS jQuery Adapter" | |
puts %Q{ | |
****************************************************************************** | |
You can update your javascript defaults in Rails3 with the following: | |
in application.rb, add: | |
config.action_view.javascript_expansions[:defaults] = %w(jquery.min rails) | |
****************************************************************************** | |
} | |
end | |
desc "Updates to the latest version of jQuery and the rails.js UJS jQuery Adapter" | |
task :update do | |
version = ENV['JQUERY_VERSION'] || nil | |
jquery = open("http://code.jquery.com/jquery#{version ? "-#{version}" : ""}.min.js") | |
ujs = open('https://github.com/rails/jquery-ujs/raw/master/src/rails.js') | |
puts "\n" | |
puts "Updating jQuery..." | |
File.open(File.join(Rails.root, 'public/javascripts/jquery.min.js'), 'w+') do |f| | |
f << jquery.read | |
end | |
puts "Updating jQuery UJS (from Github HEAD)..." | |
File.open(File.join(Rails.root, 'public/javascripts/rails.js'), 'w+') do |f| | |
f << ujs.read | |
end | |
puts "\n" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment