carrierwave 0.4.5 → 0.4.6
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.rdoc +33 -15
- data/lib/carrierwave.rb +0 -1
- data/lib/carrierwave/compatibility/paperclip.rb +2 -2
- data/lib/carrierwave/orm/activerecord.rb +9 -5
- data/lib/carrierwave/orm/datamapper.rb +10 -0
- data/lib/carrierwave/processing/mini_magick.rb +1 -1
- data/lib/carrierwave/processing/rmagick.rb +4 -4
- data/lib/carrierwave/sanitized_file.rb +2 -2
- data/lib/carrierwave/storage/cloud_files.rb +11 -12
- data/lib/carrierwave/storage/grid_fs.rb +37 -26
- data/lib/carrierwave/storage/right_s3.rb +1 -168
- data/lib/carrierwave/storage/s3.rb +73 -66
- data/lib/carrierwave/test/matchers.rb +57 -21
- data/lib/carrierwave/uploader/configuration.rb +8 -5
- data/lib/carrierwave/uploader/processing.rb +1 -0
- data/lib/carrierwave/uploader/url.rb +2 -2
- data/lib/carrierwave/uploader/versions.rb +10 -0
- metadata +31 -279
- data/Generators +0 -4
- data/History.txt +0 -125
- data/Manifest.txt +0 -111
- data/Rakefile +0 -39
- data/carrierwave.gemspec +0 -85
- data/cucumber.yml +0 -2
- data/features/caching.feature +0 -28
- data/features/download.feature +0 -20
- data/features/file_storage.feature +0 -37
- data/features/file_storage_overridden_filename.feature +0 -38
- data/features/file_storage_overridden_store_dir.feature +0 -38
- data/features/file_storage_reversing_processor.feature +0 -43
- data/features/fixtures/bork.txt +0 -1
- data/features/fixtures/monkey.txt +0 -1
- data/features/grid_fs_storage.feature +0 -32
- data/features/mount_activerecord.feature +0 -46
- data/features/mount_datamapper.feature +0 -46
- data/features/step_definitions/activerecord_steps.rb +0 -22
- data/features/step_definitions/caching_steps.rb +0 -14
- data/features/step_definitions/datamapper_steps.rb +0 -29
- data/features/step_definitions/download_steps.rb +0 -4
- data/features/step_definitions/file_steps.rb +0 -53
- data/features/step_definitions/general_steps.rb +0 -85
- data/features/step_definitions/mount_steps.rb +0 -19
- data/features/step_definitions/store_steps.rb +0 -18
- data/features/support/activerecord.rb +0 -30
- data/features/support/datamapper.rb +0 -7
- data/features/support/env.rb +0 -22
- data/features/versions_basics.feature +0 -50
- data/features/versions_nested_versions.feature +0 -70
- data/features/versions_overridden_filename.feature +0 -51
- data/features/versions_overriden_store_dir.feature +0 -41
- data/lib/carrierwave/orm/mongomapper.rb +0 -27
- data/merb_generators/uploader_generator.rb +0 -22
- data/rails_generators/uploader/USAGE +0 -2
- data/rails_generators/uploader/templates/uploader.rb +0 -47
- data/rails_generators/uploader/uploader_generator.rb +0 -21
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/spec/compatibility/paperclip_spec.rb +0 -52
- data/spec/fixtures/bork.txt +0 -1
- data/spec/fixtures/landscape.jpg +0 -0
- data/spec/fixtures/portrait.jpg +0 -0
- data/spec/fixtures/test.jpeg +0 -1
- data/spec/fixtures/test.jpg +0 -1
- data/spec/mount_spec.rb +0 -538
- data/spec/orm/activerecord_spec.rb +0 -271
- data/spec/orm/datamapper_spec.rb +0 -168
- data/spec/orm/mongoid_spec.rb +0 -202
- data/spec/orm/mongomapper_spec.rb +0 -202
- data/spec/orm/sequel_spec.rb +0 -183
- data/spec/processing/image_science_spec.rb +0 -56
- data/spec/processing/mini_magick_spec.rb +0 -76
- data/spec/processing/rmagick_spec.rb +0 -75
- data/spec/sanitized_file_spec.rb +0 -623
- data/spec/spec_helper.rb +0 -92
- data/spec/storage/cloudfiles_spec.rb +0 -78
- data/spec/storage/grid_fs_spec.rb +0 -83
- data/spec/storage/right_s3_spec.rb +0 -83
- data/spec/storage/s3_spec.rb +0 -95
- data/spec/uploader/cache_spec.rb +0 -209
- data/spec/uploader/configuration_spec.rb +0 -105
- data/spec/uploader/default_url_spec.rb +0 -85
- data/spec/uploader/download_spec.rb +0 -75
- data/spec/uploader/extension_whitelist_spec.rb +0 -44
- data/spec/uploader/mountable_spec.rb +0 -33
- data/spec/uploader/paths_spec.rb +0 -22
- data/spec/uploader/processing_spec.rb +0 -73
- data/spec/uploader/proxy_spec.rb +0 -54
- data/spec/uploader/remove_spec.rb +0 -70
- data/spec/uploader/store_spec.rb +0 -264
- data/spec/uploader/url_spec.rb +0 -102
- data/spec/uploader/versions_spec.rb +0 -298
@@ -1,19 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
When /^I assign the file '([^\']*)' to the '([^\']*)' column$/ do |path, column|
|
4
|
-
@instance.send("#{column}=", File.open(file_path(path)))
|
5
|
-
end
|
6
|
-
|
7
|
-
Given /^the uploader class is mounted on the '([^\']*)' column$/ do |column|
|
8
|
-
@mountee_klass.mount_uploader column.to_sym, @klass
|
9
|
-
end
|
10
|
-
|
11
|
-
When /^I retrieve the file later from the cache name for the column '([^\']*)'$/ do |column|
|
12
|
-
new_instance = @instance.class.new
|
13
|
-
new_instance.send("#{column}_cache=", @instance.send("#{column}_cache"))
|
14
|
-
@instance = new_instance
|
15
|
-
end
|
16
|
-
|
17
|
-
Then /^the url for the column '([^\']*)' should be '([^\']*)'$/ do |column, url|
|
18
|
-
@instance.send("#{column}_url").should == url
|
19
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
Given /^the file '(.*?)' is stored at '(.*?)'$/ do |file, stored|
|
4
|
-
FileUtils.mkdir_p(File.dirname(file_path(stored)))
|
5
|
-
FileUtils.cp(file_path(file), file_path(stored))
|
6
|
-
end
|
7
|
-
|
8
|
-
When /^I store the file$/ do
|
9
|
-
@uploader.store!
|
10
|
-
end
|
11
|
-
|
12
|
-
When /^I store the file '(.*?)'$/ do |file|
|
13
|
-
@uploader.store!(File.open(file_path(file)))
|
14
|
-
end
|
15
|
-
|
16
|
-
When /^I retrieve the file '(.*?)' from the store$/ do |identifier|
|
17
|
-
@uploader.retrieve_from_store!(identifier)
|
18
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'active_record'
|
4
|
-
require 'carrierwave/mount'
|
5
|
-
require 'carrierwave/orm/activerecord'
|
6
|
-
|
7
|
-
# change this if sqlite is unavailable
|
8
|
-
dbconfig = {
|
9
|
-
:adapter => 'sqlite3',
|
10
|
-
:database => ':memory:'
|
11
|
-
}
|
12
|
-
|
13
|
-
ActiveRecord::Base.establish_connection(dbconfig)
|
14
|
-
ActiveRecord::Migration.verbose = false
|
15
|
-
|
16
|
-
class TestMigration < ActiveRecord::Migration
|
17
|
-
def self.up
|
18
|
-
create_table :users, :force => true do |t|
|
19
|
-
t.column :avatar, :string
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.down
|
24
|
-
drop_table :users
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
Before do
|
29
|
-
TestMigration.up
|
30
|
-
end
|
data/features/support/env.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
$TESTING=true
|
4
|
-
$:.unshift File.expand_path(File.join('..', '..', 'lib'), File.dirname(__FILE__))
|
5
|
-
|
6
|
-
require File.join(File.dirname(__FILE__), 'activerecord')
|
7
|
-
require File.join(File.dirname(__FILE__), 'datamapper')
|
8
|
-
|
9
|
-
require 'spec'
|
10
|
-
require 'carrierwave'
|
11
|
-
|
12
|
-
alias :running :lambda
|
13
|
-
|
14
|
-
def file_path( *paths )
|
15
|
-
File.expand_path(File.join('..', *paths), File.dirname(__FILE__))
|
16
|
-
end
|
17
|
-
|
18
|
-
CarrierWave.root = file_path('public')
|
19
|
-
|
20
|
-
After do
|
21
|
-
FileUtils.rm_rf(file_path("public"))
|
22
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
Feature: uploader with file storage and versions
|
2
|
-
In order to be awesome
|
3
|
-
As a developer using CarrierWave
|
4
|
-
I want to upload files to the filesystem
|
5
|
-
|
6
|
-
Background:
|
7
|
-
Given an uploader class that uses the 'file' storage
|
8
|
-
And that the uploader class has a version named 'thumb'
|
9
|
-
And an instance of that class
|
10
|
-
|
11
|
-
Scenario: store a file
|
12
|
-
When I store the file 'fixtures/bork.txt'
|
13
|
-
Then there should be a file at 'public/uploads/bork.txt'
|
14
|
-
Then there should be a file at 'public/uploads/thumb_bork.txt'
|
15
|
-
And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
16
|
-
And the file at 'public/uploads/thumb_bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
17
|
-
And the uploader should have the url '/uploads/bork.txt'
|
18
|
-
And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt'
|
19
|
-
|
20
|
-
Scenario: cache a file and then store it
|
21
|
-
When I cache the file 'fixtures/bork.txt'
|
22
|
-
Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
|
23
|
-
Then there should be a file called 'thumb_bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
|
24
|
-
And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
|
25
|
-
And there should not be a file at 'public/uploads/bork.txt'
|
26
|
-
And there should not be a file at 'public/uploads/thumb_bork.txt'
|
27
|
-
When I store the file
|
28
|
-
Then there should be a file at 'public/uploads/bork.txt'
|
29
|
-
And there should be a file at 'public/uploads/thumb_bork.txt'
|
30
|
-
And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
31
|
-
And the file at 'public/uploads/thumb_bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
32
|
-
And the uploader should have the url '/uploads/bork.txt'
|
33
|
-
And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt'
|
34
|
-
|
35
|
-
Scenario: retrieving a file from cache then storing
|
36
|
-
Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/bork.txt'
|
37
|
-
Given the file 'fixtures/monkey.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/thumb_bork.txt'
|
38
|
-
When I retrieve the cache name '20090212-2343-8336-0348/bork.txt' from the cache
|
39
|
-
And I store the file
|
40
|
-
Then there should be a file at 'public/uploads/bork.txt'
|
41
|
-
Then there should be a file at 'public/uploads/thumb_bork.txt'
|
42
|
-
And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
43
|
-
And the file at 'public/uploads/thumb_bork.txt' should be identical to the file at 'fixtures/monkey.txt'
|
44
|
-
|
45
|
-
Scenario: retrieving a file from store
|
46
|
-
Given the file 'fixtures/bork.txt' is stored at 'public/uploads/bork.txt'
|
47
|
-
Given the file 'fixtures/monkey.txt' is stored at 'public/uploads/thumb_bork.txt'
|
48
|
-
When I retrieve the file 'bork.txt' from the store
|
49
|
-
Then the uploader should have the url '/uploads/bork.txt'
|
50
|
-
And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt'
|
@@ -1,70 +0,0 @@
|
|
1
|
-
Feature: uploader with nested versions
|
2
|
-
In order to optimize performance for processing
|
3
|
-
As a developer using CarrierWave
|
4
|
-
I want to set nested versions
|
5
|
-
|
6
|
-
Background:
|
7
|
-
Given an uploader class that uses the 'file' storage
|
8
|
-
And that the uploader class has a version named 'thumb'
|
9
|
-
And yo dawg, I put a version called 'mini' in your version called 'thumb'
|
10
|
-
And yo dawg, I put a version called 'micro' in your version called 'thumb'
|
11
|
-
And an instance of that class
|
12
|
-
|
13
|
-
Scenario: store a file
|
14
|
-
When I store the file 'fixtures/bork.txt'
|
15
|
-
Then there should be a file at 'public/uploads/bork.txt'
|
16
|
-
Then there should be a file at 'public/uploads/thumb_bork.txt'
|
17
|
-
Then there should be a file at 'public/uploads/thumb_mini_bork.txt'
|
18
|
-
Then there should be a file at 'public/uploads/thumb_micro_bork.txt'
|
19
|
-
And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
20
|
-
And the file at 'public/uploads/thumb_bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
21
|
-
And the file at 'public/uploads/thumb_mini_bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
22
|
-
And the file at 'public/uploads/thumb_micro_bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
23
|
-
And the uploader should have the url '/uploads/bork.txt'
|
24
|
-
And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt'
|
25
|
-
And the uploader's nested version 'mini' nested in 'thumb' should have the url '/uploads/thumb_mini_bork.txt'
|
26
|
-
And the uploader's nested version 'micro' nested in 'thumb' should have the url '/uploads/thumb_micro_bork.txt'
|
27
|
-
|
28
|
-
Scenario: cache a file and then store it
|
29
|
-
When I cache the file 'fixtures/bork.txt'
|
30
|
-
Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
|
31
|
-
Then there should be a file called 'thumb_bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
|
32
|
-
And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
|
33
|
-
And there should not be a file at 'public/uploads/bork.txt'
|
34
|
-
And there should not be a file at 'public/uploads/thumb_bork.txt'
|
35
|
-
When I store the file
|
36
|
-
Then there should be a file at 'public/uploads/bork.txt'
|
37
|
-
And there should be a file at 'public/uploads/thumb_bork.txt'
|
38
|
-
And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
39
|
-
And the file at 'public/uploads/thumb_bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
40
|
-
And the uploader should have the url '/uploads/bork.txt'
|
41
|
-
And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt'
|
42
|
-
And the uploader's nested version 'mini' nested in 'thumb' should have the url '/uploads/thumb_mini_bork.txt'
|
43
|
-
And the uploader's nested version 'micro' nested in 'thumb' should have the url '/uploads/thumb_micro_bork.txt'
|
44
|
-
|
45
|
-
Scenario: retrieving a file from cache then storing
|
46
|
-
Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/bork.txt'
|
47
|
-
Given the file 'fixtures/monkey.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/thumb_bork.txt'
|
48
|
-
Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/thumb_mini_bork.txt'
|
49
|
-
Given the file 'fixtures/monkey.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/thumb_micro_bork.txt'
|
50
|
-
When I retrieve the cache name '20090212-2343-8336-0348/bork.txt' from the cache
|
51
|
-
And I store the file
|
52
|
-
Then there should be a file at 'public/uploads/bork.txt'
|
53
|
-
Then there should be a file at 'public/uploads/thumb_bork.txt'
|
54
|
-
Then there should be a file at 'public/uploads/thumb_mini_bork.txt'
|
55
|
-
Then there should be a file at 'public/uploads/thumb_micro_bork.txt'
|
56
|
-
And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
57
|
-
And the file at 'public/uploads/thumb_bork.txt' should be identical to the file at 'fixtures/monkey.txt'
|
58
|
-
And the file at 'public/uploads/thumb_mini_bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
59
|
-
And the file at 'public/uploads/thumb_micro_bork.txt' should be identical to the file at 'fixtures/monkey.txt'
|
60
|
-
|
61
|
-
Scenario: retrieving a file from store
|
62
|
-
Given the file 'fixtures/bork.txt' is stored at 'public/uploads/bork.txt'
|
63
|
-
Given the file 'fixtures/monkey.txt' is stored at 'public/uploads/thumb_bork.txt'
|
64
|
-
Given the file 'fixtures/monkey.txt' is stored at 'public/uploads/thumb_mini_bork.txt'
|
65
|
-
Given the file 'fixtures/monkey.txt' is stored at 'public/uploads/thumb_micro_bork.txt'
|
66
|
-
When I retrieve the file 'bork.txt' from the store
|
67
|
-
Then the uploader should have the url '/uploads/bork.txt'
|
68
|
-
And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt'
|
69
|
-
And the uploader's nested version 'mini' nested in 'thumb' should have the url '/uploads/thumb_mini_bork.txt'
|
70
|
-
And the uploader's nested version 'micro' nested in 'thumb' should have the url '/uploads/thumb_micro_bork.txt'
|
@@ -1,51 +0,0 @@
|
|
1
|
-
Feature: uploader with file storage and overriden filename
|
2
|
-
In order to customize the filaname of uploaded files
|
3
|
-
As a developer using CarrierWave
|
4
|
-
I want to upload files to the filesystem with an overriden filename and different verions
|
5
|
-
|
6
|
-
Background:
|
7
|
-
Given an uploader class that uses the 'file' storage
|
8
|
-
And that the uploader class has a version named 'thumb'
|
9
|
-
And that the uploader has the filename overridden to 'grark.png'
|
10
|
-
And an instance of that class
|
11
|
-
|
12
|
-
Scenario: store a file
|
13
|
-
When I store the file 'fixtures/bork.txt'
|
14
|
-
Then there should be a file at 'public/uploads/grark.png'
|
15
|
-
Then there should be a file at 'public/uploads/thumb_grark.png'
|
16
|
-
And the file at 'public/uploads/grark.png' should be identical to the file at 'fixtures/bork.txt'
|
17
|
-
And the file at 'public/uploads/thumb_grark.png' should be identical to the file at 'fixtures/bork.txt'
|
18
|
-
And the uploader should have the url '/uploads/grark.png'
|
19
|
-
And the uploader's version 'thumb' should have the url '/uploads/thumb_grark.png'
|
20
|
-
|
21
|
-
Scenario: cache a file and then store it
|
22
|
-
When I cache the file 'fixtures/bork.txt'
|
23
|
-
Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
|
24
|
-
Then there should be a file called 'thumb_bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
|
25
|
-
And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
|
26
|
-
And there should not be a file at 'public/uploads/grark.png'
|
27
|
-
And there should not be a file at 'public/uploads/thumb_grark.png'
|
28
|
-
When I store the file
|
29
|
-
Then there should be a file at 'public/uploads/grark.png'
|
30
|
-
And there should be a file at 'public/uploads/thumb_grark.png'
|
31
|
-
And the file at 'public/uploads/grark.png' should be identical to the file at 'fixtures/bork.txt'
|
32
|
-
And the file at 'public/uploads/thumb_grark.png' should be identical to the file at 'fixtures/bork.txt'
|
33
|
-
And the uploader should have the url '/uploads/grark.png'
|
34
|
-
And the uploader's version 'thumb' should have the url '/uploads/thumb_grark.png'
|
35
|
-
|
36
|
-
Scenario: retrieving a file from cache then storing
|
37
|
-
Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/bork.txt'
|
38
|
-
Given the file 'fixtures/monkey.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/thumb_bork.txt'
|
39
|
-
When I retrieve the cache name '20090212-2343-8336-0348/bork.txt' from the cache
|
40
|
-
And I store the file
|
41
|
-
Then there should be a file at 'public/uploads/grark.png'
|
42
|
-
Then there should be a file at 'public/uploads/thumb_grark.png'
|
43
|
-
And the file at 'public/uploads/grark.png' should be identical to the file at 'fixtures/bork.txt'
|
44
|
-
And the file at 'public/uploads/thumb_grark.png' should be identical to the file at 'fixtures/monkey.txt'
|
45
|
-
|
46
|
-
Scenario: retrieving a file from store
|
47
|
-
Given the file 'fixtures/bork.txt' is stored at 'public/uploads/bork.txt'
|
48
|
-
Given the file 'fixtures/monkey.txt' is stored at 'public/uploads/thumb_bork.txt'
|
49
|
-
When I retrieve the file 'bork.txt' from the store
|
50
|
-
Then the uploader should have the url '/uploads/bork.txt'
|
51
|
-
And the uploader's version 'thumb' should have the url '/uploads/thumb_bork.txt'
|
@@ -1,41 +0,0 @@
|
|
1
|
-
Feature: uploader with file storage and versions with overridden store dir
|
2
|
-
In order to be awesome
|
3
|
-
As a developer using CarrierWave
|
4
|
-
I want to upload files to the filesystem
|
5
|
-
|
6
|
-
Background:
|
7
|
-
Given an uploader class that uses the 'file' storage
|
8
|
-
And that the uploader class has a version named 'thumb'
|
9
|
-
And that the version 'thumb' has the store_dir overridden to 'public/monkey/llama'
|
10
|
-
And an instance of that class
|
11
|
-
|
12
|
-
Scenario: store a file
|
13
|
-
When I store the file 'fixtures/bork.txt'
|
14
|
-
Then there should be a file at 'public/uploads/bork.txt'
|
15
|
-
Then there should be a file at 'public/monkey/llama/thumb_bork.txt'
|
16
|
-
And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
17
|
-
And the file at 'public/monkey/llama/thumb_bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
18
|
-
|
19
|
-
Scenario: cache a file and then store it
|
20
|
-
When I cache the file 'fixtures/bork.txt'
|
21
|
-
Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
|
22
|
-
Then there should be a file called 'thumb_bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
|
23
|
-
And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
|
24
|
-
And the file called 'thumb_bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
|
25
|
-
And there should not be a file at 'public/uploads/bork.txt'
|
26
|
-
And there should not be a file at 'public/monkey/llama/thumb_bork.txt'
|
27
|
-
When I store the file
|
28
|
-
Then there should be a file at 'public/uploads/bork.txt'
|
29
|
-
Then there should be a file at 'public/monkey/llama/thumb_bork.txt'
|
30
|
-
And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
31
|
-
And the file at 'public/monkey/llama/thumb_bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
32
|
-
|
33
|
-
Scenario: retrieving a file from cache then storing
|
34
|
-
Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/bork.txt'
|
35
|
-
Given the file 'fixtures/monkey.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/thumb_bork.txt'
|
36
|
-
When I retrieve the cache name '20090212-2343-8336-0348/bork.txt' from the cache
|
37
|
-
And I store the file
|
38
|
-
Then there should be a file at 'public/uploads/bork.txt'
|
39
|
-
Then there should be a file at 'public/monkey/llama/thumb_bork.txt'
|
40
|
-
And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
|
41
|
-
And the file at 'public/monkey/llama/thumb_bork.txt' should be identical to the file at 'fixtures/monkey.txt'
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'mongo_mapper'
|
3
|
-
|
4
|
-
module CarrierWave
|
5
|
-
module MongoMapper
|
6
|
-
include CarrierWave::Mount
|
7
|
-
##
|
8
|
-
# See +CarrierWave::Mount#mount_uploader+ for documentation
|
9
|
-
#
|
10
|
-
def mount_uploader(column, uploader, options={}, &block)
|
11
|
-
# We need to set the mount_on column (or key in MongoMapper's case)
|
12
|
-
# since MongoMapper will attempt to set the filename on
|
13
|
-
# the uploader instead of the file on a Document's initialization.
|
14
|
-
options[:mount_on] ||= "#{column}_filename"
|
15
|
-
key options[:mount_on]
|
16
|
-
|
17
|
-
super
|
18
|
-
alias_method :read_uploader, :[]
|
19
|
-
alias_method :write_uploader, :[]=
|
20
|
-
after_save "store_#{column}!".to_sym
|
21
|
-
before_save "write_#{column}_identifier".to_sym
|
22
|
-
after_destroy "remove_#{column}!".to_sym
|
23
|
-
end
|
24
|
-
end # MongoMapper
|
25
|
-
end # CarrierWave
|
26
|
-
|
27
|
-
MongoMapper::Document::ClassMethods.send(:include, CarrierWave::MongoMapper)
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Merb
|
4
|
-
module Generators
|
5
|
-
class UploaderGenerator < NamedGenerator
|
6
|
-
|
7
|
-
def self.source_root
|
8
|
-
File.join(File.dirname(__FILE__), '..', '..', 'rails_generators', 'uploader', 'templates')
|
9
|
-
end
|
10
|
-
|
11
|
-
first_argument :name, :required => true, :desc => "The name of this uploader"
|
12
|
-
|
13
|
-
template :uploader do |t|
|
14
|
-
t.source = 'uploader.rb'
|
15
|
-
t.destination = "app/uploaders/#{file_name}_uploader.rb"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
add :uploader, UploaderGenerator
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
class <%= class_name %>Uploader < CarrierWave::Uploader::Base
|
4
|
-
|
5
|
-
# Include RMagick or ImageScience support
|
6
|
-
# include CarrierWave::RMagick
|
7
|
-
# include CarrierWave::ImageScience
|
8
|
-
|
9
|
-
# Choose what kind of storage to use for this uploader
|
10
|
-
storage :file
|
11
|
-
# storage :s3
|
12
|
-
|
13
|
-
# Override the directory where uploaded files will be stored
|
14
|
-
# This is a sensible default for uploaders that are meant to be mounted:
|
15
|
-
def store_dir
|
16
|
-
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
17
|
-
end
|
18
|
-
|
19
|
-
# Provide a default URL as a default if there hasn't been a file uploaded
|
20
|
-
# def default_url
|
21
|
-
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
22
|
-
# end
|
23
|
-
|
24
|
-
# Process files as they are uploaded.
|
25
|
-
# process :scale => [200, 300]
|
26
|
-
#
|
27
|
-
# def scale(width, height)
|
28
|
-
# # do something
|
29
|
-
# end
|
30
|
-
|
31
|
-
# Create different versions of your uploaded files
|
32
|
-
# version :thumb do
|
33
|
-
# process :scale => [50, 50]
|
34
|
-
# end
|
35
|
-
|
36
|
-
# Add a white list of extensions which are allowed to be uploaded,
|
37
|
-
# for images you might use something like this:
|
38
|
-
# def extension_white_list
|
39
|
-
# %w(jpg jpeg gif png)
|
40
|
-
# end
|
41
|
-
|
42
|
-
# Override the filename of the uploaded files
|
43
|
-
# def filename
|
44
|
-
# "something.jpg" if original_filename
|
45
|
-
# end
|
46
|
-
|
47
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
class UploaderGenerator < Rails::Generator::NamedBase
|
4
|
-
|
5
|
-
def manifest
|
6
|
-
record do |m|
|
7
|
-
m.directory 'app/uploaders'
|
8
|
-
m.template 'uploader.rb', "app/uploaders/#{name.underscore}_uploader.rb"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def class_name
|
13
|
-
name.camelize
|
14
|
-
end
|
15
|
-
|
16
|
-
protected
|
17
|
-
|
18
|
-
def banner
|
19
|
-
"Usage: #{$0} uploader UploaderName"
|
20
|
-
end
|
21
|
-
end
|