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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68685b55fa2e963a4f1360b559cf5a89247acb148f1df1f7bbdfb3f1c0b7a2f7
4
- data.tar.gz: 4f9ae6aeecce7ca31d4aa8ca79f7e5f29fa9669812589f673108562d8b6fc48f
3
+ metadata.gz: 00606ed46f8982064ac5a4c9a4c84ec913d2844cb27ef3701ab8eef9f3379810
4
+ data.tar.gz: 66d28e5ffdb2c7d8c87f408847fa0a845e19fbe85559b01103e211d43e384e2d
5
5
  SHA512:
6
- metadata.gz: 158191c23a9097e4aec49111b26df612f51593f95c28a095ff1742d33cbfcee2cb64ee0fce25f0c9d959e747e0afa75a220b5de6f4cc6c159e6dbd88f78eb0ce
7
- data.tar.gz: 3ddf67382bb3ecd08069181590817b0f41150cd9735d53fadceb597b8a8ee2ce677a2044b38bd323318a6fe13123d010b3cc20ea2bf0d06f125866e164c56e4e
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
- If you would like to crop images to a specific height and width you
339
- can use the alternative option of '''resize_to_fill'''. It will make sure
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}"
@@ -114,7 +114,7 @@ module CarrierWave
114
114
  end
115
115
 
116
116
  def remove?
117
- remove.present? && remove !~ /\A0|false$\z/
117
+ remove.present? && (remove == true || remove !~ /\A0|false$\z/)
118
118
  end
119
119
 
120
120
  def remove!
@@ -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
- # directory is not a valid subdomain, so use path style for access
389
- "#{protocol}://s3.amazonaws.com/#{@uploader.fog_directory}/#{encoded_path}"
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'
@@ -1,3 +1,3 @@
1
1
  module CarrierWave
2
- VERSION = "2.0.2"
2
+ VERSION = "2.1.0"
3
3
  end
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.2
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: 2019-09-28 00:00:00.000000000 Z
11
+ date: 2020-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport