Skip to content

Commit

Permalink
Improve the update task to download jQuery 2 as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmazza committed Sep 1, 2014
1 parent 35d96fb commit c3dc6f3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
33 changes: 12 additions & 21 deletions Rakefile
Expand Up @@ -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`

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
def download_jquery(filename, version)
suffix = "-#{version}"

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
1 change: 1 addition & 0 deletions lib/jquery/rails/version.rb
Expand Up @@ -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

0 comments on commit c3dc6f3

Please sign in to comment.