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.

Files changed (50) hide show
  1. checksums.yaml +15 -0
  2. data/.travis.yml +0 -1
  3. data/Appraisals +4 -4
  4. data/NEWS +16 -0
  5. data/README.md +21 -2
  6. data/features/step_definitions/rails_steps.rb +9 -0
  7. data/features/step_definitions/s3_steps.rb +1 -1
  8. data/features/support/fakeweb.rb +4 -1
  9. data/lib/paperclip.rb +6 -42
  10. data/lib/paperclip/attachment.rb +25 -27
  11. data/lib/paperclip/filename_cleaner.rb +16 -0
  12. data/lib/paperclip/glue.rb +0 -1
  13. data/lib/paperclip/has_attached_file.rb +86 -0
  14. data/lib/paperclip/io_adapters/abstract_adapter.rb +8 -0
  15. data/lib/paperclip/io_adapters/data_uri_adapter.rb +27 -0
  16. data/lib/paperclip/io_adapters/empty_string_adapter.rb +18 -0
  17. data/lib/paperclip/io_adapters/stringio_adapter.rb +3 -3
  18. data/lib/paperclip/matchers/have_attached_file_matcher.rb +1 -5
  19. data/lib/paperclip/missing_attachment_styles.rb +11 -16
  20. data/lib/paperclip/storage/filesystem.rb +7 -3
  21. data/lib/paperclip/storage/s3.rb +2 -0
  22. data/lib/paperclip/tasks/attachments.rb +59 -0
  23. data/lib/paperclip/validators.rb +21 -2
  24. data/lib/paperclip/validators/attachment_content_type_validator.rb +9 -2
  25. data/lib/paperclip/validators/attachment_presence_validator.rb +8 -8
  26. data/lib/paperclip/validators/attachment_size_validator.rb +12 -7
  27. data/lib/paperclip/version.rb +1 -1
  28. data/lib/tasks/paperclip.rake +24 -6
  29. data/paperclip.gemspec +5 -3
  30. data/test/attachment_processing_test.rb +69 -15
  31. data/test/attachment_test.rb +49 -0
  32. data/test/filename_cleaner_test.rb +14 -0
  33. data/test/has_attached_file_test.rb +109 -0
  34. data/test/helper.rb +1 -1
  35. data/test/integration_test.rb +1 -65
  36. data/test/io_adapters/abstract_adapter_test.rb +8 -0
  37. data/test/io_adapters/data_uri_adapter_test.rb +60 -0
  38. data/test/io_adapters/empty_string_adapter_test.rb +17 -0
  39. data/test/paperclip_missing_attachment_styles_test.rb +4 -8
  40. data/test/paperclip_test.rb +0 -5
  41. data/test/rake_test.rb +103 -0
  42. data/test/storage/s3_test.rb +13 -1
  43. data/test/tasks/attachments_test.rb +77 -0
  44. data/test/validators/attachment_content_type_validator_test.rb +26 -0
  45. data/test/validators/attachment_size_validator_test.rb +10 -0
  46. data/test/validators_test.rb +8 -1
  47. metadata +56 -77
  48. data/lib/paperclip/attachment_options.rb +0 -9
  49. data/lib/paperclip/instance_methods.rb +0 -35
  50. data/test/attachment_options_test.rb +0 -27
@@ -1,9 +0,0 @@
1
- module Paperclip
2
- class AttachmentOptions < Hash
3
- def initialize(options)
4
- options.each do |k, v|
5
- self.[]=(k, v)
6
- end
7
- end
8
- end
9
- end
@@ -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