cloudinary 1.12.0 → 1.13.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/lib/active_storage/service/cloudinary_service.rb +15 -7
- data/lib/cloudinary/carrier_wave.rb +2 -1
- data/lib/cloudinary/helper.rb +30 -3
- data/lib/cloudinary/version.rb +1 -1
- data/spec/active_storage/service/cloudinary_service_spec.rb +16 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e5827b8b849956cb26923c951ff72b205ff34e898309513ec1a18eca3abd47f
|
4
|
+
data.tar.gz: 53acb20dcbd39a0dfa3d99c912c128e0731950893066a102bda1e4d267c1ebc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efd2057b536c8bbd339efce5046e23a1ee9d8c35cd398354f1ec3d72dcb98f9f2c0d7696441097b9e9de576dd98ae97c594e0368937f9ff60a52c5cd6556e98a
|
7
|
+
data.tar.gz: 19215c9db03f24c24b24aabfaf1bb887eaac5bd2c493890e2426a8523503c3235de85be0a3a243ce2ac31b52c8463f5ce4ef7f1db5775a06082436dc1610baca
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
|
2
|
+
1.13.0 / 2019-11-14
|
3
|
+
===================
|
4
|
+
|
5
|
+
New functionality and features
|
6
|
+
------------------------------
|
7
|
+
* Add `SassC` `cloudinary-url` function
|
8
|
+
|
9
|
+
Other Changes
|
10
|
+
-------------
|
11
|
+
|
12
|
+
* Fix ActiveStorage download not using `ssl` for `https`
|
13
|
+
* Fix resource type detection in ActiveStorage
|
14
|
+
* Fix `storage_type` instance method in `Cloudinary::CarrierWave` module
|
15
|
+
* Fix sample project, limit sqlite3 to a compatible version
|
16
|
+
|
1
17
|
1.12.0 / 2019-10-02
|
2
18
|
=============
|
3
19
|
|
@@ -102,12 +102,11 @@ module ActiveStorage
|
|
102
102
|
uri = URI(url)
|
103
103
|
if block_given?
|
104
104
|
instrument :streaming_download, key: key do
|
105
|
-
Net::HTTP.start(uri.host, uri.port) do |http|
|
105
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
106
106
|
request = Net::HTTP::Get.new uri
|
107
107
|
http.request request do |response|
|
108
108
|
response.read_body &block
|
109
109
|
end
|
110
|
-
|
111
110
|
end
|
112
111
|
end
|
113
112
|
else
|
@@ -130,7 +129,7 @@ module ActiveStorage
|
|
130
129
|
else range.end
|
131
130
|
end
|
132
131
|
req['range'] = "bytes=#{[range.begin, range_end].join('-')}"
|
133
|
-
res = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
132
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
134
133
|
http.request(req)
|
135
134
|
end
|
136
135
|
res.body.force_encoding(Encoding::BINARY)
|
@@ -165,14 +164,23 @@ module ActiveStorage
|
|
165
164
|
end
|
166
165
|
|
167
166
|
def resource_type(io, key = "")
|
168
|
-
|
169
|
-
options = key.attributes
|
167
|
+
options = key.respond_to?(:attributes) ? key.attributes : {}
|
170
168
|
content_type = options[:content_type] || (io.nil? ? '' : Marcel::MimeType.for(io))
|
171
|
-
|
172
|
-
|
169
|
+
type, subtype = content_type.split('/')
|
170
|
+
case type
|
171
|
+
when 'video', 'audio'
|
173
172
|
'video'
|
174
173
|
when 'text'
|
175
174
|
'raw'
|
175
|
+
when 'application'
|
176
|
+
case subtype
|
177
|
+
when 'pdf', 'postscript'
|
178
|
+
'image'
|
179
|
+
when 'vnd.apple.mpegurl', 'x-mpegurl', 'mpegurl' # m3u8
|
180
|
+
'video'
|
181
|
+
else
|
182
|
+
'raw'
|
183
|
+
end
|
176
184
|
else
|
177
185
|
'image'
|
178
186
|
end
|
@@ -10,7 +10,8 @@ module Cloudinary::CarrierWave
|
|
10
10
|
def self.included(base)
|
11
11
|
base.storage Cloudinary::CarrierWave::Storage
|
12
12
|
base.extend ClassMethods
|
13
|
-
base.class_attribute :
|
13
|
+
base.class_attribute :metadata
|
14
|
+
base.class_attribute :storage_type, instance_reader: false
|
14
15
|
override_in_versions(base, :blank?, :full_public_id, :my_public_id, :all_versions_processors, :stored_version)
|
15
16
|
end
|
16
17
|
|
data/lib/cloudinary/helper.rb
CHANGED
@@ -286,7 +286,7 @@ module CloudinaryHelper
|
|
286
286
|
Cloudinary::Utils.private_download_url(public_id, format, options)
|
287
287
|
end
|
288
288
|
|
289
|
-
# Helper method that uses the deprecated ZIP download API.
|
289
|
+
# Helper method that uses the deprecated ZIP download API.
|
290
290
|
# Replaced by cl_download_zip_url that uses the more advanced and robust archive generation and download API
|
291
291
|
# @deprecated
|
292
292
|
def cl_zip_download_url(tag, options = {})
|
@@ -296,7 +296,7 @@ module CloudinaryHelper
|
|
296
296
|
# @see {Cloudinary::Utils.download_archive_url}
|
297
297
|
def cl_download_archive_url(options = {})
|
298
298
|
Cloudinary::Utils.download_archive_url(options)
|
299
|
-
end
|
299
|
+
end
|
300
300
|
|
301
301
|
# @see {Cloudinary::Utils.download_zip_url}
|
302
302
|
def cl_download_zip_url(options = {})
|
@@ -318,7 +318,7 @@ module CloudinaryHelper
|
|
318
318
|
if Cloudinary.config.enhance_image_tag
|
319
319
|
alias_method :image_tag, :image_tag_with_cloudinary
|
320
320
|
alias_method :image_path, :image_path_with_cloudinary
|
321
|
-
end
|
321
|
+
end
|
322
322
|
end
|
323
323
|
end
|
324
324
|
|
@@ -419,3 +419,30 @@ rescue LoadError
|
|
419
419
|
# no sass support. Ignore.
|
420
420
|
end
|
421
421
|
|
422
|
+
begin
|
423
|
+
require 'sassc'
|
424
|
+
require 'sassc/script/functions'
|
425
|
+
module SassC::Script::Functions
|
426
|
+
# Helper method for generating cloudinary_url in scss files.
|
427
|
+
#
|
428
|
+
# As opposed to sass(deprecated), optional named arguments are not supported, use hash map instead.
|
429
|
+
#
|
430
|
+
# Example:
|
431
|
+
# Sass: cloudinary-url("sample", $quality: "auto", $fetch_format: "auto");
|
432
|
+
# becomes
|
433
|
+
# SassC: cloudinary-url("sample", ("quality": "auto", "fetch_format": "auto"));
|
434
|
+
#
|
435
|
+
# @param [::SassC::Script::Value::String] public_id The public ID of the resource
|
436
|
+
# @param [::SassC::Script::Value::Map] sass_options Additional options
|
437
|
+
#
|
438
|
+
# @return [::SassC::Script::Value::String]
|
439
|
+
def cloudinary_url(public_id, sass_options = {})
|
440
|
+
options = {}
|
441
|
+
sass_options.to_h.each { |k, v| options[k.value] = v.value }
|
442
|
+
url = Cloudinary::Utils.cloudinary_url(public_id.value, {:type => :asset}.merge(options))
|
443
|
+
::SassC::Script::Value::String.new("url(#{url})")
|
444
|
+
end
|
445
|
+
end
|
446
|
+
rescue LoadError
|
447
|
+
# no sassc support. Ignore.
|
448
|
+
end
|
data/lib/cloudinary/version.rb
CHANGED
@@ -7,13 +7,17 @@ if RUBY_VERSION > '2.2.2'
|
|
7
7
|
CONFIGURATION_PATH = Pathname.new(File.expand_path("service/configurations.yml", __dir__))
|
8
8
|
SERVICE = ActiveStorage::Service.configure(:cloudinary, SERVICE_CONFIGURATIONS)
|
9
9
|
|
10
|
+
TEST_IMG_PATH = Pathname.new(TEST_IMG)
|
11
|
+
TEST_VIDEO_PATH = Pathname.new(TEST_VIDEO)
|
12
|
+
TEST_RAW_PATH = Pathname.new(TEST_RAW)
|
13
|
+
|
10
14
|
describe 'active_storage' do
|
11
15
|
let(:key) {ActiveStorage::BlobKey.new({key: SecureRandom.base58(24), filename: BASENAME})}
|
12
16
|
|
13
17
|
before :all do
|
14
18
|
@key = ActiveStorage::BlobKey.new key: SecureRandom.base58(24), filename: BASENAME
|
15
19
|
@service = self.class.const_get(:SERVICE)
|
16
|
-
@service.upload @key,
|
20
|
+
@service.upload @key, TEST_IMG_PATH, tags: [TEST_TAG, TIMESTAMP_TAG, AS_TAG]
|
17
21
|
end
|
18
22
|
|
19
23
|
after :all do
|
@@ -88,5 +92,16 @@ if RUBY_VERSION > '2.2.2'
|
|
88
92
|
expect(Cloudinary::Uploader).to receive(:upload).with(TEST_IMG, hash_including(tags: override_tags))
|
89
93
|
@service.upload(key, TEST_IMG, tags: override_tags)
|
90
94
|
end
|
95
|
+
|
96
|
+
it "should correctly identify resource_type" do
|
97
|
+
expect(Cloudinary::Uploader).to receive(:upload).with(TEST_IMG_PATH, hash_including(resource_type: 'image'))
|
98
|
+
@service.upload(key, TEST_IMG_PATH)
|
99
|
+
|
100
|
+
expect(Cloudinary::Uploader).to receive(:upload).with(TEST_VIDEO_PATH, hash_including(resource_type: 'video'))
|
101
|
+
@service.upload(key, TEST_VIDEO_PATH)
|
102
|
+
|
103
|
+
expect(Cloudinary::Uploader).to receive(:upload).with(TEST_RAW_PATH, hash_including(resource_type: 'raw'))
|
104
|
+
@service.upload(key, TEST_RAW_PATH)
|
105
|
+
end
|
91
106
|
end
|
92
107
|
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: 1.
|
4
|
+
version: 1.13.0
|
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: 2019-
|
13
|
+
date: 2019-11-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: aws_cf_signer
|
@@ -342,8 +342,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
342
342
|
- !ruby/object:Gem::Version
|
343
343
|
version: '0'
|
344
344
|
requirements: []
|
345
|
-
|
346
|
-
rubygems_version: 2.7.10
|
345
|
+
rubygems_version: 3.0.6
|
347
346
|
signing_key:
|
348
347
|
specification_version: 4
|
349
348
|
summary: Client library for easily using the Cloudinary service
|