carrierwave 0.7.1 → 0.8.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.
- data/README.md +15 -45
- data/lib/carrierwave.rb +10 -49
- data/lib/carrierwave/error.rb +7 -0
- data/lib/carrierwave/mount.rb +7 -2
- data/lib/carrierwave/processing.rb +3 -0
- data/lib/carrierwave/processing/mime_types.rb +10 -1
- data/lib/carrierwave/processing/mini_magick.rb +10 -3
- data/lib/carrierwave/processing/rmagick.rb +11 -10
- data/lib/carrierwave/storage.rb +9 -0
- data/lib/carrierwave/storage/fog.rb +27 -22
- data/lib/carrierwave/uploader.rb +18 -1
- data/lib/carrierwave/uploader/cache.rb +6 -3
- data/lib/carrierwave/uploader/configuration.rb +0 -1
- data/lib/carrierwave/uploader/download.rb +2 -2
- data/lib/carrierwave/uploader/versions.rb +15 -6
- data/lib/carrierwave/version.rb +1 -1
- metadata +8 -4
data/README.md
CHANGED
@@ -386,11 +386,11 @@ end
|
|
386
386
|
You might come to a situation where you want to retroactively change a version
|
387
387
|
or add a new one. You can use the recreate_versions! method to recreate the
|
388
388
|
versions from the base file. This uses a naive approach which will re-upload and
|
389
|
-
process all versions.
|
389
|
+
process the specified version or all versions, if none is passed as an argument.
|
390
390
|
|
391
391
|
```ruby
|
392
392
|
instance = MyUploader.new
|
393
|
-
instance.recreate_versions!
|
393
|
+
instance.recreate_versions!(:thumb, :large)
|
394
394
|
```
|
395
395
|
|
396
396
|
Or on a mounted uploader:
|
@@ -505,15 +505,16 @@ You can also pass in additional options, as documented fully in lib/carrierwave/
|
|
505
505
|
```ruby
|
506
506
|
CarrierWave.configure do |config|
|
507
507
|
config.fog_credentials = {
|
508
|
-
:provider => 'AWS',
|
509
|
-
:aws_access_key_id => 'xxx',
|
510
|
-
:aws_secret_access_key => 'yyy',
|
511
|
-
:region => 'eu-west-1'
|
508
|
+
:provider => 'AWS', # required
|
509
|
+
:aws_access_key_id => 'xxx', # required
|
510
|
+
:aws_secret_access_key => 'yyy', # required
|
511
|
+
:region => 'eu-west-1', # optional, defaults to 'us-east-1'
|
512
|
+
:hosts => 's3.example.com', # optional, defaults to nil
|
513
|
+
:endpoint => 'https://s3.example.com:8080' # optional, defaults to nil
|
512
514
|
}
|
513
515
|
config.fog_directory = 'name_of_directory' # required
|
514
516
|
config.fog_public = false # optional, defaults to true
|
515
517
|
config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} # optional, defaults to {}
|
516
|
-
config.asset_host = 'https://assets.example.com' # optional, defaults to nil
|
517
518
|
end
|
518
519
|
```
|
519
520
|
|
@@ -579,6 +580,10 @@ gem "fog", "~> 1.3.1"
|
|
579
580
|
You'll need to configure a directory (also known as a bucket), access key id and secret access key in the initializer.
|
580
581
|
For the sake of performance it is assumed that the directory already exists, so please create it if need be.
|
581
582
|
|
583
|
+
Sign up [here](http://gs-signup-redirect.appspot.com/) and get your credentials [here](https://storage.cloud.google.com/m)
|
584
|
+
under the section “Interoperable Access”.
|
585
|
+
|
586
|
+
|
582
587
|
```ruby
|
583
588
|
CarrierWave.configure do |config|
|
584
589
|
config.fog_credentials = {
|
@@ -658,7 +663,7 @@ of ImageMagick without having to worry about installing all the RMagick librarie
|
|
658
663
|
|
659
664
|
See the MiniMagick site for more details:
|
660
665
|
|
661
|
-
https://github.com/
|
666
|
+
https://github.com/minimagick/minimagick
|
662
667
|
|
663
668
|
And the ImageMagick command line options for more for whats on offer:
|
664
669
|
|
@@ -736,46 +741,11 @@ This has only been tested with the local filesystem store.
|
|
736
741
|
|
737
742
|
## Contributing to CarrierWave
|
738
743
|
|
739
|
-
|
740
|
-
and pull requests are very welcome. Before submitting a pull request, please make sure that your changes are well tested.
|
741
|
-
|
742
|
-
First, make sure you have `imagemagick` and `ghostscript` installed.
|
743
|
-
|
744
|
-
Then, you'll need to install bundler and the gem dependencies:
|
745
|
-
|
746
|
-
gem install bundler
|
747
|
-
bundle install
|
748
|
-
|
749
|
-
You should now be able to run the local tests:
|
750
|
-
|
751
|
-
bundle exec rake
|
752
|
-
|
753
|
-
You can also run the remote specs by creating a ~/.fog file:
|
754
|
-
|
755
|
-
```yaml
|
756
|
-
:carrierwave:
|
757
|
-
:aws_access_key_id: xxx
|
758
|
-
:aws_secret_access_key: yyy
|
759
|
-
:rackspace_username: xxx
|
760
|
-
:rackspace_api_key: yyy
|
761
|
-
:google_storage_access_key_id: xxx
|
762
|
-
:google_storage_secret_access_key: yyy
|
763
|
-
```
|
764
|
-
|
765
|
-
You should now be able to run the remote tests:
|
766
|
-
|
767
|
-
REMOTE=true bundle exec rake
|
768
|
-
|
769
|
-
Please test with the latest Ruby 1.8.x and 1.9.x versions using RVM if possible.
|
770
|
-
|
771
|
-
### Running active record tests
|
772
|
-
|
773
|
-
Make sure you have a local MySQL database named `carrierwave_test` with the username
|
774
|
-
`root` and empty password.
|
744
|
+
See [CONTRIBUTING.md](https://github.com/jnicklas/carrierwave/blob/master/CONTRIBUTING.md)
|
775
745
|
|
776
746
|
## License
|
777
747
|
|
778
|
-
Copyright (c) 2008-
|
748
|
+
Copyright (c) 2008-2013 Jonas Nicklas
|
779
749
|
|
780
750
|
Permission is hereby granted, free of charge, to any person obtaining
|
781
751
|
a copy of this software and associated documentation files (the
|
data/lib/carrierwave.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require 'fileutils'
|
4
4
|
require 'active_support/core_ext/object/blank'
|
5
5
|
require 'active_support/core_ext/class/attribute'
|
6
|
-
|
7
6
|
require 'active_support/concern'
|
8
7
|
|
9
8
|
module CarrierWave
|
@@ -20,53 +19,6 @@ module CarrierWave
|
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
23
|
-
class UploadError < StandardError; end
|
24
|
-
class IntegrityError < UploadError; end
|
25
|
-
class InvalidParameter < UploadError; end
|
26
|
-
class ProcessingError < UploadError; end
|
27
|
-
class DownloadError < UploadError; end
|
28
|
-
|
29
|
-
autoload :SanitizedFile, 'carrierwave/sanitized_file'
|
30
|
-
autoload :Mount, 'carrierwave/mount'
|
31
|
-
autoload :RMagick, 'carrierwave/processing/rmagick'
|
32
|
-
autoload :ImageScience, 'carrierwave/processing/image_science'
|
33
|
-
autoload :MiniMagick, 'carrierwave/processing/mini_magick'
|
34
|
-
autoload :MimeTypes, 'carrierwave/processing/mime_types'
|
35
|
-
autoload :VERSION, 'carrierwave/version'
|
36
|
-
|
37
|
-
module Storage
|
38
|
-
autoload :Abstract, 'carrierwave/storage/abstract'
|
39
|
-
autoload :File, 'carrierwave/storage/file'
|
40
|
-
autoload :Fog, 'carrierwave/storage/fog'
|
41
|
-
end
|
42
|
-
|
43
|
-
module Uploader
|
44
|
-
autoload :Base, 'carrierwave/uploader'
|
45
|
-
autoload :Cache, 'carrierwave/uploader/cache'
|
46
|
-
autoload :Store, 'carrierwave/uploader/store'
|
47
|
-
autoload :Download, 'carrierwave/uploader/download'
|
48
|
-
autoload :Callbacks, 'carrierwave/uploader/callbacks'
|
49
|
-
autoload :Processing, 'carrierwave/uploader/processing'
|
50
|
-
autoload :Versions, 'carrierwave/uploader/versions'
|
51
|
-
autoload :Remove, 'carrierwave/uploader/remove'
|
52
|
-
autoload :ExtensionWhitelist, 'carrierwave/uploader/extension_whitelist'
|
53
|
-
autoload :ExtensionBlacklist, 'carrierwave/uploader/extension_blacklist'
|
54
|
-
autoload :DefaultUrl, 'carrierwave/uploader/default_url'
|
55
|
-
autoload :Proxy, 'carrierwave/uploader/proxy'
|
56
|
-
autoload :Url, 'carrierwave/uploader/url'
|
57
|
-
autoload :Mountable, 'carrierwave/uploader/mountable'
|
58
|
-
autoload :Configuration, 'carrierwave/uploader/configuration'
|
59
|
-
autoload :Serialization, 'carrierwave/uploader/serialization'
|
60
|
-
end
|
61
|
-
|
62
|
-
module Compatibility
|
63
|
-
autoload :Paperclip, 'carrierwave/compatibility/paperclip'
|
64
|
-
end
|
65
|
-
|
66
|
-
module Test
|
67
|
-
autoload :Matchers, 'carrierwave/test/matchers'
|
68
|
-
end
|
69
|
-
|
70
22
|
end
|
71
23
|
|
72
24
|
if defined?(Merb)
|
@@ -108,5 +60,14 @@ elsif defined?(Sinatra)
|
|
108
60
|
Sinatra::Application.public
|
109
61
|
end
|
110
62
|
end
|
111
|
-
|
112
63
|
end
|
64
|
+
|
65
|
+
require "carrierwave/error"
|
66
|
+
require "carrierwave/sanitized_file"
|
67
|
+
require "carrierwave/mount"
|
68
|
+
require "carrierwave/processing"
|
69
|
+
require "carrierwave/version"
|
70
|
+
require "carrierwave/storage"
|
71
|
+
require "carrierwave/uploader"
|
72
|
+
require "carrierwave/compatibility/paperclip"
|
73
|
+
require "carrierwave/test/matchers"
|
data/lib/carrierwave/mount.rb
CHANGED
@@ -141,10 +141,15 @@ module CarrierWave
|
|
141
141
|
def mount_uploader(column, uploader=nil, options={}, &block)
|
142
142
|
if block_given?
|
143
143
|
uploader = Class.new(uploader || CarrierWave::Uploader::Base)
|
144
|
+
const_set("Uploader#{uploader.object_id}".gsub('-', '_'), uploader)
|
144
145
|
uploader.class_eval(&block)
|
145
146
|
uploader.recursively_apply_block_to_versions(&block)
|
146
147
|
else
|
147
|
-
uploader ||=
|
148
|
+
uploader ||= begin
|
149
|
+
u = Class.new(CarrierWave::Uploader::Base)
|
150
|
+
const_set("Uploader#{u.object_id}".gsub('-', '_'), u)
|
151
|
+
u
|
152
|
+
end
|
148
153
|
end
|
149
154
|
|
150
155
|
uploaders[column.to_sym] = uploader
|
@@ -344,7 +349,7 @@ module CarrierWave
|
|
344
349
|
@integrity_error = nil
|
345
350
|
|
346
351
|
@remote_url = url
|
347
|
-
|
352
|
+
|
348
353
|
uploader.download!(url)
|
349
354
|
|
350
355
|
rescue CarrierWave::DownloadError => e
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# encoding: utf-8
|
2
2
|
|
3
3
|
module CarrierWave
|
4
4
|
|
@@ -26,6 +26,15 @@ module CarrierWave
|
|
26
26
|
module MimeTypes
|
27
27
|
extend ActiveSupport::Concern
|
28
28
|
|
29
|
+
included do
|
30
|
+
begin
|
31
|
+
require "mime/types"
|
32
|
+
rescue LoadError => e
|
33
|
+
e.message << " (You may need to install the mime-types gem)"
|
34
|
+
raise e
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
29
38
|
module ClassMethods
|
30
39
|
def set_content_type(override=false)
|
31
40
|
process :set_content_type => override
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'mini_magick'
|
4
|
-
|
5
3
|
module CarrierWave
|
6
4
|
|
7
5
|
##
|
@@ -51,12 +49,21 @@ module CarrierWave
|
|
51
49
|
#
|
52
50
|
# http://mini_magick.rubyforge.org/
|
53
51
|
# and
|
54
|
-
#
|
52
|
+
# https://github.com/minimagic/minimagick/
|
55
53
|
#
|
56
54
|
#
|
57
55
|
module MiniMagick
|
58
56
|
extend ActiveSupport::Concern
|
59
57
|
|
58
|
+
included do
|
59
|
+
begin
|
60
|
+
require "mini_magick"
|
61
|
+
rescue LoadError => e
|
62
|
+
e.message << " (You may need to install the mini_magick gem)"
|
63
|
+
raise e
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
60
67
|
module ClassMethods
|
61
68
|
def convert(format)
|
62
69
|
process :convert => format
|
@@ -1,15 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
unless defined? Magick
|
4
|
-
begin
|
5
|
-
require 'rmagick'
|
6
|
-
rescue LoadError
|
7
|
-
require 'RMagick'
|
8
|
-
rescue LoadError
|
9
|
-
puts "WARNING: Failed to require rmagick, image processing may fail!"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
3
|
module CarrierWave
|
14
4
|
|
15
5
|
##
|
@@ -70,6 +60,17 @@ module CarrierWave
|
|
70
60
|
module RMagick
|
71
61
|
extend ActiveSupport::Concern
|
72
62
|
|
63
|
+
included do
|
64
|
+
begin
|
65
|
+
require "rmagick"
|
66
|
+
rescue LoadError
|
67
|
+
require "RMagick"
|
68
|
+
rescue LoadError => e
|
69
|
+
e.message << " (You may need to install the rmagick gem)"
|
70
|
+
raise e
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
73
74
|
module ClassMethods
|
74
75
|
def convert(format)
|
75
76
|
process :convert => format
|
@@ -1,10 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
require 'fog'
|
5
|
-
rescue LoadError
|
6
|
-
raise "You don't have the 'fog' gem installed"
|
7
|
-
end
|
3
|
+
require "fog"
|
8
4
|
|
9
5
|
module CarrierWave
|
10
6
|
module Storage
|
@@ -16,11 +12,10 @@ module CarrierWave
|
|
16
12
|
#
|
17
13
|
# You need to setup some options to configure your usage:
|
18
14
|
#
|
19
|
-
# [:fog_credentials] credentials for service
|
15
|
+
# [:fog_credentials] host info and credentials for service
|
20
16
|
# [:fog_directory] specifies name of directory to store data in, assumed to already exist
|
21
17
|
#
|
22
18
|
# [:fog_attributes] (optional) additional attributes to set on files
|
23
|
-
# [:fog_endpoint] (optional) non-default host to connect with
|
24
19
|
# [:fog_public] (optional) public readability, defaults to true
|
25
20
|
# [:fog_authenticated_url_expiration] (optional) time (in seconds) that authenticated urls
|
26
21
|
# will be valid, when fog_public is false and provider is AWS or Google, defaults to 600
|
@@ -103,14 +98,6 @@ module CarrierWave
|
|
103
98
|
def connection
|
104
99
|
@connection ||= begin
|
105
100
|
options = credentials = uploader.fog_credentials
|
106
|
-
endpoint_url = if uploader.fog_endpoint.respond_to? :call
|
107
|
-
URI.parse( uploader.fog_endpoint.call(self) )
|
108
|
-
elsif uploader.fog_endpoint
|
109
|
-
URI.parse( uploader.fog_endpoint )
|
110
|
-
end
|
111
|
-
if host_string = endpoint_url && (endpoint_url.host || endpoint_url.to_s)
|
112
|
-
options.merge!( { :host => host_string } )
|
113
|
-
end
|
114
101
|
self.class.connection_cache[credentials] ||= ::Fog::Storage.new(options)
|
115
102
|
end
|
116
103
|
end
|
@@ -139,7 +126,7 @@ module CarrierWave
|
|
139
126
|
|
140
127
|
##
|
141
128
|
# Return a temporary authenticated url to a private file, if available
|
142
|
-
# Only supported for AWS and Google providers
|
129
|
+
# Only supported for AWS, Rackspace and Google providers
|
143
130
|
#
|
144
131
|
# === Returns
|
145
132
|
#
|
@@ -148,12 +135,14 @@ module CarrierWave
|
|
148
135
|
# [NilClass] no authenticated url available
|
149
136
|
#
|
150
137
|
def authenticated_url(options = {})
|
151
|
-
if ['AWS', 'Google'].include?(@uploader.fog_credentials[:provider])
|
138
|
+
if ['AWS', 'Google', 'Rackspace'].include?(@uploader.fog_credentials[:provider])
|
152
139
|
# avoid a get by using local references
|
153
140
|
local_directory = connection.directories.new(:key => @uploader.fog_directory)
|
154
141
|
local_file = local_directory.files.new(:key => path)
|
155
142
|
if @uploader.fog_credentials[:provider] == "AWS"
|
156
143
|
local_file.url(::Fog::Time.now + @uploader.fog_authenticated_url_expiration, options)
|
144
|
+
elsif @uploader.fog_credentials[:provider] == "Rackspace"
|
145
|
+
connection.get_object_https_url(@uploader.fog_directory, path, ::Fog::Time.now + @uploader.fog_authenticated_url_expiration)
|
157
146
|
else
|
158
147
|
local_file.url(::Fog::Time.now + @uploader.fog_authenticated_url_expiration)
|
159
148
|
end
|
@@ -196,6 +185,17 @@ module CarrierWave
|
|
196
185
|
directory.files.new(:key => path).destroy
|
197
186
|
end
|
198
187
|
|
188
|
+
##
|
189
|
+
# Return extension of file
|
190
|
+
#
|
191
|
+
# === Returns
|
192
|
+
#
|
193
|
+
# [String] extension of file
|
194
|
+
#
|
195
|
+
def extension
|
196
|
+
path.split('.').last
|
197
|
+
end
|
198
|
+
|
199
199
|
##
|
200
200
|
# deprecated: All attributes from file (includes headers)
|
201
201
|
#
|
@@ -285,12 +285,17 @@ module CarrierWave
|
|
285
285
|
# AWS/Google optimized for speed over correctness
|
286
286
|
case @uploader.fog_credentials[:provider]
|
287
287
|
when 'AWS'
|
288
|
-
# if
|
289
|
-
if @uploader.
|
290
|
-
"
|
288
|
+
# check if some endpoint is set in fog_credentials
|
289
|
+
if @uploader.fog_credentials.has_key?(:endpoint)
|
290
|
+
"#{@uploader.fog_credentials[:endpoint]}/#{@uploader.fog_directory}/#{path}"
|
291
291
|
else
|
292
|
-
# directory is
|
293
|
-
|
292
|
+
# if directory is a valid subdomain, use that style for access
|
293
|
+
if @uploader.fog_directory.to_s =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\d{1,3}){3}$))(?:[a-z0-9\.]|(?![\-])|\-(?![\.])){1,61}[a-z0-9]$/
|
294
|
+
"https://#{@uploader.fog_directory}.s3.amazonaws.com/#{path}"
|
295
|
+
else
|
296
|
+
# directory is not a valid subdomain, so use path style for access
|
297
|
+
"https://s3.amazonaws.com/#{@uploader.fog_directory}/#{path}"
|
298
|
+
end
|
294
299
|
end
|
295
300
|
when 'Google'
|
296
301
|
"https://commondatastorage.googleapis.com/#{@uploader.fog_directory}/#{path}"
|
data/lib/carrierwave/uploader.rb
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require "carrierwave/uploader/configuration"
|
4
|
+
require "carrierwave/uploader/callbacks"
|
5
|
+
require "carrierwave/uploader/proxy"
|
6
|
+
require "carrierwave/uploader/url"
|
7
|
+
require "carrierwave/uploader/mountable"
|
8
|
+
require "carrierwave/uploader/cache"
|
9
|
+
require "carrierwave/uploader/store"
|
10
|
+
require "carrierwave/uploader/download"
|
11
|
+
require "carrierwave/uploader/remove"
|
12
|
+
require "carrierwave/uploader/extension_whitelist"
|
13
|
+
require "carrierwave/uploader/extension_blacklist"
|
14
|
+
require "carrierwave/uploader/processing"
|
15
|
+
require "carrierwave/uploader/versions"
|
16
|
+
require "carrierwave/uploader/default_url"
|
17
|
+
|
18
|
+
require "carrierwave/uploader/serialization"
|
19
|
+
|
3
20
|
module CarrierWave
|
4
21
|
|
5
22
|
##
|
@@ -25,6 +42,7 @@ module CarrierWave
|
|
25
42
|
class Base
|
26
43
|
attr_reader :file
|
27
44
|
|
45
|
+
include CarrierWave::Uploader::Configuration
|
28
46
|
include CarrierWave::Uploader::Callbacks
|
29
47
|
include CarrierWave::Uploader::Proxy
|
30
48
|
include CarrierWave::Uploader::Url
|
@@ -38,7 +56,6 @@ module CarrierWave
|
|
38
56
|
include CarrierWave::Uploader::Processing
|
39
57
|
include CarrierWave::Uploader::Versions
|
40
58
|
include CarrierWave::Uploader::DefaultUrl
|
41
|
-
include CarrierWave::Uploader::Configuration
|
42
59
|
include CarrierWave::Uploader::Serialization
|
43
60
|
end # Base
|
44
61
|
|
@@ -70,6 +70,10 @@ module CarrierWave
|
|
70
70
|
# require the file to be stored on the local filesystem.
|
71
71
|
#
|
72
72
|
def cache_stored_file!
|
73
|
+
cache!
|
74
|
+
end
|
75
|
+
|
76
|
+
def sanitized_file
|
73
77
|
_content = file.read
|
74
78
|
if _content.is_a?(File) # could be if storage is Fog
|
75
79
|
sanitized = CarrierWave::Storage::Fog.new(self).retrieve!(File.basename(_content.path))
|
@@ -79,8 +83,7 @@ module CarrierWave
|
|
79
83
|
sanitized = SanitizedFile.new :tempfile => StringIO.new(file.read),
|
80
84
|
:filename => File.basename(path), :content_type => file.content_type
|
81
85
|
end
|
82
|
-
|
83
|
-
cache! sanitized
|
86
|
+
sanitized
|
84
87
|
end
|
85
88
|
|
86
89
|
##
|
@@ -110,7 +113,7 @@ module CarrierWave
|
|
110
113
|
#
|
111
114
|
# [CarrierWave::FormNotMultipart] if the assigned parameter is a string
|
112
115
|
#
|
113
|
-
def cache!(new_file)
|
116
|
+
def cache!(new_file = sanitized_file)
|
114
117
|
new_file = CarrierWave::SanitizedFile.new(new_file)
|
115
118
|
|
116
119
|
unless new_file.empty?
|
@@ -37,8 +37,8 @@ module CarrierWave
|
|
37
37
|
end
|
38
38
|
@file
|
39
39
|
|
40
|
-
rescue
|
41
|
-
raise CarrierWave::DownloadError, "could not download file"
|
40
|
+
rescue Exception => e
|
41
|
+
raise CarrierWave::DownloadError, "could not download file: #{e.message}"
|
42
42
|
end
|
43
43
|
|
44
44
|
def method_missing(*args, &block)
|
@@ -52,6 +52,7 @@ module CarrierWave
|
|
52
52
|
name = name.to_sym
|
53
53
|
unless versions[name]
|
54
54
|
uploader = Class.new(self)
|
55
|
+
const_set("Uploader#{uploader.object_id}".gsub('-', '_'), uploader)
|
55
56
|
uploader.versions = {}
|
56
57
|
|
57
58
|
# Define the enable_processing method for versions so they get the
|
@@ -164,16 +165,20 @@ module CarrierWave
|
|
164
165
|
# Recreate versions and reprocess them. This can be used to recreate
|
165
166
|
# versions if their parameters somehow have changed.
|
166
167
|
#
|
167
|
-
def recreate_versions!
|
168
|
+
def recreate_versions!(*versions)
|
168
169
|
# Some files could possibly not be stored on the local disk. This
|
169
170
|
# doesn't play nicely with processing. Make sure that we're only
|
170
171
|
# processing a cached file
|
171
172
|
#
|
172
173
|
# The call to store! will trigger the necessary callbacks to both
|
173
174
|
# process this version and all sub-versions
|
174
|
-
|
175
|
-
|
176
|
-
|
175
|
+
if versions.any?
|
176
|
+
file = sanitized_file if !cached?
|
177
|
+
store_versions!(file, versions)
|
178
|
+
else
|
179
|
+
cache! if !cached?
|
180
|
+
store!
|
181
|
+
end
|
177
182
|
end
|
178
183
|
|
179
184
|
private
|
@@ -233,8 +238,12 @@ module CarrierWave
|
|
233
238
|
end
|
234
239
|
end
|
235
240
|
|
236
|
-
def store_versions!(new_file)
|
237
|
-
|
241
|
+
def store_versions!(new_file, versions=nil)
|
242
|
+
if versions
|
243
|
+
versions.each { |v| Hash[active_versions][v].store!(new_file) }
|
244
|
+
else
|
245
|
+
active_versions.each { |name, v| v.store!(new_file) }
|
246
|
+
end
|
238
247
|
end
|
239
248
|
|
240
249
|
def remove_versions!
|
data/lib/carrierwave/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -114,7 +114,7 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - ~>
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 2.
|
117
|
+
version: 2.12.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
requirements:
|
123
123
|
- - ~>
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 2.
|
125
|
+
version: 2.12.0
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: sham_rack
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -213,16 +213,19 @@ extra_rdoc_files:
|
|
213
213
|
- README.md
|
214
214
|
files:
|
215
215
|
- lib/carrierwave/compatibility/paperclip.rb
|
216
|
+
- lib/carrierwave/error.rb
|
216
217
|
- lib/carrierwave/locale/en.yml
|
217
218
|
- lib/carrierwave/mount.rb
|
218
219
|
- lib/carrierwave/orm/activerecord.rb
|
219
220
|
- lib/carrierwave/processing/mime_types.rb
|
220
221
|
- lib/carrierwave/processing/mini_magick.rb
|
221
222
|
- lib/carrierwave/processing/rmagick.rb
|
223
|
+
- lib/carrierwave/processing.rb
|
222
224
|
- lib/carrierwave/sanitized_file.rb
|
223
225
|
- lib/carrierwave/storage/abstract.rb
|
224
226
|
- lib/carrierwave/storage/file.rb
|
225
227
|
- lib/carrierwave/storage/fog.rb
|
228
|
+
- lib/carrierwave/storage.rb
|
226
229
|
- lib/carrierwave/test/matchers.rb
|
227
230
|
- lib/carrierwave/uploader/cache.rb
|
228
231
|
- lib/carrierwave/uploader/callbacks.rb
|
@@ -272,3 +275,4 @@ signing_key:
|
|
272
275
|
specification_version: 3
|
273
276
|
summary: Ruby file upload library
|
274
277
|
test_files: []
|
278
|
+
has_rdoc:
|