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,202 +0,0 @@
1
- # encoding: utf-8
2
- require File.dirname(__FILE__) + '/../spec_helper'
3
-
4
- require 'carrierwave/orm/mongomapper'
5
-
6
- MongoMapper.database = "carrierwave_test"
7
-
8
- describe CarrierWave::MongoMapper do
9
-
10
- before do
11
- uploader = Class.new(CarrierWave::Uploader::Base)
12
-
13
- @class = Class.new
14
- @class.class_eval do
15
- include MongoMapper::Document
16
- mount_uploader :image, uploader
17
- end
18
-
19
- @uploader = uploader
20
- end
21
-
22
- describe '#image' do
23
-
24
- context "when nothing is assigned" do
25
-
26
- before do
27
- @document = @class.new
28
- end
29
-
30
- it "returns a blank uploader" do
31
- @document.image.should be_blank
32
- end
33
-
34
- end
35
-
36
- context "when an empty string is assigned" do
37
-
38
- before do
39
- @document = @class.new(:image_filename => "")
40
- @document.save
41
- end
42
-
43
- it "returns a blank uploader" do
44
- @saved_doc = @class.first
45
- @saved_doc.image.should be_blank
46
- end
47
-
48
- end
49
-
50
- context "when a filename is saved in the database" do
51
-
52
- before do
53
- @document = @class.new(:image_filename => "test.jpg")
54
- @document.save
55
- @doc = @class.first
56
- end
57
-
58
- it "returns an uploader" do
59
- @doc.image.should be_an_instance_of(@uploader)
60
- end
61
-
62
- it "sets the path to the store directory" do
63
- @doc.image.current_path.should == public_path('uploads/test.jpg')
64
- end
65
-
66
- end
67
-
68
- end
69
-
70
- describe '#image=' do
71
-
72
- before do
73
- @doc = @class.new
74
- end
75
-
76
- context "when nil is assigned" do
77
-
78
- it "does not set the value" do
79
- @doc.image = nil
80
- @doc.image.should be_blank
81
- end
82
-
83
- end
84
-
85
- context "when an empty string is assigned" do
86
-
87
- it "does not set the value" do
88
- @doc.image = ''
89
- @doc.image.should be_blank
90
- end
91
-
92
- end
93
-
94
- context "when a file is assigned" do
95
-
96
- it "should cache a file" do
97
- @doc.image = stub_file('test.jpeg')
98
- @doc.image.should be_an_instance_of(@uploader)
99
- end
100
-
101
- it "should write nothing to the database, to prevent overriden filenames to fail because of unassigned attributes" do
102
- @doc[:image_filename].should be_nil
103
- end
104
-
105
- it "should copy a file into into the cache directory" do
106
- @doc.image = stub_file('test.jpeg')
107
- @doc.image.current_path.should =~ /^#{public_path('uploads/tmp')}/
108
- end
109
-
110
- end
111
-
112
- end
113
-
114
- describe "#save" do
115
-
116
- before do
117
- @doc = @class.new
118
- end
119
-
120
- context "when no file is assigned" do
121
-
122
- it "image is blank" do
123
- @doc.save
124
- @doc.image.should be_blank
125
- end
126
-
127
- end
128
-
129
- context "when a file is assigned" do
130
-
131
- it "copies the file to the upload directory" do
132
- @doc.image = stub_file('test.jpg')
133
- @doc.save
134
- @doc.image.should be_an_instance_of(@uploader)
135
- @doc.image.current_path.should == public_path('uploads/test.jpg')
136
- end
137
-
138
- it "saves the filename in the database" do
139
- @doc.image = stub_file('test.jpg')
140
- @doc.save
141
- @doc[:image_filename].should == 'test.jpg'
142
- end
143
-
144
- context "when remove_image? is true" do
145
-
146
- it "removes the image" do
147
- @doc.image = stub_file('test.jpeg')
148
- @doc.save
149
- @doc.remove_image = true
150
- @doc.save
151
- @doc.image.should be_blank
152
- @doc[:image_filename].should == ''
153
- end
154
-
155
- end
156
-
157
- end
158
-
159
- end
160
-
161
- describe '#destroy' do
162
-
163
- before do
164
- @doc = @class.new
165
- end
166
-
167
- describe "when file assigned" do
168
-
169
- it "removes the file from the filesystem" do
170
- @doc.image = stub_file('test.jpeg')
171
- @doc.save.should be_true
172
- File.exist?(public_path('uploads/test.jpeg')).should be_true
173
- @doc.image.should be_an_instance_of(@uploader)
174
- @doc.image.current_path.should == public_path('uploads/test.jpeg')
175
- @doc.destroy
176
- File.exist?(public_path('uploads/test.jpeg')).should be_false
177
- end
178
-
179
- end
180
-
181
- describe "when file is not assigned" do
182
-
183
- it "deletes the instance of @class after save" do
184
- @doc.save
185
- @class.count.should eql(1)
186
- @doc.destroy
187
- end
188
-
189
- it "deletes the instance of @class after save and then re-looking up the instance" do
190
- # this fails with TypeError in 'CarrierWave::MongoMapper#destroy when file is not assigned deletes the instance of @class' can't modify frozen object
191
- @doc.save
192
- @class.count.should eql(1)
193
- @doc = @class.first
194
- @doc.destroy
195
- end
196
-
197
- end
198
-
199
- end
200
-
201
-
202
- end
@@ -1,183 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.dirname(__FILE__) + '/../spec_helper'
4
-
5
- require 'carrierwave/orm/sequel'
6
-
7
- DB = Sequel.sqlite
8
-
9
- describe CarrierWave::Sequel do
10
-
11
- def setup_variables_for_class(klass)
12
- uploader = Class.new(CarrierWave::Uploader::Base)
13
- klass.mount_uploader(:image, uploader)
14
- model = klass.new
15
- [klass, uploader, model]
16
- end
17
-
18
- describe '.mount_uploader' do
19
-
20
- before(:all) do
21
- DB.create_table :events do
22
- primary_key :id
23
- column :image, :string
24
- column :textfile, :string
25
- end
26
- end
27
-
28
- after(:all) do
29
- DB.drop_table :events
30
- end
31
-
32
- before(:each) do
33
- @class = Class.new(Sequel::Model)
34
- @class.set_dataset :events
35
- @class, @uploader, @event = setup_variables_for_class(@class)
36
- end
37
-
38
- after(:each) { @class.delete }
39
-
40
- describe '#image' do
41
-
42
- it "should return blank uploader when nothing has been assigned" do
43
- @event.image.should be_blank
44
- end
45
-
46
- it "should return blank uploader when an empty string has been assigned" do
47
- @event[:image] = ''
48
- @event.save
49
- @event.reload
50
- @event.image.should be_blank
51
- end
52
-
53
- it "should retrieve a file from the storage if a value is stored in the database" do
54
- @event[:image] = 'test.jpeg'
55
- @event.save
56
- @event.reload
57
- @event.image.should be_an_instance_of(@uploader)
58
- end
59
-
60
- it "should set the path to the store dir" do
61
- @event[:image] = 'test.jpeg'
62
- @event.save
63
- @event.reload
64
- @event.image.current_path.should == public_path('uploads/test.jpeg')
65
- end
66
-
67
- end
68
-
69
- describe '#image=' do
70
-
71
- it "should cache a file" do
72
- @event.image = stub_file('test.jpeg')
73
- @event.image.should be_an_instance_of(@uploader)
74
- end
75
-
76
- it "should write nothing to the database, to prevent overriden filenames to fail because of unassigned attributes" do
77
- @event[:image].should be_nil
78
- end
79
-
80
- it "should copy a file into into the cache directory" do
81
- @event.image = stub_file('test.jpeg')
82
- @event.image.current_path.should =~ /^#{public_path('uploads/tmp')}/
83
- end
84
-
85
- it "should do nothing when nil is assigned" do
86
- @event.image = nil
87
- @event.image.should be_blank
88
- end
89
-
90
- it "should do nothing when an empty string is assigned" do
91
- @event.image = ''
92
- @event.image.should be_blank
93
- end
94
-
95
- end
96
-
97
- describe '#save' do
98
-
99
- it "should do nothing when no file has been assigned" do
100
- @event.save.should be_true
101
- @event.image.should be_blank
102
- end
103
-
104
- it "should copy the file to the upload directory when a file has been assigned" do
105
- @event.image = stub_file('test.jpeg')
106
- @event.save.should be_true
107
- @event.image.should be_an_instance_of(@uploader)
108
- @event.image.current_path.should == public_path('uploads/test.jpeg')
109
- end
110
-
111
- describe 'with validation' do
112
-
113
- before do
114
- @class.class_eval do
115
- def validate
116
- errors.add(:image, 'FAIL!')
117
- end
118
- end
119
- # Turn off raising the exceptions on save
120
- @event.raise_on_save_failure = false
121
- end
122
-
123
- it "should do nothing when a validation fails" do
124
- @event.image = stub_file('test.jpeg')
125
- @event.should_not be_valid
126
- @event.save
127
- @event.should be_new
128
- @event.image.should be_an_instance_of(@uploader)
129
- @event.image.current_path.should =~ /^#{public_path('uploads/tmp')}/
130
- end
131
- end
132
-
133
- it "should assign the filename to the database" do
134
- @event.image = stub_file('test.jpeg')
135
- @event.save.should be_true
136
- @event.reload
137
- @event[:image].should == 'test.jpeg'
138
- end
139
-
140
- it "should remove the image if remove_image? returns true" do
141
- @event.image = stub_file('test.jpeg')
142
- @event.save
143
- @event.remove_image = true
144
- @event.save
145
- @event.reload
146
- @event.image.should be_blank
147
- @event[:image].should == ''
148
- end
149
- end
150
-
151
- describe 'with overriddent filename' do
152
-
153
- describe '#save' do
154
-
155
- before do
156
- @uploader.class_eval do
157
- def filename
158
- model.name + File.extname(super)
159
- end
160
- end
161
- @event.stub!(:name).and_return('jonas')
162
- end
163
-
164
- it "should copy the file to the upload directory when a file has been assigned" do
165
- @event.image = stub_file('test.jpeg')
166
- @event.save.should be_true
167
- @event.image.should be_an_instance_of(@uploader)
168
- @event.image.current_path.should == public_path('uploads/jonas.jpeg')
169
- end
170
-
171
- it "should assign an overridden filename to the database" do
172
- @event.image = stub_file('test.jpeg')
173
- @event.save.should be_true
174
- @event.reload
175
- @event[:image].should == 'jonas.jpeg'
176
- end
177
-
178
- end
179
-
180
- end
181
-
182
- end
183
- end
@@ -1,56 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.dirname(__FILE__) + '/../spec_helper'
4
-
5
- describe CarrierWave::ImageScience do
6
-
7
- before do
8
- @klass = Class.new do
9
- include CarrierWave::ImageScience
10
- end
11
- @instance = @klass.new
12
- FileUtils.cp(file_path('landscape.jpg'), file_path('landscape_copy.jpg'))
13
- @instance.stub(:current_path).and_return(file_path('landscape_copy.jpg'))
14
- end
15
-
16
- after do
17
- FileUtils.rm(file_path('landscape_copy.jpg'))
18
- end
19
-
20
- describe '#resize_to_fill' do
21
- it "should resize the image to exactly the given dimensions" do
22
- @instance.resize_to_fill(200, 200)
23
- @instance.should have_dimensions(200, 200)
24
- end
25
-
26
- it "should scale up the image if it smaller than the given dimensions" do
27
- @instance.resize_to_fill(1000, 1000)
28
- @instance.should have_dimensions(1000, 1000)
29
- end
30
- end
31
-
32
- describe '#resize_to_fit' do
33
- it "should resize the image to fit within the given dimensions" do
34
- @instance.resize_to_fit(200, 200)
35
- @instance.should have_dimensions(200, 150)
36
- end
37
-
38
- it "should scale up the image if it smaller than the given dimensions" do
39
- @instance.resize_to_fit(1000, 1000)
40
- @instance.should have_dimensions(1000, 750)
41
- end
42
- end
43
-
44
- describe '#resize_to_limit' do
45
- it "should resize the image to fit within the given dimensions" do
46
- @instance.resize_to_limit(200, 200)
47
- @instance.should have_dimensions(200, 150)
48
- end
49
-
50
- it "should not scale up the image if it smaller than the given dimensions" do
51
- @instance.resize_to_limit(1000, 1000)
52
- @instance.should have_dimensions(640, 480)
53
- end
54
- end
55
-
56
- end
@@ -1,76 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.dirname(__FILE__) + '/../spec_helper'
4
-
5
- describe CarrierWave::MiniMagick do
6
-
7
- before do
8
- @klass = Class.new do
9
- include CarrierWave::MiniMagick
10
- end
11
- @instance = @klass.new
12
- FileUtils.cp(file_path('landscape.jpg'), file_path('landscape_copy.jpg'))
13
- @instance.stub(:current_path).and_return(file_path('landscape_copy.jpg'))
14
- end
15
-
16
- after do
17
- FileUtils.rm(file_path('landscape_copy.jpg'))
18
- end
19
-
20
- describe "#convert" do
21
- it "should convert from one format to another" do
22
- @instance.convert('png')
23
- img = ::MiniMagick::Image.from_file(@instance.current_path)
24
- img['format'].should =~ /PNG/
25
- end
26
- end
27
-
28
- describe '#resize_to_fill' do
29
- it "should resize the image to exactly the given dimensions" do
30
- @instance.resize_to_fill(200, 200)
31
- @instance.should have_dimensions(200, 200)
32
- end
33
-
34
- it "should scale up the image if it smaller than the given dimensions" do
35
- @instance.resize_to_fill(1000, 1000)
36
- @instance.should have_dimensions(1000, 1000)
37
- end
38
- end
39
-
40
- describe '#resize_and_pad' do
41
- it "should resize the image to exactly the given dimensions" do
42
- @instance.resize_and_pad(200, 200)
43
- @instance.should have_dimensions(200, 200)
44
- end
45
-
46
- it "should scale up the image if it smaller than the given dimensions" do
47
- @instance.resize_and_pad(1000, 1000)
48
- @instance.should have_dimensions(1000, 1000)
49
- end
50
- end
51
-
52
- describe '#resize_to_fit' do
53
- it "should resize the image to fit within the given dimensions" do
54
- @instance.resize_to_fit(200, 200)
55
- @instance.should have_dimensions(200, 150)
56
- end
57
-
58
- it "should scale up the image if it smaller than the given dimensions" do
59
- @instance.resize_to_fit(1000, 1000)
60
- @instance.should have_dimensions(1000, 750)
61
- end
62
- end
63
-
64
- describe '#resize_to_limit' do
65
- it "should resize the image to fit within the given dimensions" do
66
- @instance.resize_to_limit(200, 200)
67
- @instance.should have_dimensions(200, 150)
68
- end
69
-
70
- it "should not scale up the image if it smaller than the given dimensions" do
71
- @instance.resize_to_limit(1000, 1000)
72
- @instance.should have_dimensions(640, 480)
73
- end
74
- end
75
-
76
- end