lib/tasks/cloudinary/fetch_assets.rake in cloudinary-1.29.0 vs lib/tasks/cloudinary/fetch_assets.rake in cloudinary-2.0.0

- old
+ new

@@ -1,27 +1,33 @@ require 'tmpdir' -require 'rest_client' +require 'faraday' +require 'faraday/follow_redirects' require 'json' require 'rubygems/package' +require 'stringio' unless Rake::Task.task_defined?('cloudinary:fetch_assets') # prevent double-loading/execution namespace :cloudinary do desc "Fetch the latest JavaScript library files and create the JavaScript index files" task :fetch_assets do index_files = %w[jquery.ui.widget.js jquery.iframe-transport.js jquery.fileupload.js jquery.cloudinary.js] processing_files = %w[canvas-to-blob.min.js load-image.all.min.js jquery.fileupload-process.js jquery.fileupload-image.js jquery.fileupload-validate.js] files = index_files + processing_files - release = JSON(RestClient.get("https://api.github.com/repos/cloudinary/cloudinary_js/releases/latest")) + release = JSON(Faraday.get("https://api.github.com/repos/cloudinary/cloudinary_js/releases/latest").body) FileUtils.rm_rf 'vendor/assets' html_folder = 'vendor/assets/html' FileUtils.mkdir_p html_folder js_folder = 'vendor/assets/javascripts/cloudinary' FileUtils.mkdir_p js_folder puts "Fetching cloudinary_js version #{release["tag_name"]}\n\n" - sio = StringIO.new(RestClient.get(release["tarball_url"]).body) + conn = Faraday.new do |faraday| + faraday.response :follow_redirects + faraday.adapter Faraday.default_adapter + end + sio = StringIO.new(conn.get(release["tarball_url"]).body) file = Zlib::GzipReader.new(sio) tar = Gem::Package::TarReader.new(file) tar.each_entry do |entry| name = File.basename(entry.full_name) if files.include? name