paperclip 3.4.2 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of paperclip might be problematic. Click here for more details.
- checksums.yaml +15 -0
- data/.travis.yml +0 -1
- data/Appraisals +4 -4
- data/NEWS +16 -0
- data/README.md +21 -2
- data/features/step_definitions/rails_steps.rb +9 -0
- data/features/step_definitions/s3_steps.rb +1 -1
- data/features/support/fakeweb.rb +4 -1
- data/lib/paperclip.rb +6 -42
- data/lib/paperclip/attachment.rb +25 -27
- data/lib/paperclip/filename_cleaner.rb +16 -0
- data/lib/paperclip/glue.rb +0 -1
- data/lib/paperclip/has_attached_file.rb +86 -0
- data/lib/paperclip/io_adapters/abstract_adapter.rb +8 -0
- data/lib/paperclip/io_adapters/data_uri_adapter.rb +27 -0
- data/lib/paperclip/io_adapters/empty_string_adapter.rb +18 -0
- data/lib/paperclip/io_adapters/stringio_adapter.rb +3 -3
- data/lib/paperclip/matchers/have_attached_file_matcher.rb +1 -5
- data/lib/paperclip/missing_attachment_styles.rb +11 -16
- data/lib/paperclip/storage/filesystem.rb +7 -3
- data/lib/paperclip/storage/s3.rb +2 -0
- data/lib/paperclip/tasks/attachments.rb +59 -0
- data/lib/paperclip/validators.rb +21 -2
- data/lib/paperclip/validators/attachment_content_type_validator.rb +9 -2
- data/lib/paperclip/validators/attachment_presence_validator.rb +8 -8
- data/lib/paperclip/validators/attachment_size_validator.rb +12 -7
- data/lib/paperclip/version.rb +1 -1
- data/lib/tasks/paperclip.rake +24 -6
- data/paperclip.gemspec +5 -3
- data/test/attachment_processing_test.rb +69 -15
- data/test/attachment_test.rb +49 -0
- data/test/filename_cleaner_test.rb +14 -0
- data/test/has_attached_file_test.rb +109 -0
- data/test/helper.rb +1 -1
- data/test/integration_test.rb +1 -65
- data/test/io_adapters/abstract_adapter_test.rb +8 -0
- data/test/io_adapters/data_uri_adapter_test.rb +60 -0
- data/test/io_adapters/empty_string_adapter_test.rb +17 -0
- data/test/paperclip_missing_attachment_styles_test.rb +4 -8
- data/test/paperclip_test.rb +0 -5
- data/test/rake_test.rb +103 -0
- data/test/storage/s3_test.rb +13 -1
- data/test/tasks/attachments_test.rb +77 -0
- data/test/validators/attachment_content_type_validator_test.rb +26 -0
- data/test/validators/attachment_size_validator_test.rb +10 -0
- data/test/validators_test.rb +8 -1
- metadata +56 -77
- data/lib/paperclip/attachment_options.rb +0 -9
- data/lib/paperclip/instance_methods.rb +0 -35
- data/test/attachment_options_test.rb +0 -27
@@ -1,35 +0,0 @@
|
|
1
|
-
module Paperclip
|
2
|
-
module InstanceMethods #:nodoc:
|
3
|
-
def attachment_for name
|
4
|
-
@_paperclip_attachments ||= {}
|
5
|
-
@_paperclip_attachments[name] ||= Attachment.new(name, self, attachment_definitions[name])
|
6
|
-
end
|
7
|
-
|
8
|
-
def each_attachment
|
9
|
-
self.attachment_definitions.each do |name, definition|
|
10
|
-
yield(name, attachment_for(name))
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def save_attached_files
|
15
|
-
Paperclip.log("Saving attachments.")
|
16
|
-
each_attachment do |name, attachment|
|
17
|
-
attachment.send(:save)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def destroy_attached_files
|
22
|
-
Paperclip.log("Deleting attachments.")
|
23
|
-
each_attachment do |name, attachment|
|
24
|
-
attachment.send(:flush_deletes)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def prepare_for_destroy
|
29
|
-
Paperclip.log("Scheduling attachments for deletion.")
|
30
|
-
each_attachment do |name, attachment|
|
31
|
-
attachment.send(:queue_all_for_delete)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require './test/helper'
|
2
|
-
|
3
|
-
class AttachmentOptionsTest < Test::Unit::TestCase
|
4
|
-
should "be a Hash" do
|
5
|
-
assert_kind_of Hash, Paperclip::AttachmentOptions.new({})
|
6
|
-
end
|
7
|
-
|
8
|
-
should "respond to []" do
|
9
|
-
assert Paperclip::AttachmentOptions.new({}).respond_to?(:[])
|
10
|
-
end
|
11
|
-
|
12
|
-
should "deliver the specified options through []" do
|
13
|
-
intended_options = {:specific_key => "specific value"}
|
14
|
-
attachment_options = Paperclip::AttachmentOptions.new(intended_options)
|
15
|
-
assert_equal "specific value", attachment_options[:specific_key]
|
16
|
-
end
|
17
|
-
|
18
|
-
should "respond to []=" do
|
19
|
-
assert Paperclip::AttachmentOptions.new({}).respond_to?(:[]=)
|
20
|
-
end
|
21
|
-
|
22
|
-
should "remember options set with []=" do
|
23
|
-
attachment_options = Paperclip::AttachmentOptions.new({})
|
24
|
-
attachment_options[:foo] = "bar"
|
25
|
-
assert_equal "bar", attachment_options[:foo]
|
26
|
-
end
|
27
|
-
end
|