carrierwave 0.3.2 → 0.3.3

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 (41) hide show
  1. data/History.txt +68 -0
  2. data/Manifest.txt +89 -0
  3. data/README.rdoc +39 -4
  4. data/Rakefile +32 -115
  5. data/carrierwave.gemspec +63 -0
  6. data/cucumber.yml +2 -0
  7. data/features/caching.feature +28 -0
  8. data/features/file_storage.feature +37 -0
  9. data/features/file_storage_overridden_filename.feature +38 -0
  10. data/features/file_storage_overridden_store_dir.feature +38 -0
  11. data/features/file_storage_reversing_processor.feature +43 -0
  12. data/features/fixtures/bork.txt +1 -0
  13. data/features/fixtures/monkey.txt +1 -0
  14. data/features/mount_activerecord.feature +46 -0
  15. data/features/mount_datamapper.feature +46 -0
  16. data/features/step_definitions/activerecord_steps.rb +22 -0
  17. data/features/step_definitions/caching_steps.rb +14 -0
  18. data/features/step_definitions/datamapper_steps.rb +29 -0
  19. data/features/step_definitions/file_steps.rb +42 -0
  20. data/features/step_definitions/general_steps.rb +80 -0
  21. data/features/step_definitions/mount_steps.rb +19 -0
  22. data/features/step_definitions/store_steps.rb +18 -0
  23. data/features/support/activerecord.rb +30 -0
  24. data/features/support/datamapper.rb +7 -0
  25. data/features/support/env.rb +35 -0
  26. data/features/versions_basics.feature +50 -0
  27. data/features/versions_nested_versions.feature +70 -0
  28. data/features/versions_overridden_filename.feature +51 -0
  29. data/features/versions_overriden_store_dir.feature +41 -0
  30. data/lib/carrierwave.rb +8 -0
  31. data/lib/carrierwave/orm/mongomapper.rb +27 -0
  32. data/lib/carrierwave/processing/rmagick.rb +6 -4
  33. data/lib/carrierwave/storage/abstract.rb +5 -5
  34. data/lib/carrierwave/storage/s3.rb +17 -1
  35. data/script/console +10 -0
  36. data/script/destroy +14 -0
  37. data/script/generate +14 -0
  38. data/spec/orm/mongomapper_spec.rb +184 -0
  39. metadata +157 -20
  40. data/LICENSE +0 -20
  41. data/TODO +0 -0
data/cucumber.yml ADDED
@@ -0,0 +1,2 @@
1
+ default: --format pretty --no-source
2
+ html: --format html --out features.html
@@ -0,0 +1,28 @@
1
+ Feature: uploader with file storage
2
+ In order to be able to temporarily store files to disk
3
+ As a developer using CarrierWave
4
+ I want to cache files
5
+
6
+ Scenario: cache a file
7
+ Given an uploader class that uses the 'file' storage
8
+ And an instance of that class
9
+ When I cache the file 'fixtures/bork.txt'
10
+ Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
11
+ And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
12
+
13
+ Scenario: cache two files in succession
14
+ Given an uploader class that uses the 'file' storage
15
+ And an instance of that class
16
+ When I cache the file 'fixtures/bork.txt'
17
+ Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
18
+ And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
19
+ When I cache the file 'fixtures/monkey.txt'
20
+ Then there should be a file called 'monkey.txt' somewhere in a subdirectory of 'public/uploads/tmp'
21
+ And the file called 'monkey.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/monkey.txt'
22
+
23
+ Scenario: retrieving a file from cache
24
+ Given an uploader class that uses the 'file' storage
25
+ And an instance of that class
26
+ And the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/bork.txt'
27
+ When I retrieve the cache name '20090212-2343-8336-0348/bork.txt' from the cache
28
+ Then the uploader should have 'public/uploads/tmp/20090212-2343-8336-0348/bork.txt' as its current path
@@ -0,0 +1,37 @@
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 'file' 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 there should be a file at 'public/uploads/bork.txt'
13
+ And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
14
+
15
+ Scenario: store two files in succession
16
+ When I store the file 'fixtures/bork.txt'
17
+ Then there should be a file at 'public/uploads/bork.txt'
18
+ And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
19
+ When I store the file 'fixtures/monkey.txt'
20
+ Then there should be a file at 'public/uploads/monkey.txt'
21
+ And the file at 'public/uploads/monkey.txt' should be identical to the file at 'fixtures/monkey.txt'
22
+
23
+ Scenario: cache a file and then store it
24
+ When I cache the file 'fixtures/bork.txt'
25
+ Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'
26
+ And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt'
27
+ And there should not be a file at 'public/uploads/bork.txt'
28
+ When I store the file
29
+ Then there should be a file at 'public/uploads/bork.txt'
30
+ And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
31
+
32
+ Scenario: retrieving a file from cache then storing
33
+ Given the file 'fixtures/bork.txt' is cached file at 'public/uploads/tmp/20090212-2343-8336-0348/bork.txt'
34
+ When I retrieve the cache name '20090212-2343-8336-0348/bork.txt' from the cache
35
+ And I store the file
36
+ Then there should be a file at 'public/uploads/bork.txt'
37
+ And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt'
@@ -0,0 +1,38 @@
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'
@@ -0,0 +1,38 @@
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'
@@ -0,0 +1,43 @@
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'
@@ -0,0 +1 @@
1
+ this is a file
@@ -0,0 +1 @@
1
+ this is another file
@@ -0,0 +1,46 @@
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'
@@ -0,0 +1,46 @@
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'
@@ -0,0 +1,22 @@
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
@@ -0,0 +1,14 @@
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
@@ -0,0 +1,29 @@
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
@@ -0,0 +1,42 @@
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
+ # REVERSING
39
+
40
+ Then /^the file at '(.*?)' should be the reverse of the file at '(.*?)'$/ do |one, two|
41
+ File.read(file_path(one)).should == File.read(file_path(two)).reverse
42
+ end
@@ -0,0 +1,80 @@
1
+ # encoding: utf-8
2
+
3
+ Given /^an uploader class that uses the 'file' storage$/ do
4
+ @klass = Class.new(CarrierWave::Uploader::Base)
5
+ end
6
+
7
+ Given /^an instance of that class$/ do
8
+ @uploader = @klass.new
9
+ end
10
+
11
+ Given /^that the uploader reverses the filename$/ do
12
+ @klass.class_eval do
13
+ def filename
14
+ super.reverse unless super.blank?
15
+ end
16
+ end
17
+ end
18
+
19
+ Given /^that the uploader has the filename overridden to '(.*?)'$/ do |filename|
20
+ @klass.class_eval do
21
+ define_method(:filename) do
22
+ filename
23
+ end
24
+ end
25
+ end
26
+
27
+ Given /^that the uploader has the store_dir overridden to '(.*?)'$/ do |store_dir|
28
+ @klass.class_eval do
29
+ define_method(:store_dir) do
30
+ file_path(store_dir)
31
+ end
32
+ end
33
+ end
34
+
35
+ Given /^that the version '(.*?)' has the store_dir overridden to '(.*?)'$/ do |version, store_dir|
36
+ @klass.versions[version.to_sym].class_eval do
37
+ define_method(:store_dir) do
38
+ file_path(store_dir)
39
+ end
40
+ end
41
+ end
42
+
43
+ Given /^that the uploader class has a version named '(.*?)'$/ do |name|
44
+ @klass.version(name)
45
+ end
46
+
47
+ Given /^yo dawg, I put a version called '(.*?)' in your version called '(.*?)'$/ do |v2, v1|
48
+ @klass.version(v1) do
49
+ version(v2)
50
+ end
51
+ end
52
+
53
+ Given /^the class has a method called 'reverse' that reverses the contents of a file$/ do
54
+ @klass.class_eval do
55
+ def reverse
56
+ text = File.read(current_path)
57
+ File.open(current_path, 'w') { |f| f.write(text.reverse) }
58
+ end
59
+ end
60
+ end
61
+
62
+ Given /^the class will process '([a-zA-Z0-9\_\?!]*)'$/ do |name|
63
+ @klass.process name.to_sym
64
+ end
65
+
66
+ Then /^the uploader should have '(.*?)' as its current path$/ do |path|
67
+ @uploader.current_path.should == file_path(path)
68
+ end
69
+
70
+ Then /^the uploader should have the url '(.*?)'$/ do |url|
71
+ @uploader.url.should == url
72
+ end
73
+
74
+ Then /^the uploader's version '(.*?)' should have the url '(.*?)'$/ do |version, url|
75
+ @uploader.versions[version.to_sym].url.should == url
76
+ end
77
+
78
+ Then /^the uploader's nested version '(.*?)' nested in '(.*?)' should have the url '(.*?)'$/ do |v2, v1, url|
79
+ @uploader.versions[v1.to_sym].versions[v2.to_sym].url.should == url
80
+ end