Improve the update task to download jQuery 2 as well.

This commit is contained in:
Lucas Mazza
2014-09-01 14:28:29 -03:00
parent 35d96fba4f
commit c3dc6f3433
2 changed files with 12 additions and 20 deletions

View File

@@ -18,31 +18,22 @@ task :guard_version do
end
check_version('jquery.js', /jQuery JavaScript Library v([\S]+)/, 'JQUERY_VERSION')
check_version('jquery2.js', /jQuery JavaScript Library v([\S]+)/, 'JQUERY_2_VERSION')
end
task :update_jquery do
puts "Downloading jquery.js"
puts `curl -o vendor/assets/javascripts/jquery.js http://code.jquery.com/jquery.js`
puts "Downloading jquery.min.js"
puts `curl -o vendor/assets/javascripts/jquery.min.js http://code.jquery.com/jquery.min.js`
puts "Downloading jquery.min.map"
puts `curl -o vendor/assets/javascripts/jquery.min.map http://code.jquery.com/jquery.min.map`
def download_jquery(filename, version)
suffix = "-#{version}"
puts "Updating version.rb"
version = false
File.foreach('vendor/assets/javascripts/jquery.js') do |line|
version = line.match(/jQuery JavaScript Library v([\S]+)/)
version = version && version[1]
break if version
end
version_path = 'lib/jquery/rails/version.rb'
lines = IO.readlines(version_path).map do |line|
line.gsub(/JQUERY_VERSION = "([\d\.]+)"/, "JQUERY_VERSION = \"#{version}\"")
end
File.open(version_path, 'w') do |file|
file.puts lines
puts "Downloading #{filename}.js"
puts `curl -o vendor/assets/javascripts/#{filename}.js http://code.jquery.com/jquery#{suffix}.js`
puts "Downloading #{filename}.min.js"
puts `curl -o vendor/assets/javascripts/#{filename}.min.js http://code.jquery.com/jquery#{suffix}.min.js`
puts "Downloading #{filename}.min.map"
puts `curl -o vendor/assets/javascripts/#{filename}.min.map http://code.jquery.com/jquery#{suffix}.min.map`
end
download_jquery('jquery', Jquery::Rails::JQUERY_VERSION)
download_jquery('jquery2', Jquery::Rails::JQUERY_2_VERSION)
puts "\e[32mDone!\e[0m"
end

View File

@@ -2,6 +2,7 @@ module Jquery
module Rails
VERSION = "4.0.0.alpha"
JQUERY_VERSION = "1.11.1"
JQUERY_2_VERSION = "2.1.1"
JQUERY_UJS_VERSION = "1.0.1"
end
end