cloudinary 2.0.2 → 2.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0eb913c34bb7e22bdd7c72d748ce67956a73923772932137b4b3c3e58b922df
4
- data.tar.gz: b2d8aac422d47d0777b132c87649379d0a9535a83a84245202fecbd477d06803
3
+ metadata.gz: 7c9fd54c62a8ad7408044ceb1be3178c98a250a3d874fc9b8f6f47f4e24b676c
4
+ data.tar.gz: 5b8b38c41734a1250c23f312e9afff293acddddc2ee86d506b1c0d0a16391520
5
5
  SHA512:
6
- metadata.gz: f224ae816b6485ae1abec08b6658037765139f46946f3679a4589083049d498121ff62a3af71f0d9b4ef2a918490dec0c3ffd0177439405037afe10e85138f06
7
- data.tar.gz: b6ad12381140938aa3f46342c36d0faba9350e9556e97d29c0a9db949d6e9bf84f709887072876cedd6e9190c60f141b96287db011aadef670717ceaae819e41
6
+ metadata.gz: a4d6c84719bb67ab74ce7575374bfcfee1e3364fa86df4734a7a4146777b05b0f233aa8b3962b6ef86222bf2e91ee1b59be16ba8b7c00166c54da16c875669d0
7
+ data.tar.gz: a3af6962c29d2112425b55170a90b63309b1d11418f380b8151988e96f0a8d895fc44a6d1615f4eb0b3eab1d0dfdd47f5fcf6e3d1e2adcd06f7be261e7634d39
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ 2.1.1 / 2024-05-28
2
+ ==================
3
+
4
+ * Fix regression in `cloudinary_url` generation
5
+
6
+ 2.1.0 / 2024-05-27
7
+ ==================
8
+
9
+ New functionality and features
10
+ ------------------------------
11
+
12
+ * Add support for `rename_folder` Admin API
13
+ * Add support for `delete_access_key` in Provisioning API
14
+
15
+ Other Changes
16
+ -------------
17
+
18
+ * Fix detection of base64 encoded files with complex MIME type
19
+ * Fix `fetch` url generation with Active Storage `folder` configuration
20
+ * Fix usage of deprecated `File.exists?` method
21
+
1
22
  2.0.2 / 2024-04-09
2
23
  ==================
3
24
 
@@ -17,7 +17,9 @@ module CloudinaryHelper
17
17
  alias cloudinary_url_internal_original cloudinary_url_internal
18
18
 
19
19
  def cloudinary_url_internal(source, options = {})
20
- source = ActiveStorage::Blob.service.public_id(source) if defined? ActiveStorage::Blob.service.public_id
20
+ if defined?(ActiveStorage::Blob.service.public_id) && options.fetch(:type, "").to_s != "fetch"
21
+ source = ActiveStorage::Blob.service.public_id(source)
22
+ end
21
23
  cloudinary_url_internal_original(source, options)
22
24
  end
23
25
  end
@@ -58,7 +60,7 @@ module ActiveStorage
58
60
  def url(key, filename: nil, content_type: '', **options)
59
61
  instrument :url, key: key do |payload|
60
62
  url = Cloudinary::Utils.cloudinary_url(
61
- full_public_id_internal(key),
63
+ full_public_id_internal(key, options),
62
64
  resource_type: resource_type(nil, key, content_type),
63
65
  format: ext_for_file(key, filename, content_type),
64
66
  **@options.merge(options.symbolize_keys)
@@ -231,10 +233,12 @@ module ActiveStorage
231
233
  end
232
234
 
233
235
  # Returns the full public id including folder.
234
- def full_public_id_internal(key)
236
+ def full_public_id_internal(key, options = {})
235
237
  public_id = public_id_internal(key)
236
238
 
237
- return public_id unless @options[:folder]
239
+ options = @options.merge(options)
240
+
241
+ return public_id if !options[:folder] || options.fetch(:type, "").to_s == "fetch"
238
242
 
239
243
  File.join(@options.fetch(:folder), public_id)
240
244
  end
@@ -260,6 +260,24 @@ class Cloudinary::AccountApi
260
260
  call_account_api(:put, ['sub_accounts', sub_account_id, 'access_keys', api_key], params, options.merge(content_type: :json))
261
261
  end
262
262
 
263
+ # Deletes access key.
264
+ #
265
+ # @param [String] sub_account_id The ID of the sub-account.
266
+ # @param [String, nil] api_key The API key.
267
+ # @param [String, nil] name The display name as shown in the management console.
268
+ # @param [Object] options Additional options.
269
+ def self.delete_access_key(sub_account_id, api_key = nil, name = nil, options = {})
270
+ uri = ['sub_accounts', sub_account_id, 'access_keys']
271
+ unless api_key.blank?
272
+ uri.append(api_key)
273
+ end
274
+
275
+ params = {
276
+ name: name,
277
+ }
278
+ call_account_api(:delete, uri, params, options.merge(content_type: :json))
279
+ end
280
+
263
281
  def self.call_account_api(method, uri, params, options)
264
282
  account_id = options[:account_id] || Cloudinary.account_config.account_id || raise('Must supply account_id')
265
283
  api_key = options[:provisioning_api_key] || Cloudinary.account_config.provisioning_api_key || raise('Must supply provisioning api_key')
@@ -731,6 +731,21 @@ class Cloudinary::Api
731
731
  call_api(:post, "folders/#{folder_name}", {}, options)
732
732
  end
733
733
 
734
+ # Renames existing asset folder.
735
+ #
736
+ # @param [String] from_path The full path of an existing asset folder.
737
+ # @param [String] to_path The full path of the new asset folder.
738
+ # @param [Hash] options The optional parameters.
739
+ #
740
+ # @return [Cloudinary::Api::Response]
741
+ #
742
+ # @raise [Cloudinary::Api::Error]
743
+ #
744
+ # @see https://cloudinary.com/documentation/admin_api#rename_folder
745
+ def self.rename_folder(from_path, to_path, options={})
746
+ call_api(:put, "folders/#{from_path}", {:to_folder => to_path}, options)
747
+ end
748
+
734
749
  # Lists upload mappings by folder and its mapped template (URL).
735
750
  #
736
751
  # @param [Hash] options The optional parameters. See the
@@ -179,7 +179,7 @@ module CloudinaryHelper
179
179
  version_store = options.delete(:version_store)
180
180
  if options[:version].blank? && (version_store == :file) && defined?(Rails) && defined?(Rails.root)
181
181
  file_name = "#{Rails.root}/tmp/cloudinary/cloudinary_sprite_#{source.sub(/\..*/, '')}.version"
182
- if File.exists?(file_name)
182
+ if File.exist?(file_name)
183
183
  options[:version] = File.read(file_name).chomp
184
184
  end
185
185
  end
@@ -153,7 +153,7 @@ class Cloudinary::Utils
153
153
  zoom
154
154
  ].map(&:to_sym)
155
155
 
156
- 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=]+)$)
157
157
 
158
158
  LONG_URL_SIGNATURE_LENGTH = 32
159
159
  SHORT_URL_SIGNATURE_LENGTH = 8
@@ -1,4 +1,4 @@
1
1
  # Copyright Cloudinary
2
2
  module Cloudinary
3
- VERSION = "2.0.2"
3
+ VERSION = "2.1.1"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudinary
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nadav Soferman
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-04-09 00:00:00.000000000 Z
13
+ date: 2024-05-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday