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.

Files changed (92) hide show
  1. data/README.rdoc +33 -15
  2. data/lib/carrierwave.rb +0 -1
  3. data/lib/carrierwave/compatibility/paperclip.rb +2 -2
  4. data/lib/carrierwave/orm/activerecord.rb +9 -5
  5. data/lib/carrierwave/orm/datamapper.rb +10 -0
  6. data/lib/carrierwave/processing/mini_magick.rb +1 -1
  7. data/lib/carrierwave/processing/rmagick.rb +4 -4
  8. data/lib/carrierwave/sanitized_file.rb +2 -2
  9. data/lib/carrierwave/storage/cloud_files.rb +11 -12
  10. data/lib/carrierwave/storage/grid_fs.rb +37 -26
  11. data/lib/carrierwave/storage/right_s3.rb +1 -168
  12. data/lib/carrierwave/storage/s3.rb +73 -66
  13. data/lib/carrierwave/test/matchers.rb +57 -21
  14. data/lib/carrierwave/uploader/configuration.rb +8 -5
  15. data/lib/carrierwave/uploader/processing.rb +1 -0
  16. data/lib/carrierwave/uploader/url.rb +2 -2
  17. data/lib/carrierwave/uploader/versions.rb +10 -0
  18. metadata +31 -279
  19. data/Generators +0 -4
  20. data/History.txt +0 -125
  21. data/Manifest.txt +0 -111
  22. data/Rakefile +0 -39
  23. data/carrierwave.gemspec +0 -85
  24. data/cucumber.yml +0 -2
  25. data/features/caching.feature +0 -28
  26. data/features/download.feature +0 -20
  27. data/features/file_storage.feature +0 -37
  28. data/features/file_storage_overridden_filename.feature +0 -38
  29. data/features/file_storage_overridden_store_dir.feature +0 -38
  30. data/features/file_storage_reversing_processor.feature +0 -43
  31. data/features/fixtures/bork.txt +0 -1
  32. data/features/fixtures/monkey.txt +0 -1
  33. data/features/grid_fs_storage.feature +0 -32
  34. data/features/mount_activerecord.feature +0 -46
  35. data/features/mount_datamapper.feature +0 -46
  36. data/features/step_definitions/activerecord_steps.rb +0 -22
  37. data/features/step_definitions/caching_steps.rb +0 -14
  38. data/features/step_definitions/datamapper_steps.rb +0 -29
  39. data/features/step_definitions/download_steps.rb +0 -4
  40. data/features/step_definitions/file_steps.rb +0 -53
  41. data/features/step_definitions/general_steps.rb +0 -85
  42. data/features/step_definitions/mount_steps.rb +0 -19
  43. data/features/step_definitions/store_steps.rb +0 -18
  44. data/features/support/activerecord.rb +0 -30
  45. data/features/support/datamapper.rb +0 -7
  46. data/features/support/env.rb +0 -22
  47. data/features/versions_basics.feature +0 -50
  48. data/features/versions_nested_versions.feature +0 -70
  49. data/features/versions_overridden_filename.feature +0 -51
  50. data/features/versions_overriden_store_dir.feature +0 -41
  51. data/lib/carrierwave/orm/mongomapper.rb +0 -27
  52. data/merb_generators/uploader_generator.rb +0 -22
  53. data/rails_generators/uploader/USAGE +0 -2
  54. data/rails_generators/uploader/templates/uploader.rb +0 -47
  55. data/rails_generators/uploader/uploader_generator.rb +0 -21
  56. data/script/console +0 -10
  57. data/script/destroy +0 -14
  58. data/script/generate +0 -14
  59. data/spec/compatibility/paperclip_spec.rb +0 -52
  60. data/spec/fixtures/bork.txt +0 -1
  61. data/spec/fixtures/landscape.jpg +0 -0
  62. data/spec/fixtures/portrait.jpg +0 -0
  63. data/spec/fixtures/test.jpeg +0 -1
  64. data/spec/fixtures/test.jpg +0 -1
  65. data/spec/mount_spec.rb +0 -538
  66. data/spec/orm/activerecord_spec.rb +0 -271
  67. data/spec/orm/datamapper_spec.rb +0 -168
  68. data/spec/orm/mongoid_spec.rb +0 -202
  69. data/spec/orm/mongomapper_spec.rb +0 -202
  70. data/spec/orm/sequel_spec.rb +0 -183
  71. data/spec/processing/image_science_spec.rb +0 -56
  72. data/spec/processing/mini_magick_spec.rb +0 -76
  73. data/spec/processing/rmagick_spec.rb +0 -75
  74. data/spec/sanitized_file_spec.rb +0 -623
  75. data/spec/spec_helper.rb +0 -92
  76. data/spec/storage/cloudfiles_spec.rb +0 -78
  77. data/spec/storage/grid_fs_spec.rb +0 -83
  78. data/spec/storage/right_s3_spec.rb +0 -83
  79. data/spec/storage/s3_spec.rb +0 -95
  80. data/spec/uploader/cache_spec.rb +0 -209
  81. data/spec/uploader/configuration_spec.rb +0 -105
  82. data/spec/uploader/default_url_spec.rb +0 -85
  83. data/spec/uploader/download_spec.rb +0 -75
  84. data/spec/uploader/extension_whitelist_spec.rb +0 -44
  85. data/spec/uploader/mountable_spec.rb +0 -33
  86. data/spec/uploader/paths_spec.rb +0 -22
  87. data/spec/uploader/processing_spec.rb +0 -73
  88. data/spec/uploader/proxy_spec.rb +0 -54
  89. data/spec/uploader/remove_spec.rb +0 -70
  90. data/spec/uploader/store_spec.rb +0 -264
  91. data/spec/uploader/url_spec.rb +0 -102
  92. data/spec/uploader/versions_spec.rb +0 -298
@@ -1,38 +0,0 @@
1
- Feature: uploader with file storage and overriden filename
2
- In order to be awesome
3
- As a developer using CarrierWave
4
- I want to upload files to the filesystem with an overriden filename
5
-
6
- Background:
7
- Given an uploader class that uses the 'file' storage
8
- And that the uploader reverses the filename
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/txt.krob'
14
- And the file at 'public/uploads/txt.krob' should be identical to the file at 'fixtures/bork.txt'
15
-
16
- Scenario: store two files in succession
17
- When I store the file 'fixtures/bork.txt'
18
- Then there should be a file at 'public/uploads/txt.krob'
19
- And the file at 'public/uploads/txt.krob' should be identical to the file at 'fixtures/bork.txt'
20
- When I store the file 'fixtures/monkey.txt'
21
- Then there should be a file at 'public/uploads/txt.yeknom'
22
- And the file at 'public/uploads/txt.yeknom' should be identical to the file at 'fixtures/monkey.txt'
23
-
24
- Scenario: cache a file and then store it
25
- When I cache the file 'fixtures/bork.txt'
26
- Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
27
- And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
28
- And there should not be a file at 'public/uploads/txt.krob'
29
- When I store the file
30
- Then there should be a file at 'public/uploads/txt.krob'
31
- And the file at 'public/uploads/txt.krob' 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
- When I retrieve the cache name '20090212-2343-8336-0348/bork.txt' from the cache
36
- And I store the file
37
- Then there should be a file at 'public/uploads/txt.krob'
38
- And the file at 'public/uploads/txt.krob' should be identical to the file at 'fixtures/bork.txt'
@@ -1,38 +0,0 @@
1
- Feature: uploader with file storage and 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 has the store_dir overridden to 'public/monkey/llama'
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/monkey/llama/bork.txt'
14
- And the file at 'public/monkey/llama/bork.txt' should be identical to the file at 'fixtures/bork.txt'
15
-
16
- Scenario: store two files in succession
17
- When I store the file 'fixtures/bork.txt'
18
- Then there should be a file at 'public/monkey/llama/bork.txt'
19
- And the file at 'public/monkey/llama/bork.txt' should be identical to the file at 'fixtures/bork.txt'
20
- When I store the file 'fixtures/monkey.txt'
21
- Then there should be a file at 'public/monkey/llama/monkey.txt'
22
- And the file at 'public/monkey/llama/monkey.txt' should be identical to the file at 'fixtures/monkey.txt'
23
-
24
- Scenario: cache a file and then store it
25
- When I cache the file 'fixtures/bork.txt'
26
- Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
27
- And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
28
- And there should not be a file at 'public/monkey/llama/bork.txt'
29
- When I store the file
30
- Then there should be a file at 'public/monkey/llama/bork.txt'
31
- And the file at 'public/monkey/llama/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
- When I retrieve the cache name '20090212-2343-8336-0348/bork.txt' from the cache
36
- And I store the file
37
- Then there should be a file at 'public/monkey/llama/bork.txt'
38
- And the file at 'public/monkey/llama/bork.txt' should be identical to the file at 'fixtures/bork.txt'
@@ -1,43 +0,0 @@
1
- Feature: uploader with file storage and a processor that reverses the file
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 an instance of that class
9
- And the class has a method called 'reverse' that reverses the contents of a file
10
- And the class will process 'reverse'
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
- And the file at 'public/uploads/bork.txt' should not be identical to the file at 'fixtures/bork.txt'
16
- And the file at 'public/uploads/bork.txt' should be the reverse of the file at 'fixtures/bork.txt'
17
-
18
- Scenario: store two files in succession
19
- When I store the file 'fixtures/bork.txt'
20
- Then there should be a file at 'public/uploads/bork.txt'
21
- And the file at 'public/uploads/bork.txt' should not be identical to the file at 'fixtures/bork.txt'
22
- And the file at 'public/uploads/bork.txt' should be the reverse of the file at 'fixtures/bork.txt'
23
- When I store the file 'fixtures/monkey.txt'
24
- Then there should be a file at 'public/uploads/monkey.txt'
25
- And the file at 'public/uploads/monkey.txt' should not be identical to the file at 'fixtures/monkey.txt'
26
- And the file at 'public/uploads/monkey.txt' should be the reverse of the file at 'fixtures/monkey.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
- And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should not be identical to the file at 'fixtures/bork.txt'
32
- And there should not be a file at 'public/uploads/bork.txt'
33
- When I store the file
34
- Then there should be a file at 'public/uploads/bork.txt'
35
- And the file at 'public/uploads/bork.txt' should not be identical to the file at 'fixtures/bork.txt'
36
- And the file at 'public/uploads/bork.txt' should be the reverse of the file at 'fixtures/bork.txt'
37
-
38
- Scenario: retrieving a file from cache then storing
39
- Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/bork.txt'
40
- When I retrieve the cache name '20090212-2343-8336-0348/bork.txt' from the cache
41
- And I store the file
42
- Then there should be a file at 'public/uploads/bork.txt'
43
- And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
@@ -1 +0,0 @@
1
- this is a file
@@ -1 +0,0 @@
1
- this is another file
@@ -1,32 +0,0 @@
1
- Feature: uploader with file storage
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 'grid_fs' storage
8
- And an instance of that class
9
-
10
- Scenario: store a file
11
- When I store the file 'fixtures/bork.txt'
12
- Then the contents of the file should be 'this is a file'
13
-
14
- Scenario: store two files in succession
15
- When I store the file 'fixtures/bork.txt'
16
- Then the contents of the file should be 'this is a file'
17
- When I store the file 'fixtures/monkey.txt'
18
- Then the contents of the file should be 'this is another file'
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
- 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 there should not be a file at 'public/uploads/bork.txt'
25
- When I store the file
26
- Then the contents of the file should be 'this is a file'
27
-
28
- Scenario: retrieving a file from cache then storing
29
- Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/bork.txt'
30
- When I retrieve the cache name '20090212-2343-8336-0348/bork.txt' from the cache
31
- And I store the file
32
- Then the contents of the file should be 'this is a file'
@@ -1,46 +0,0 @@
1
- Feature: Mount an Uploader on ActiveRecord class
2
- In order to easily attach files to a form
3
- As a web developer using CarrierWave
4
- I want to mount an uploader on an ActiveRecord class
5
-
6
- Background:
7
- Given an uploader class that uses the 'file' storage
8
- And an activerecord class that uses the 'users' table
9
- And the uploader class is mounted on the 'avatar' column
10
- And an instance of the activerecord class
11
-
12
- Scenario: assign a file
13
- When I assign the file 'fixtures/bork.txt' to the 'avatar' column
14
- Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
15
- And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
16
-
17
- Scenario: assign a file and save the record
18
- When I assign the file 'fixtures/bork.txt' to the 'avatar' column
19
- And I save the active record
20
- Then there should be a file at 'public/uploads/bork.txt'
21
- And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
22
- And the url for the column 'avatar' should be '/uploads/bork.txt'
23
-
24
- Scenario: assign a file and retrieve it from cache
25
- When I assign the file 'fixtures/bork.txt' to the 'avatar' column
26
- And I retrieve the file later from the cache name for the column 'avatar'
27
- And I save the active record
28
- Then there should be a file at 'public/uploads/bork.txt'
29
- And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
30
- And the url for the column 'avatar' should be '/uploads/bork.txt'
31
-
32
- Scenario: store a file and retrieve it later
33
- When I assign the file 'fixtures/bork.txt' to the 'avatar' column
34
- And I retrieve the file later from the cache name for the column 'avatar'
35
- And I save the active record
36
- Then there should be a file at 'public/uploads/bork.txt'
37
- When I reload the active record
38
- Then the url for the column 'avatar' should be '/uploads/bork.txt'
39
-
40
- Scenario: store a file and delete the record
41
- When I assign the file 'fixtures/bork.txt' to the 'avatar' column
42
- And I retrieve the file later from the cache name for the column 'avatar'
43
- And I save the active record
44
- Then there should be a file at 'public/uploads/bork.txt'
45
- When I delete the active record
46
- Then there should not be a file at 'public/uploads/bork.txt'
@@ -1,46 +0,0 @@
1
- Feature: Mount an Uploader on ActiveRecord class
2
- In order to easily attach files to a form
3
- As a web developer using CarrierWave
4
- I want to mount an uploader on an ActiveRecord class
5
-
6
- Background:
7
- Given an uploader class that uses the 'file' storage
8
- And a datamapper class that has a 'avatar' column
9
- And the uploader class is mounted on the 'avatar' column
10
- And an instance of the datamapper class
11
-
12
- Scenario: assign a file
13
- When I assign the file 'fixtures/bork.txt' to the 'avatar' column
14
- Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
15
- And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
16
-
17
- Scenario: assign a file and save the record
18
- When I assign the file 'fixtures/bork.txt' to the 'avatar' column
19
- And I save the datamapper record
20
- Then there should be a file at 'public/uploads/bork.txt'
21
- And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
22
- And the url for the column 'avatar' should be '/uploads/bork.txt'
23
-
24
- Scenario: assign a file and retrieve it from cache
25
- When I assign the file 'fixtures/bork.txt' to the 'avatar' column
26
- And I retrieve the file later from the cache name for the column 'avatar'
27
- And I save the datamapper record
28
- Then there should be a file at 'public/uploads/bork.txt'
29
- And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
30
- And the url for the column 'avatar' should be '/uploads/bork.txt'
31
-
32
- # Scenario: store a file and retrieve it later
33
- # When I assign the file 'fixtures/bork.txt' to the 'avatar' column
34
- # And I retrieve the file later from the cache name for the column 'avatar'
35
- # And I save the datamapper record
36
- # Then there should be a file at 'public/uploads/bork.txt'
37
- # When I reload the datamapper record
38
- # Then the url for the column 'avatar' should be '/uploads/bork.txt'
39
- #
40
- # Scenario: store a file and delete the record
41
- # When I assign the file 'fixtures/bork.txt' to the 'avatar' column
42
- # And I retrieve the file later from the cache name for the column 'avatar'
43
- # And I save the datamapper record
44
- # Then there should be a file at 'public/uploads/bork.txt'
45
- # When I delete the datamapper record
46
- # Then there should not be a file at 'public/uploads/bork.txt'
@@ -1,22 +0,0 @@
1
- # encoding: utf-8
2
-
3
- Given /^an activerecord class that uses the '([^\']*)' table$/ do |name|
4
- @mountee_klass = Class.new(ActiveRecord::Base)
5
- @mountee_klass.table_name = name
6
- end
7
-
8
- Given /^an instance of the activerecord class$/ do
9
- @instance = @mountee_klass.new
10
- end
11
-
12
- When /^I save the active record$/ do
13
- @instance.save!
14
- end
15
-
16
- When /^I reload the active record$/ do
17
- @instance = @instance.class.find(@instance.id)
18
- end
19
-
20
- When /^I delete the active record$/ do
21
- @instance.destroy
22
- end
@@ -1,14 +0,0 @@
1
- # encoding: utf-8
2
-
3
- Given /^the file '(.*?)' is cached file at '(.*?)'$/ do |file, cached|
4
- FileUtils.mkdir_p(File.dirname(file_path(cached)))
5
- FileUtils.cp(file_path(file), file_path(cached))
6
- end
7
-
8
- When /^I cache the file '(.*?)'$/ do |file|
9
- @uploader.cache!(File.open(file_path(file)))
10
- end
11
-
12
- When /^I retrieve the cache name '(.*?)' from the cache$/ do |name|
13
- @uploader.retrieve_from_cache!(name)
14
- end
@@ -1,29 +0,0 @@
1
- # encoding: utf-8
2
-
3
- Given /^a datamapper class that has a '([^\']*)' column$/ do |column|
4
- @mountee_klass = Class.new do
5
- include DataMapper::Resource
6
-
7
- storage_names[:default] = 'users'
8
-
9
- property :id, Integer, :key => true
10
- property column.to_sym, String
11
- end
12
- @mountee_klass.auto_migrate!
13
- end
14
-
15
- Given /^an instance of the datamapper class$/ do
16
- @instance = @mountee_klass.new
17
- end
18
-
19
- When /^I save the datamapper record$/ do
20
- @instance.save
21
- end
22
-
23
- When /^I reload the datamapper record$/ do
24
- @instance = @instance.class.first(:id => @instance.key)
25
- end
26
-
27
- When /^I delete the datamapper record$/ do
28
- @instance.destroy
29
- end
@@ -1,4 +0,0 @@
1
- When /^I download the file '([^']+)'/ do |url|
2
- @uploader.download!(url)
3
- end
4
-
@@ -1,53 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # EXISTENCE
5
-
6
- Then /^there should be a file at '(.*?)'$/ do |file|
7
- File.exist?(file_path(file)).should be_true
8
- end
9
-
10
- Then /^there should not be a file at '(.*?)'$/ do |file|
11
- File.exist?(file_path(file)).should be_false
12
- end
13
-
14
- Then /^there should be a file called '(.*?)' somewhere in a subdirectory of '(.*?)'$/ do |file, directory|
15
- Dir.glob(File.join(file_path(directory), '**', file)).any?.should be_true
16
- end
17
-
18
- ###
19
- # IDENTICAL
20
-
21
- Then /^the file at '(.*?)' should be identical to the file at '(.*?)'$/ do |one, two|
22
- File.read(file_path(one)).should == File.read(file_path(two))
23
- end
24
-
25
- Then /^the file at '(.*?)' should not be identical to the file at '(.*?)'$/ do |one, two|
26
- File.read(file_path(one)).should_not == File.read(file_path(two))
27
- end
28
-
29
- Then /^the file called '(.*?)' in a subdirectory of '(.*?)' should be identical to the file at '(.*?)'$/ do |file, directory, other|
30
- File.read(Dir.glob(File.join(file_path(directory), '**', file)).first).should == File.read(file_path(other))
31
- end
32
-
33
- Then /^the file called '(.*?)' in a subdirectory of '(.*?)' should not be identical to the file at '(.*?)'$/ do |file, directory, other|
34
- File.read(Dir.glob(File.join(file_path(directory), '**', file)).first).should_not == File.read(file_path(other))
35
- end
36
-
37
- ###
38
- # CONTENT
39
-
40
- Then /^the file called '([^']+)' in a subdirectory of '([^']+)' should contain '([^']+)'$/ do |file, directory, content|
41
- File.read(Dir.glob(File.join(file_path(directory), '**', file)).first).should include(content)
42
- end
43
-
44
- Then /^the file at '([^']+)' should contain '([^']+)'$/ do |path, content|
45
- File.read(file_path(path)).should include(content)
46
- end
47
-
48
- ###
49
- # REVERSING
50
-
51
- Then /^the file at '(.*?)' should be the reverse of the file at '(.*?)'$/ do |one, two|
52
- File.read(file_path(one)).should == File.read(file_path(two)).reverse
53
- end
@@ -1,85 +0,0 @@
1
- # encoding: utf-8
2
-
3
- Given /^an uploader class that uses the '(.*?)' storage$/ do |kind|
4
- @klass = Class.new(CarrierWave::Uploader::Base)
5
- @klass.storage = kind.to_sym
6
- end
7
-
8
- Given /^an instance of that class$/ do
9
- @uploader = @klass.new
10
- end
11
-
12
- Then /^the contents of the file should be '(.*?)'$/ do |contents|
13
- @uploader.read.chomp.should == contents
14
- end
15
-
16
- Given /^that the uploader reverses the filename$/ do
17
- @klass.class_eval do
18
- def filename
19
- super.reverse unless super.blank?
20
- end
21
- end
22
- end
23
-
24
- Given /^that the uploader has the filename overridden to '(.*?)'$/ do |filename|
25
- @klass.class_eval do
26
- define_method(:filename) do
27
- filename
28
- end
29
- end
30
- end
31
-
32
- Given /^that the uploader has the store_dir overridden to '(.*?)'$/ do |store_dir|
33
- @klass.class_eval do
34
- define_method(:store_dir) do
35
- file_path(store_dir)
36
- end
37
- end
38
- end
39
-
40
- Given /^that the version '(.*?)' has the store_dir overridden to '(.*?)'$/ do |version, store_dir|
41
- @klass.versions[version.to_sym].class_eval do
42
- define_method(:store_dir) do
43
- file_path(store_dir)
44
- end
45
- end
46
- end
47
-
48
- Given /^that the uploader class has a version named '(.*?)'$/ do |name|
49
- @klass.version(name)
50
- end
51
-
52
- Given /^yo dawg, I put a version called '(.*?)' in your version called '(.*?)'$/ do |v2, v1|
53
- @klass.version(v1) do
54
- version(v2)
55
- end
56
- end
57
-
58
- Given /^the class has a method called 'reverse' that reverses the contents of a file$/ do
59
- @klass.class_eval do
60
- def reverse
61
- text = File.read(current_path)
62
- File.open(current_path, 'w') { |f| f.write(text.reverse) }
63
- end
64
- end
65
- end
66
-
67
- Given /^the class will process '([a-zA-Z0-9\_\?!]*)'$/ do |name|
68
- @klass.process name.to_sym
69
- end
70
-
71
- Then /^the uploader should have '(.*?)' as its current path$/ do |path|
72
- @uploader.current_path.should == file_path(path)
73
- end
74
-
75
- Then /^the uploader should have the url '(.*?)'$/ do |url|
76
- @uploader.url.should == url
77
- end
78
-
79
- Then /^the uploader's version '(.*?)' should have the url '(.*?)'$/ do |version, url|
80
- @uploader.versions[version.to_sym].url.should == url
81
- end
82
-
83
- Then /^the uploader's nested version '(.*?)' nested in '(.*?)' should have the url '(.*?)'$/ do |v2, v1, url|
84
- @uploader.versions[v1.to_sym].versions[v2.to_sym].url.should == url
85
- end