carrierwave 1.0.0 → 1.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
  SHA1:
3
- metadata.gz: 4e8aa98fa4de1f1cb517138ae11e7bfbd574638e
4
- data.tar.gz: 5456c89662d0ca78e61cc12c8d9305b23175172e
3
+ metadata.gz: 637cc1f96fe4f41cc4468837e5f3ea358e80ed6e
4
+ data.tar.gz: 7e160616b11d78c39bee758a90412dbadb588c04
5
5
  SHA512:
6
- metadata.gz: d4ba35c722eeef4ccdf925adf951c1323dad0c116e0f4cbf7e567cbeefacb538e7259e5a59c771d17e05ced3a0d182bfb15000ca982edb3bce6f51fa288255eb
7
- data.tar.gz: d9dbc8490ce0637ab6aa828eb695170637317141e0b3d901fefb15dfdf8b1f52094e4d7911e34182f607a185b5ebb06d460f047fb7a080f850da5d8a482c9321
6
+ metadata.gz: 9757ab08f11fee70c9337f706dce60d20f12200890ed1816f6eedc0fb2939e282c9290d724ccaa592f3c78bf91f5f643b3af0bd27240bd7ced5132068af1e45e
7
+ data.tar.gz: 768e9c140fba9bd1f3dd299cdf83b94cc4348a1888801793a638d6a20220c2eff152916a6066bcb0b586f96080039e7594c13c89b352d4711699502110772293
data/README.md CHANGED
@@ -16,7 +16,7 @@ It works well with Rack based web applications, such as Ruby on Rails.
16
16
 
17
17
  ## Getting Help
18
18
 
19
- * Please ask the community on [Stack Overflow](http://stackoverflow.com/) for help if you have any questions. Please do not post usage questions on the issue tracker.
19
+ * Please ask the community on [Stack Overflow](https://stackoverflow.com/questions/tagged/carrierwave) for help if you have any questions. Please do not post usage questions on the issue tracker.
20
20
  * Please report bugs on the [issue tracker](http://github.com/carrierwaveuploader/carrierwave/issues) but read the "getting help" section in the wiki first.
21
21
 
22
22
  ## Installation
@@ -131,9 +131,6 @@ Other ORM support has been extracted into separate gems:
131
131
  There are more extensions listed in [the wiki](https://github.com/carrierwaveuploader/carrierwave/wiki)
132
132
 
133
133
  ## Multiple file uploads
134
- **Note:** You must specify using the master branch to enable this feature:
135
-
136
- `gem 'carrierwave', github: 'carrierwaveuploader/carrierwave'`.
137
134
 
138
135
  CarrierWave also has convenient support for multiple file upload fields.
139
136
 
@@ -144,14 +141,25 @@ column for example. Your choice depends on what your database supports. For
144
141
  example, create a migration like this:
145
142
 
146
143
 
144
+ #### For databases with ActiveRecord json data type support (e.g. PostgreSQL, MySQL)
145
+
147
146
  rails g migration add_avatars_to_users avatars:json
148
147
  rake db:migrate
149
148
 
149
+ #### For database without ActiveRecord json data type support (e.g. SQLite)
150
+
151
+ rails g migration add_avatars_to_users avatars:string
152
+ rake db:migrate
153
+
154
+ __Note__: JSON datatype doesn't exists in SQLite adapter, that's why you can use a string datatype which will be serialized in model.
155
+
150
156
  Open your model file and mount the uploader:
151
157
 
158
+
152
159
  ```ruby
153
160
  class User < ActiveRecord::Base
154
161
  mount_uploaders :avatars, AvatarUploader
162
+ serialize :avatars, JSON # If you use SQLite, add this line.
155
163
  end
156
164
  ```
157
165
 
@@ -659,7 +667,7 @@ CarrierWave.configure do |config|
659
667
  }
660
668
  config.fog_directory = 'name_of_directory' # required
661
669
  config.fog_public = false # optional, defaults to true
662
- config.fog_attributes = { 'Cache-Control' => "max-age=#{365.day.to_i}" } # optional, defaults to {}
670
+ config.fog_attributes = { cache_control: "public, max-age=#{365.day.to_i}" } # optional, defaults to {}
663
671
  end
664
672
  ```
665
673
 
@@ -740,7 +748,7 @@ the url to the file on Rackspace Cloud Files.
740
748
 
741
749
  ```ruby
742
750
  gem "fog-google"
743
- gem "google-api-client", ">= 0.6.2", "< 0.9"
751
+ gem "google-api-client", "> 0.8.5", "< 0.9"
744
752
  gem "mime-types"
745
753
  ```
746
754
 
@@ -186,7 +186,8 @@ module CarrierWave
186
186
  end
187
187
 
188
188
  def store_previous_changes_for_#{column}
189
- @_previous_changes_for_#{column} = changes[_mounter(:#{column}).serialization_column]
189
+ attribute_changes = ::ActiveRecord.version.to_s.to_f >= 5.1 ? saved_changes : changes
190
+ @_previous_changes_for_#{column} = attribute_changes[_mounter(:#{column}).serialization_column]
190
191
  end
191
192
 
192
193
  def remove_previously_stored_#{column}
@@ -340,7 +341,8 @@ module CarrierWave
340
341
  end
341
342
 
342
343
  def store_previous_changes_for_#{column}
343
- @_previous_changes_for_#{column} = changes[_mounter(:#{column}).serialization_column]
344
+ attribute_changes = ::ActiveRecord.version.to_s.to_f >= 5.1 ? saved_changes : changes
345
+ @_previous_changes_for_#{column} = attribute_changes[_mounter(:#{column}).serialization_column]
344
346
  end
345
347
 
346
348
  def remove_previously_stored_#{column}
@@ -123,6 +123,7 @@ module CarrierWave
123
123
  end
124
124
 
125
125
  def remove_previous(before=nil, after=nil)
126
+ after ||= []
126
127
  return unless before
127
128
 
128
129
  # both 'before' and 'after' can be string when 'mount_on' option is set
@@ -303,8 +303,7 @@ module CarrierWave
303
303
  image.destroy!
304
304
  end
305
305
  rescue ::MiniMagick::Error, ::MiniMagick::Invalid => e
306
- default = I18n.translate(:"errors.messages.mini_magick_processing_error", :e => e, :locale => :en)
307
- message = I18n.translate(:"errors.messages.mini_magick_processing_error", :e => e, :default => default)
306
+ message = I18n.translate(:"errors.messages.mini_magick_processing_error", :e => e)
308
307
  raise CarrierWave::ProcessingError, message
309
308
  end
310
309
 
@@ -312,7 +311,11 @@ module CarrierWave
312
311
 
313
312
  def append_combine_options(cmd, combine_options)
314
313
  combine_options.each do |method, options|
315
- cmd.send(method, options)
314
+ if options.nil?
315
+ cmd.send(method)
316
+ else
317
+ cmd.send(method, options)
318
+ end
316
319
  end
317
320
  end
318
321
 
@@ -355,7 +355,7 @@ module CarrierWave
355
355
 
356
356
  destroy_image(frames)
357
357
  rescue ::Magick::ImageMagickError => e
358
- raise CarrierWave::ProcessingError, I18n.translate(:"errors.messages.rmagick_processing_error", :e => e, :default => I18n.translate(:"errors.messages.rmagick_processing_error", :e => e, :locale => :en))
358
+ raise CarrierWave::ProcessingError, I18n.translate(:"errors.messages.rmagick_processing_error", :e => e)
359
359
  end
360
360
 
361
361
  private
@@ -186,9 +186,9 @@ module CarrierWave
186
186
  move!(new_path)
187
187
  chmod!(new_path, permissions)
188
188
  if keep_filename
189
- self.file = {:tempfile => new_path, :filename => original_filename}
189
+ self.file = {:tempfile => new_path, :filename => original_filename, :content_type => content_type}
190
190
  else
191
- self.file = new_path
191
+ self.file = {:tempfile => new_path, :content_type => content_type}
192
192
  end
193
193
  self
194
194
  end
@@ -16,6 +16,8 @@ module CarrierWave
16
16
  # [:fog_authenticated_url_expiration] (optional) time (in seconds) that authenticated urls
17
17
  # will be valid, when fog_public is false and provider is AWS or Google, defaults to 600
18
18
  # [:fog_use_ssl_for_aws] (optional) #public_url will use https for the AWS generated URL]
19
+ # [:fog_aws_accelerate] (optional) #public_url will use s3-accelerate subdomain
20
+ # instead of s3, defaults to false
19
21
  #
20
22
  #
21
23
  # AWS credentials contain the following keys:
@@ -349,7 +351,8 @@ module CarrierWave
349
351
  protocol = @uploader.fog_use_ssl_for_aws ? "https" : "http"
350
352
  # if directory is a valid subdomain, use that style for access
351
353
  if @uploader.fog_directory.to_s =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\d{1,3}){3}$))(?:[a-z0-9\.]|(?![\-])|\-(?![\.])){1,61}[a-z0-9]$/
352
- "#{protocol}://#{@uploader.fog_directory}.s3.amazonaws.com/#{encoded_path}"
354
+ s3_subdomain = @uploader.fog_aws_accelerate ? "s3-accelerate" : "s3"
355
+ "#{protocol}://#{@uploader.fog_directory}.#{s3_subdomain}.amazonaws.com/#{encoded_path}"
353
356
  else
354
357
  # directory is not a valid subdomain, so use path style for access
355
358
  "#{protocol}://s3.amazonaws.com/#{@uploader.fog_directory}/#{encoded_path}"
@@ -190,7 +190,7 @@ module CarrierWave
190
190
  def cache_id=(cache_id)
191
191
  # Earlier version used 3 part cache_id. Thus we should allow for
192
192
  # the cache_id to have both 3 part and 4 part formats.
193
- raise CarrierWave::InvalidParameter, "invalid cache id" unless cache_id =~ /\A[\d]+\-[\d]+(\-[\d]{4})?\-[\d]{4}\z/
193
+ raise CarrierWave::InvalidParameter, "invalid cache id" unless cache_id =~ /\A(-)?[\d]+\-[\d]+(\-[\d]{4})?\-[\d]{4}\z/
194
194
  @cache_id = cache_id
195
195
  end
196
196
 
@@ -30,6 +30,7 @@ module CarrierWave
30
30
  add_config :fog_public
31
31
  add_config :fog_authenticated_url_expiration
32
32
  add_config :fog_use_ssl_for_aws
33
+ add_config :fog_aws_accelerate
33
34
 
34
35
  # Mounting
35
36
  add_config :ignore_integrity_errors
@@ -177,6 +178,7 @@ module CarrierWave
177
178
  config.fog_public = true
178
179
  config.fog_authenticated_url_expiration = 600
179
180
  config.fog_use_ssl_for_aws = true
181
+ config.fog_aws_accelerate = false
180
182
  config.store_dir = 'uploads'
181
183
  config.cache_dir = 'uploads/tmp'
182
184
  config.delete_tmp_file_after_storage = true
@@ -200,4 +202,3 @@ module CarrierWave
200
202
  end
201
203
  end
202
204
  end
203
-
@@ -71,15 +71,17 @@ module CarrierWave
71
71
  def process!(new_file=nil)
72
72
  return unless enable_processing
73
73
 
74
- self.class.processors.each do |method, args, condition|
75
- if(condition)
76
- if condition.respond_to?(:call)
77
- next unless condition.call(self, :args => args, :method => method, :file => new_file)
78
- else
79
- next unless self.send(condition, new_file)
74
+ with_callbacks(:process, new_file) do
75
+ self.class.processors.each do |method, args, condition|
76
+ if(condition)
77
+ if condition.respond_to?(:call)
78
+ next unless condition.call(self, :args => args, :method => method, :file => new_file)
79
+ else
80
+ next unless self.send(condition, new_file)
81
+ end
80
82
  end
83
+ self.send(method, *args)
81
84
  end
82
- self.send(method, *args)
83
85
  end
84
86
  end
85
87
 
@@ -15,8 +15,8 @@ module CarrierWave
15
15
  # [String] the location where this file is accessible via a url
16
16
  #
17
17
  def url(options = {})
18
- if file.respond_to?(:url) and not file.url.blank?
19
- file.method(:url).arity == 0 ? file.url : file.url(options)
18
+ if file.respond_to?(:url) and not (tmp_url = file.url).blank?
19
+ file.method(:url).arity == 0 ? tmp_url : file.url(options)
20
20
  elsif file.respond_to?(:path)
21
21
  path = encode_path(file.path.sub(File.expand_path(root), ''))
22
22
 
@@ -1,3 +1,3 @@
1
1
  module CarrierWave
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -15,7 +15,7 @@ class <%= class_name %>Uploader < CarrierWave::Uploader::Base
15
15
  end
16
16
 
17
17
  # Provide a default URL as a default if there hasn't been a file uploaded:
18
- # def default_url
18
+ # def default_url(*args)
19
19
  # # For Rails 3.1+ asset pipeline compatibility:
20
20
  # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
21
21
  #
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: 1.0.0
4
+ version: 1.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: 2016-12-24 00:00:00.000000000 Z
11
+ date: 2017-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -294,7 +294,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
294
294
  version: '0'
295
295
  requirements: []
296
296
  rubyforge_project:
297
- rubygems_version: 2.5.1
297
+ rubygems_version: 2.5.2
298
298
  signing_key:
299
299
  specification_version: 4
300
300
  summary: Ruby file upload library