desc "Update to the latest version of Highcharts" task :update, :version do |t, args| version = args[:version] url = "http://code.highcharts.com/zips/Highcharts-#{version}.zip" puts "Fetching #{url}" #`curl -# #{url} -o tmp/#{version}.zip` #`unzip tmp/#{version}.zip -d tmp/#{version}` mappings = { "highcharts.src.js" => "highcharts.js", "highcharts-more.src.js" => "highcharts/highcharts-more.js", "mootools-adapter.src.js" => "highcharts/adapters/mootools.js", "prototype-adapter.src.js" => "highcharts/adapters/prototype.js", "annotations.src.js" => "highcharts/modules/annotations.js", "canvas-tools.src.js" => "highcharts/modules/canvas-tools.js", "data.src.js" => "highcharts/modules/data.js", "exporting.src.js" => "highcharts/modules/exporting.js", "funnel.src.js" => "highcharts/modules/funnel.js", "heatmap.src.js" => "highcharts/modules/heatmap.js", "map.src.js" => "highcharts/modules/map.js", } dest = "app/assets/javascripts/" Dir.glob("tmp/#{version}/js/**/*.src.js").each do |file| name = File.basename(file) FileUtils.cp file, "#{dest}#{mappings[name]}", verbose: true end FileUtils.cp Dir.glob("tmp/#{version}/js/themes/*.js"), "#{dest}highcharts/themes/", verbose: true FileUtils.cp Dir.glob("tmp/#{version}/graphics/*.png"), "app/assets/images/highcharts", verbose: true end