cloudinary 1.29.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,83 +1,53 @@
1
1
  # Copyright Cloudinary
2
- require 'rest_client'
2
+ require 'faraday'
3
3
  require 'json'
4
4
  require 'cloudinary/cache'
5
5
 
6
6
  class Cloudinary::Uploader
7
-
8
- REMOTE_URL_REGEX = Cloudinary::Utils::REMOTE_URL_REGEX
9
- # @deprecated use {Cloudinary::Utils.build_eager} instead
10
- def self.build_eager(eager)
11
- Cloudinary::Utils.build_eager(eager)
12
- end
13
-
14
- # @private
15
- def self.build_upload_params(options)
7
+ @adapter = nil
8
+ def self.build_upload_params(options, as_bool = false)
16
9
  #symbolize keys
17
10
  options = options.clone
18
11
  options.keys.each { |key| options[key.to_sym] = options.delete(key) if key.is_a?(String) }
19
12
 
20
13
  params = {
21
- :access_control => Cloudinary::Utils.json_array_param(options[:access_control]),
22
- :access_mode => options[:access_mode],
23
- :allowed_formats => Cloudinary::Utils.build_array(options[:allowed_formats]).join(","),
24
- :asset_folder => options[:asset_folder],
25
- :async => Cloudinary::Utils.as_safe_bool(options[:async]),
26
- :auto_tagging => options[:auto_tagging] && options[:auto_tagging].to_f,
27
- :background_removal => options[:background_removal],
28
- :backup => Cloudinary::Utils.as_safe_bool(options[:backup]),
29
- :callback => options[:callback],
30
- :categorization => options[:categorization],
31
- :cinemagraph_analysis => Cloudinary::Utils.as_safe_bool(options[:cinemagraph_analysis]),
32
- :colors => Cloudinary::Utils.as_safe_bool(options[:colors]),
33
- :context => Cloudinary::Utils.encode_context(options[:context]),
34
- :custom_coordinates => Cloudinary::Utils.encode_double_array(options[:custom_coordinates]),
35
- :detection => options[:detection],
36
- :discard_original_filename => Cloudinary::Utils.as_safe_bool(options[:discard_original_filename]),
37
- :display_name => options[:display_name],
38
- :eager => Cloudinary::Utils.build_eager(options[:eager]),
39
- :eager_async => Cloudinary::Utils.as_safe_bool(options[:eager_async]),
40
- :eager_notification_url => options[:eager_notification_url],
41
- :exif => Cloudinary::Utils.as_safe_bool(options[:exif]),
42
- :eval => options[:eval],
43
- :on_success => options[:on_success],
44
- :face_coordinates => Cloudinary::Utils.encode_double_array(options[:face_coordinates]),
45
- :faces => Cloudinary::Utils.as_safe_bool(options[:faces]),
46
- :folder => options[:folder],
47
- :format => options[:format],
48
- :filename_override => options[:filename_override],
49
- :headers => build_custom_headers(options[:headers]),
50
- :image_metadata => Cloudinary::Utils.as_safe_bool(options[:image_metadata]),
51
- :media_metadata => Cloudinary::Utils.as_safe_bool(options[:media_metadata]),
52
- :invalidate => Cloudinary::Utils.as_safe_bool(options[:invalidate]),
53
- :moderation => options[:moderation],
54
- :notification_url => options[:notification_url],
55
- :ocr => options[:ocr],
56
- :overwrite => Cloudinary::Utils.as_safe_bool(options[:overwrite]),
57
- :phash => Cloudinary::Utils.as_safe_bool(options[:phash]),
58
- :proxy => options[:proxy],
59
- :public_id => options[:public_id],
60
- :public_id_prefix => options[:public_id_prefix],
61
- :quality_analysis => Cloudinary::Utils.as_safe_bool(options[:quality_analysis]),
62
- :quality_override => options[:quality_override],
63
- :raw_convert => options[:raw_convert],
64
- :responsive_breakpoints => Cloudinary::Utils.generate_responsive_breakpoints_string(options[:responsive_breakpoints]),
65
- :return_delete_token => Cloudinary::Utils.as_safe_bool(options[:return_delete_token]),
66
- :similarity_search => options[:similarity_search],
67
- :visual_search => Cloudinary::Utils.as_safe_bool(options[:visual_search]),
68
- :tags => options[:tags] && Cloudinary::Utils.build_array(options[:tags]).join(","),
69
- :timestamp => (options[:timestamp] || Time.now.to_i),
70
- :transformation => Cloudinary::Utils.generate_transformation_string(options.clone),
71
- :type => options[:type],
72
- :unique_filename => Cloudinary::Utils.as_safe_bool(options[:unique_filename]),
73
- :upload_preset => options[:upload_preset],
74
- :use_filename => Cloudinary::Utils.as_safe_bool(options[:use_filename]),
75
- :use_filename_as_display_name => Cloudinary::Utils.as_safe_bool(options[:use_filename_as_display_name]),
76
- :use_asset_folder_as_public_id_prefix => Cloudinary::Utils.as_safe_bool(options[:use_asset_folder_as_public_id_prefix]),
77
- :unique_display_name => Cloudinary::Utils.as_safe_bool(options[:unique_display_name]),
78
- :accessibility_analysis => Cloudinary::Utils.as_safe_bool(options[:accessibility_analysis]),
79
- :metadata => Cloudinary::Utils.encode_context(options[:metadata])
14
+ :access_control => Cloudinary::Utils.json_array_param(options[:access_control]),
15
+ :allowed_formats => Cloudinary::Utils.build_array(options[:allowed_formats]).join(","),
16
+ :auto_tagging => options[:auto_tagging] && options[:auto_tagging].to_f,
17
+ :context => Cloudinary::Utils.encode_context(options[:context]),
18
+ :custom_coordinates => Cloudinary::Utils.encode_double_array(options[:custom_coordinates]),
19
+ :eager => Cloudinary::Utils.build_eager(options[:eager]),
20
+ :face_coordinates => Cloudinary::Utils.encode_double_array(options[:face_coordinates]),
21
+ :headers => build_custom_headers(options[:headers]),
22
+ :responsive_breakpoints => Cloudinary::Utils.generate_responsive_breakpoints_string(options[:responsive_breakpoints]),
23
+ :tags => options[:tags] && Cloudinary::Utils.build_array(options[:tags]).join(","),
24
+ :timestamp => (options[:timestamp] || Time.now.to_i),
25
+ :transformation => Cloudinary::Utils.generate_transformation_string(options.clone),
26
+ :metadata => Cloudinary::Utils.encode_context(options[:metadata])
80
27
  }
28
+
29
+ bool_params = [
30
+ :async, :backup, :cinemagraph_analysis, :colors, :discard_original_filename, :eager_async, :exif, :faces,
31
+ :image_metadata, :media_metadata, :invalidate, :overwrite, :phash, :quality_analysis, :return_delete_token,
32
+ :visual_search, :unique_filename, :use_filename, :use_filename_as_display_name,
33
+ :use_asset_folder_as_public_id_prefix, :unique_display_name, :accessibility_analysis
34
+ ]
35
+
36
+ string_params = [
37
+ :access_mode, :asset_folder, :background_removal, :callback, :categorization, :detection, :display_name,
38
+ :eager_notification_url, :eval, :on_success, :folder, :format, :filename_override, :moderation, :notification_url,
39
+ :ocr, :proxy, :public_id, :public_id_prefix, :quality_override, :raw_convert, :similarity_search, :type,
40
+ :upload_preset
41
+ ]
42
+
43
+ bool_params.each do |b|
44
+ params[b] = as_bool ? Cloudinary::Utils.as_bool(options[b]): Cloudinary::Utils.as_safe_bool(options[b])
45
+ end
46
+
47
+ string_params.each do |s|
48
+ params[s] = options[s]
49
+ end
50
+
81
51
  params
82
52
  end
83
53
 
@@ -394,29 +364,39 @@ class Cloudinary::Uploader
394
364
  params[:signature] = Cloudinary::Utils.api_sign_request(params.reject { |k, v| non_signable.include?(k) }, api_secret, signature_algorithm)
395
365
  params[:api_key] = api_key
396
366
  end
397
- proxy = options[:api_proxy] || Cloudinary.config.api_proxy
398
- timeout = options.fetch(:timeout) { Cloudinary.config.to_h.fetch(:timeout, 60) }
399
-
400
- result = nil
401
-
402
- api_url = Cloudinary::Utils.cloudinary_api_url(action, options)
403
- RestClient::Request.execute(:method => :post, :url => api_url, :payload => params.reject { |k, v| v.nil? || v=="" }, :timeout => timeout, :headers => headers, :proxy => proxy) do
404
- |response, request, tmpresult|
405
- raise CloudinaryException, "Server returned unexpected status code - #{response.code} - #{response.body}" unless [200, 400, 401, 403, 404, 500].include?(response.code)
406
- begin
407
- result = Cloudinary::Utils.json_decode(response.body)
408
- rescue => e
409
- # Error is parsing json
410
- raise CloudinaryException, "Error parsing server response (#{response.code}) - #{response.body}. Got - #{e}"
411
- end
412
- if result["error"]
413
- if return_error
414
- result["error"]["http_code"] = response.code
415
- else
416
- raise CloudinaryException, result["error"]["message"]
417
- end
367
+
368
+ api_url = Cloudinary::Utils.cloudinary_api_url(action, options)
369
+ api_proxy = options[:api_proxy] || Cloudinary.config.api_proxy
370
+ timeout = options.fetch(:timeout) { Cloudinary.config.to_h.fetch(:timeout, 60) }
371
+
372
+ conn = Faraday.new(url: api_url) do |faraday|
373
+ faraday.proxy = api_proxy if api_proxy
374
+ faraday.request :multipart, **options
375
+ faraday.request :url_encoded
376
+ faraday.adapter @adapter || Faraday.default_adapter
377
+ end
378
+
379
+ response = conn.send(:post) do |req|
380
+ req.headers = headers
381
+ req.body = params.reject { |_, v| v.nil? || v=="" }
382
+ req.options.timeout = timeout if timeout
383
+ end
384
+
385
+ raise CloudinaryException, "Server returned unexpected status code - #{response.status} - #{response.body}" unless [200, 400, 401, 403, 404, 500].include?(response.status)
386
+ begin
387
+ result = Cloudinary::Utils.json_decode(response.body)
388
+ rescue => e
389
+ # Error is parsing json
390
+ raise CloudinaryException, "Error parsing server response (#{response.status}) - #{response.body}. Got - #{e}"
391
+ end
392
+ if result["error"]
393
+ if return_error
394
+ result["error"]["http_code"] = response.status
395
+ else
396
+ raise CloudinaryException, result["error"]["message"]
418
397
  end
419
398
  end
399
+
420
400
  if use_cache && !result.nil?
421
401
  cache_results(result)
422
402
  end
@@ -4,15 +4,14 @@
4
4
  require 'digest/sha1'
5
5
  require 'zlib'
6
6
  require 'uri'
7
- require 'aws_cf_signer'
8
7
  require 'json'
9
8
  require 'cgi'
9
+ require 'faraday'
10
+ require 'faraday/multipart'
10
11
  require 'cloudinary/auth_token'
11
12
  require 'cloudinary/responsive'
12
13
 
13
14
  class Cloudinary::Utils
14
- # @deprecated Use Cloudinary::SHARED_CDN
15
- SHARED_CDN = Cloudinary::SHARED_CDN
16
15
  MODE_DOWNLOAD = "download"
17
16
  DEFAULT_RESPONSIVE_WIDTH_TRANSFORMATION = {:width => :auto, :crop => :limit}
18
17
  CONDITIONAL_OPERATORS = {
@@ -98,7 +97,6 @@ class Cloudinary::Utils
98
97
  secure_distribution
99
98
  shorten
100
99
  sign_url
101
- ssl_detected
102
100
  type
103
101
  url_suffix
104
102
  use_root_path
@@ -155,7 +153,7 @@ class Cloudinary::Utils
155
153
  zoom
156
154
  ].map(&:to_sym)
157
155
 
158
- REMOTE_URL_REGEX = %r(^ftp:|^https?:|^s3:|^gs:|^data:([\w-]+\/[\w-]+(\+[\w-]+)?)?(;[\w-]+=[\w-]+)*;base64,([a-zA-Z0-9\/+\n=]+)$)
156
+ REMOTE_URL_REGEX = %r(^ftp:|^https?:|^s3:|^gs:|^data:([\w-]+\/[\w-]+(\.[\w-]+)*(\+[\w-]+)?)?(;[\w-]+=[\w-]+)*;base64,([a-zA-Z0-9\/+\n=]+)$)
159
157
 
160
158
  LONG_URL_SIGNATURE_LENGTH = 32
161
159
  SHORT_URL_SIGNATURE_LENGTH = 8
@@ -513,7 +511,7 @@ class Cloudinary::Utils
513
511
  end
514
512
 
515
513
  # Warning: options are being destructively updated!
516
- def self.unsigned_download_url(source, options = {})
514
+ def self.cloudinary_url(source, options = {})
517
515
 
518
516
  patch_fetch_format(options)
519
517
  type = options.delete(:type)
@@ -530,7 +528,6 @@ class Cloudinary::Utils
530
528
 
531
529
  sign_url = config_option_consume(options, :sign_url)
532
530
  secret = config_option_consume(options, :api_secret)
533
- sign_version = config_option_consume(options, :sign_version) # Deprecated behavior
534
531
  url_suffix = options.delete(:url_suffix)
535
532
  use_root_path = config_option_consume(options, :use_root_path)
536
533
  auth_token = config_option_consume(options, :auth_token)
@@ -578,7 +575,7 @@ class Cloudinary::Utils
578
575
  transformation = transformation.gsub(%r(([^:])//), '\1/')
579
576
  if sign_url && ( !auth_token || auth_token.empty?)
580
577
  raise(CloudinaryException, "Must supply api_secret") if (secret.nil? || secret.empty?)
581
- to_sign = [transformation, sign_version && version, source_to_sign].reject(&:blank?).join("/")
578
+ to_sign = [transformation, source_to_sign].reject(&:blank?).join("/")
582
579
  to_sign = fully_unescape(to_sign)
583
580
  signature_algorithm = long_url_signature ? ALGO_SHA256 : signature_algorithm
584
581
  hash = hash("#{to_sign}#{secret}", signature_algorithm)
@@ -590,12 +587,22 @@ class Cloudinary::Utils
590
587
  prefix = build_distribution_domain(options)
591
588
 
592
589
  source = [prefix, resource_type, type, signature, transformation, version, source].reject(&:blank?).join("/")
590
+
591
+ token = nil
593
592
  if sign_url && auth_token && !auth_token.empty?
594
593
  auth_token[:url] = URI.parse(source).path
595
594
  token = Cloudinary::AuthToken.generate auth_token
596
- source += "?#{token}"
597
595
  end
598
596
 
597
+ analytics = config_option_consume(options, :analytics, true)
598
+ analytics_token = nil
599
+ if analytics && ! original_source.include?("?") # Disable analytics for public IDs containing query params.
600
+ analytics_token = Cloudinary::Analytics.sdk_analytics_query_param
601
+ end
602
+
603
+ query_params = [token, analytics_token].compact.join("&")
604
+
605
+ source += "?#{query_params}" unless query_params.empty?
599
606
  source
600
607
  end
601
608
 
@@ -678,7 +685,7 @@ class Cloudinary::Utils
678
685
  shared_domain = !private_cdn
679
686
 
680
687
  if secure
681
- if secure_distribution.nil? || secure_distribution == Cloudinary::OLD_AKAMAI_SHARED_CDN
688
+ if secure_distribution.nil?
682
689
  secure_distribution = private_cdn ? "#{cloud_name}-res.cloudinary.com" : Cloudinary::SHARED_CDN
683
690
  end
684
691
  shared_domain ||= secure_distribution == Cloudinary::SHARED_CDN
@@ -705,9 +712,7 @@ class Cloudinary::Utils
705
712
  cloud_name = config_option_consume(options, :cloud_name) || raise(CloudinaryException, "Must supply cloud_name in tag or in configuration")
706
713
 
707
714
  source = options.delete(:source)
708
- secure = options.delete(:secure)
709
- ssl_detected = options.delete(:ssl_detected)
710
- secure = ssl_detected || Cloudinary.config.secure if secure.nil?
715
+ secure = config_option_consume(options, :secure, true)
711
716
  private_cdn = config_option_consume(options, :private_cdn)
712
717
  secure_distribution = config_option_consume(options, :secure_distribution)
713
718
  cname = config_option_consume(options, :cname)
@@ -726,8 +731,9 @@ class Cloudinary::Utils
726
731
  def self.base_api_url(path, options = {})
727
732
  cloudinary = options[:upload_prefix] || Cloudinary.config.upload_prefix || UPLOAD_PREFIX
728
733
  cloud_name = options[:cloud_name] || Cloudinary.config.cloud_name || raise(CloudinaryException, 'Must supply cloud_name')
734
+ api_version = options[:api_version] || Cloudinary.config.api_version || 'v1_1'
729
735
 
730
- [cloudinary, 'v1_1', cloud_name, path].join('/')
736
+ [cloudinary, api_version, cloud_name, path].join('/')
731
737
  end
732
738
 
733
739
  def self.cloudinary_api_url(action = 'upload', options = {})
@@ -796,14 +802,6 @@ class Cloudinary::Utils
796
802
  return Cloudinary::Utils.cloudinary_api_url("download", options) + "?" + hash_query_params(cloudinary_params)
797
803
  end
798
804
 
799
- # Utility method that uses the deprecated ZIP download API.
800
- # @deprecated Replaced by {download_zip_url} that uses the more advanced and robust archive generation and download API
801
- def self.zip_download_url(tag, options = {})
802
- warn "zip_download_url is deprecated. Please use download_zip_url instead."
803
- cloudinary_params = sign_request({:timestamp=>Time.now.to_i, :tag=>tag, :transformation=>generate_transformation_string(options)}, options)
804
- return Cloudinary::Utils.cloudinary_api_url("download_tag.zip", options) + "?" + hash_query_params(cloudinary_params)
805
- end
806
-
807
805
  # Returns a URL that when invokes creates an archive and returns it.
808
806
  # @param options [Hash]
809
807
  # @option options [String|Symbol] :resource_type The resource type of files to include in the archive. Must be one of :image | :video | :raw
@@ -853,31 +851,6 @@ class Cloudinary::Utils
853
851
  download_archive_url(options.merge(:resource_type => resource_type, :prefixes => folder_path))
854
852
  end
855
853
 
856
- def self.signed_download_url(public_id, options = {})
857
- aws_private_key_path = options[:aws_private_key_path] || Cloudinary.config.aws_private_key_path
858
- if aws_private_key_path
859
- aws_key_pair_id = options[:aws_key_pair_id] || Cloudinary.config.aws_key_pair_id || raise(CloudinaryException, "Must supply aws_key_pair_id")
860
- authenticated_distribution = options[:authenticated_distribution] || Cloudinary.config.authenticated_distribution || raise(CloudinaryException, "Must supply authenticated_distribution")
861
- @signers ||= Hash.new{|h,k| path, id = k; h[k] = AwsCfSigner.new(path, id)}
862
- signer = @signers[[aws_private_key_path, aws_key_pair_id]]
863
- url = Cloudinary::Utils.unsigned_download_url(public_id, {:type=>:authenticated}.merge(options).merge(:secure=>true, :secure_distribution=>authenticated_distribution, :private_cdn=>true))
864
- expires_at = options[:expires_at] || (Time.now+3600)
865
- return signer.sign(url, :ending => expires_at)
866
- else
867
- return Cloudinary::Utils.unsigned_download_url( public_id, options)
868
- end
869
-
870
- end
871
-
872
- def self.cloudinary_url(public_id, options = {})
873
- if options[:type].to_s == 'authenticated' && !options[:sign_url]
874
- result = signed_download_url(public_id, options)
875
- else
876
- result = unsigned_download_url(public_id, options)
877
- end
878
- return result
879
- end
880
-
881
854
  def self.asset_file_name(path)
882
855
  data = Cloudinary.app_root.join(path).read(:mode=>"rb")
883
856
  ext = path.extname
@@ -1305,22 +1278,26 @@ class Cloudinary::Utils
1305
1278
  # Handles file parameter.
1306
1279
  #
1307
1280
  # @param [Pathname, StringIO, File, String, int, _ToPath] file
1308
- # @return [StringIO, File] A File object.
1281
+ # @return [StringIO, File, String] A File object.
1309
1282
  #
1310
1283
  # @private
1311
1284
  def self.handle_file_param(file, options = {})
1285
+ original_filename = options[:original_filename] || "cloudinaryfile"
1286
+ content_type = options[:content_type] || "application/octet-stream"
1312
1287
  if file.is_a?(Pathname)
1313
- return File.open(file, "rb")
1288
+ return Faraday::FilePart.new(file.to_s, content_type)
1314
1289
  elsif file.is_a?(Cloudinary::Blob)
1315
- return file
1290
+ return Faraday::FilePart.new(file, file.content_type, file.original_filename)
1316
1291
  elsif file.is_a?(StringIO)
1317
1292
  file.rewind
1318
- return Cloudinary::Blob.new(file.read, options)
1319
- elsif file.respond_to?(:read) || Cloudinary::Utils.is_remote?(file)
1320
- return file
1293
+ return Faraday::FilePart.new(file, content_type, original_filename)
1294
+ elsif file.respond_to?(:read)
1295
+ return Faraday::FilePart.new(file, content_type, original_filename)
1296
+ elsif Cloudinary::Utils.is_remote?(file)
1297
+ return file.to_s
1321
1298
  end
1322
-
1323
- File.open(file, "rb")
1299
+ # we got file path
1300
+ Faraday::FilePart.new(file.to_s, content_type)
1324
1301
  end
1325
1302
 
1326
1303
  # The returned url should allow downloading the backedup asset based on the version and asset id
@@ -1,4 +1,4 @@
1
1
  # Copyright Cloudinary
2
2
  module Cloudinary
3
- VERSION = "1.29.0"
3
+ VERSION = "2.3.0"
4
4
  end
data/lib/cloudinary.rb CHANGED
@@ -1,10 +1,6 @@
1
1
  # Copyright Cloudinary
2
- if RUBY_VERSION > "2"
3
- require "ostruct"
4
- else
5
- require "cloudinary/ostruct2"
6
- end
7
2
 
3
+ require "ostruct"
8
4
  require "pathname"
9
5
  require "yaml"
10
6
  require "uri"
@@ -29,11 +25,9 @@ module Cloudinary
29
25
  autoload :CarrierWave, "cloudinary/carrier_wave"
30
26
  autoload :Search, "cloudinary/search"
31
27
  autoload :SearchFolders, "cloudinary/search_folders"
28
+ autoload :Analytics, "cloudinary/analytics"
32
29
 
33
- CF_SHARED_CDN = "d3jpl91pxevbkh.cloudfront.net"
34
- AKAMAI_SHARED_CDN = "res.cloudinary.com"
35
- OLD_AKAMAI_SHARED_CDN = "cloudinary-a.akamaihd.net"
36
- SHARED_CDN = AKAMAI_SHARED_CDN
30
+ SHARED_CDN = "res.cloudinary.com"
37
31
 
38
32
  USER_AGENT = "CloudinaryRuby/#{VERSION} (Ruby #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL})"
39
33
  @@user_platform = defined?(Rails.version) ? "Rails/#{Rails.version}" : ""
@@ -1,7 +1,9 @@
1
1
  require 'tmpdir'
2
- require 'rest_client'
2
+ require 'faraday'
3
+ require 'faraday/follow_redirects'
3
4
  require 'json'
4
5
  require 'rubygems/package'
6
+ require 'stringio'
5
7
 
6
8
  unless Rake::Task.task_defined?('cloudinary:fetch_assets') # prevent double-loading/execution
7
9
  namespace :cloudinary do
@@ -11,7 +13,7 @@ unless Rake::Task.task_defined?('cloudinary:fetch_assets') # prevent double-load
11
13
  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]
12
14
  files = index_files + processing_files
13
15
 
14
- release = JSON(RestClient.get("https://api.github.com/repos/cloudinary/cloudinary_js/releases/latest"))
16
+ release = JSON(Faraday.get("https://api.github.com/repos/cloudinary/cloudinary_js/releases/latest").body)
15
17
 
16
18
  FileUtils.rm_rf 'vendor/assets'
17
19
  html_folder = 'vendor/assets/html'
@@ -20,7 +22,11 @@ unless Rake::Task.task_defined?('cloudinary:fetch_assets') # prevent double-load
20
22
  FileUtils.mkdir_p js_folder
21
23
 
22
24
  puts "Fetching cloudinary_js version #{release["tag_name"]}\n\n"
23
- sio = StringIO.new(RestClient.get(release["tarball_url"]).body)
25
+ conn = Faraday.new do |faraday|
26
+ faraday.response :follow_redirects
27
+ faraday.adapter Faraday.default_adapter
28
+ end
29
+ sio = StringIO.new(conn.get(release["tarball_url"]).body)
24
30
  file = Zlib::GzipReader.new(sio)
25
31
  tar = Gem::Package::TarReader.new(file)
26
32
  tar.each_entry do |entry|
@@ -422,7 +422,7 @@ var slice = [].slice,
422
422
  * @returns {boolean} true if item is empty
423
423
  */
424
424
  isEmpty = function(item) {
425
- return (item == null) || (jQuery.isArray(item) || Util.isString(item)) && item.length === 0 || (jQuery.isPlainObject(item) && jQuery.isEmptyObject(item));
425
+ return (item == null) || (Array.isArray(item) || Util.isString(item)) && item.length === 0 || (jQuery.isPlainObject(item) && jQuery.isEmptyObject(item));
426
426
  };
427
427
 
428
428
  /**
@@ -565,7 +565,7 @@ var slice = [].slice,
565
565
  setData: setData,
566
566
  width: width,
567
567
  isString: isString,
568
- isArray: jQuery.isArray,
568
+ isArray: Array.isArray,
569
569
  isEmpty: isEmpty,
570
570
 
571
571
  /**
@@ -4728,7 +4728,7 @@ var slice = [].slice,
4728
4728
  return k + '=' + v;
4729
4729
  }).join('|');
4730
4730
  } else if (Util.isArray(value)) {
4731
- if (value.length > 0 && jQuery.isArray(value[0])) {
4731
+ if (value.length > 0 && Array.isArray(value[0])) {
4732
4732
  upload_params[key] = jQuery.map(value, function(array_value) {
4733
4733
  return array_value.join(',');
4734
4734
  }).join('|');