carrierwave 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of carrierwave might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +15 -5
- data/lib/carrierwave/downloader/base.rb +1 -1
- data/lib/carrierwave/mounter.rb +1 -1
- data/lib/carrierwave/processing/mini_magick.rb +1 -1
- data/lib/carrierwave/sanitized_file.rb +1 -1
- data/lib/carrierwave/storage/fog.rb +12 -4
- data/lib/carrierwave/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00606ed46f8982064ac5a4c9a4c84ec913d2844cb27ef3701ab8eef9f3379810
|
4
|
+
data.tar.gz: 66d28e5ffdb2c7d8c87f408847fa0a845e19fbe85559b01103e211d43e384e2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1a4033c04815846930764b92e49a1d9c15c3d54acbe8ab2caafc605d7b04dabf9409f97fa66efa9f533ac341ed6062b821997114408d7b963b022fbc1602bdf
|
7
|
+
data.tar.gz: 281fc8198bef5940ca8638a04888e44c2216688fee3e805da985f00dac7588830e8b50dd570484c5b0bf8a121e526c3aaa32981fcff4fd99b71a9b5bc2a72754
|
data/README.md
CHANGED
@@ -332,15 +332,13 @@ end
|
|
332
332
|
|
333
333
|
When this uploader is used, an uploaded image would be scaled to be no larger
|
334
334
|
than 800 by 800 pixels. The original aspect ratio will be kept.
|
335
|
-
A version called thumb is then created, which is scaled
|
336
|
-
to exactly 200 by 200 pixels.
|
337
335
|
|
338
|
-
|
339
|
-
|
336
|
+
A version called `:thumb` is then created, which is scaled
|
337
|
+
to exactly 200 by 200 pixels. The thumbnail uses `resize_to_fill` which makes sure
|
340
338
|
that the width and height specified are filled, only cropping
|
341
339
|
if the aspect ratio requires it.
|
342
340
|
|
343
|
-
The uploader could be used like this:
|
341
|
+
The above uploader could be used like this:
|
344
342
|
|
345
343
|
```ruby
|
346
344
|
uploader = AvatarUploader.new
|
@@ -353,6 +351,18 @@ uploader.thumb.url # => '/url/to/thumb_my_file.png' # size: 200x200
|
|
353
351
|
One important thing to remember is that process is called *before* versions are
|
354
352
|
created. This can cut down on processing cost.
|
355
353
|
|
354
|
+
### Processing Methods: mini_magick
|
355
|
+
|
356
|
+
- `convert` - Changes the image encoding format to the given format, eg. jpg
|
357
|
+
- `resize_to_limit` - Resize the image to fit within the specified dimensions while retaining the original aspect ratio. Will only resize the image if it is larger than the specified dimensions. The resulting image may be shorter or narrower than specified in the smaller dimension but will not be larger than the specified values.
|
358
|
+
- `resize_to_fit` - Resize the image to fit within the specified dimensions while retaining the original aspect ratio. The image may be shorter or narrower than specified in the smaller dimension but will not be larger than the specified values.
|
359
|
+
- `resize_to_fill` - Resize the image to fit within the specified dimensions while retaining the aspect ratio of the original image. If necessary, crop the image in the larger dimension. Optionally, a "gravity" may be specified, for example "Center", or "NorthEast".
|
360
|
+
- `resize_and_pad` - Resize the image to fit within the specified dimensions while retaining the original aspect ratio. If necessary, will pad the remaining area with the given color, which defaults to transparent (for gif and png, white for jpeg). Optionally, a "gravity" may be specified, as above.
|
361
|
+
|
362
|
+
See `carrierwave/processing/mini_magick.rb` for details.
|
363
|
+
|
364
|
+
### Nested versions
|
365
|
+
|
356
366
|
It is possible to nest versions within versions:
|
357
367
|
|
358
368
|
```ruby
|
@@ -40,7 +40,7 @@ module CarrierWave
|
|
40
40
|
def process_uri(uri)
|
41
41
|
uri_parts = uri.split('?')
|
42
42
|
encoded_uri = Addressable::URI.parse(uri_parts.shift).normalize.to_s
|
43
|
-
encoded_uri << '?' << URI.encode(uri_parts.join('?')) if uri_parts.any?
|
43
|
+
encoded_uri << '?' << Addressable::URI.encode(uri_parts.join('?')).gsub('%5B', '[').gsub('%5D', ']') if uri_parts.any?
|
44
44
|
URI.parse(encoded_uri)
|
45
45
|
rescue URI::InvalidURIError, Addressable::URI::InvalidURIError
|
46
46
|
raise CarrierWave::DownloadError, "couldn't parse URL: #{uri}"
|
data/lib/carrierwave/mounter.rb
CHANGED
@@ -297,7 +297,7 @@ module CarrierWave
|
|
297
297
|
|
298
298
|
# backwards compatibility (we want to eventually move away from MiniMagick::Image)
|
299
299
|
if block
|
300
|
-
image = MiniMagick::Image.new(result.path, result)
|
300
|
+
image = ::MiniMagick::Image.new(result.path, result)
|
301
301
|
image = block.call(image)
|
302
302
|
result = image.instance_variable_get(:@tempfile)
|
303
303
|
end
|
@@ -305,7 +305,7 @@ module CarrierWave
|
|
305
305
|
def mkdir!(path, directory_permissions)
|
306
306
|
options = {}
|
307
307
|
options[:mode] = directory_permissions if directory_permissions
|
308
|
-
FileUtils.mkdir_p(File.dirname(path), options) unless File.exist?(File.dirname(path))
|
308
|
+
FileUtils.mkdir_p(File.dirname(path), **options) unless File.exist?(File.dirname(path))
|
309
309
|
end
|
310
310
|
|
311
311
|
def chmod!(path, permissions)
|
@@ -161,6 +161,8 @@ module CarrierWave
|
|
161
161
|
end
|
162
162
|
|
163
163
|
class File
|
164
|
+
DEFAULT_S3_REGION = 'us-east-1'
|
165
|
+
|
164
166
|
include CarrierWave::Utilities::Uri
|
165
167
|
|
166
168
|
##
|
@@ -194,7 +196,7 @@ module CarrierWave
|
|
194
196
|
# [NilClass] no authenticated url available
|
195
197
|
#
|
196
198
|
def authenticated_url(options = {})
|
197
|
-
if ['AWS', 'Google', 'Rackspace', 'OpenStack', 'AzureRM', 'Aliyun'].include?(@uploader.fog_credentials[:provider])
|
199
|
+
if ['AWS', 'Google', 'Rackspace', 'OpenStack', 'AzureRM', 'Aliyun', 'backblaze'].include?(@uploader.fog_credentials[:provider])
|
198
200
|
# avoid a get by using local references
|
199
201
|
local_directory = connection.directories.new(:key => @uploader.fog_directory)
|
200
202
|
local_file = local_directory.files.new(:key => path)
|
@@ -384,9 +386,15 @@ module CarrierWave
|
|
384
386
|
if valid_subdomain
|
385
387
|
s3_subdomain = @uploader.fog_aws_accelerate ? "s3-accelerate" : "s3"
|
386
388
|
"#{protocol}://#{@uploader.fog_directory}.#{s3_subdomain}.amazonaws.com/#{encoded_path}"
|
387
|
-
else
|
388
|
-
|
389
|
-
|
389
|
+
else # directory is not a valid subdomain, so use path style for access
|
390
|
+
region = @uploader.fog_credentials[:region].to_s
|
391
|
+
host = case region
|
392
|
+
when DEFAULT_S3_REGION, ''
|
393
|
+
's3.amazonaws.com'
|
394
|
+
else
|
395
|
+
"s3.#{region}.amazonaws.com"
|
396
|
+
end
|
397
|
+
"#{protocol}://#{host}/#{@uploader.fog_directory}/#{encoded_path}"
|
390
398
|
end
|
391
399
|
end
|
392
400
|
when 'Google'
|
data/lib/carrierwave/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Nicklas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|