mirror of
https://github.com/rails/jquery-rails.git
synced 2026-01-10 15:17:54 -05:00
Improve the update task to download jQuery 2 as well.
This commit is contained in:
31
Rakefile
31
Rakefile
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user