paperclip 3.0.3 → 3.5.1
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/.gitignore +2 -1
- data/.travis.yml +3 -0
- data/Appraisals +8 -3
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/NEWS +198 -35
- data/README.md +332 -113
- data/features/basic_integration.feature +24 -12
- data/features/migration.feature +94 -0
- data/features/rake_tasks.feature +2 -3
- data/features/step_definitions/attachment_steps.rb +28 -0
- data/features/step_definitions/rails_steps.rb +94 -8
- data/features/step_definitions/s3_steps.rb +1 -1
- data/features/step_definitions/web_steps.rb +3 -3
- data/features/support/fakeweb.rb +4 -1
- data/features/support/file_helpers.rb +10 -0
- data/features/support/rails.rb +18 -2
- data/gemfiles/3.0.gemfile +2 -2
- data/gemfiles/3.1.gemfile +2 -2
- data/gemfiles/3.2.gemfile +2 -2
- data/gemfiles/4.0.gemfile +11 -0
- data/lib/generators/paperclip/templates/paperclip_migration.rb.erb +4 -8
- data/lib/paperclip/attachment.rb +96 -43
- data/lib/paperclip/attachment_registry.rb +57 -0
- data/lib/paperclip/callbacks.rb +2 -2
- data/lib/paperclip/content_type_detector.rb +78 -0
- data/lib/paperclip/file_command_content_type_detector.rb +32 -0
- data/lib/paperclip/filename_cleaner.rb +16 -0
- data/lib/paperclip/geometry.rb +66 -30
- data/lib/paperclip/geometry_detector_factory.rb +41 -0
- data/lib/paperclip/geometry_parser_factory.rb +31 -0
- data/lib/paperclip/glue.rb +2 -8
- data/lib/paperclip/has_attached_file.rb +99 -0
- data/lib/paperclip/helpers.rb +12 -15
- data/lib/paperclip/interpolations/plural_cache.rb +17 -0
- data/lib/paperclip/interpolations.rb +15 -5
- data/lib/paperclip/io_adapters/abstract_adapter.rb +45 -0
- data/lib/paperclip/io_adapters/attachment_adapter.rb +14 -49
- 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/file_adapter.rb +8 -69
- data/lib/paperclip/io_adapters/identity_adapter.rb +1 -1
- data/lib/paperclip/io_adapters/nil_adapter.rb +2 -2
- data/lib/paperclip/io_adapters/stringio_adapter.rb +16 -45
- data/lib/paperclip/io_adapters/uploaded_file_adapter.rb +17 -40
- data/lib/paperclip/io_adapters/uri_adapter.rb +44 -0
- data/lib/paperclip/matchers/have_attached_file_matcher.rb +1 -5
- data/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb +36 -17
- data/lib/paperclip/matchers/validate_attachment_presence_matcher.rb +5 -1
- data/lib/paperclip/matchers.rb +3 -3
- data/lib/paperclip/missing_attachment_styles.rb +11 -16
- data/lib/paperclip/processor.rb +12 -0
- data/lib/paperclip/railtie.rb +5 -1
- data/lib/paperclip/schema.rb +59 -23
- data/lib/paperclip/storage/filesystem.rb +23 -5
- data/lib/paperclip/storage/fog.rb +64 -25
- data/lib/paperclip/storage/s3.rb +93 -52
- data/lib/paperclip/style.rb +2 -2
- data/lib/paperclip/tempfile_factory.rb +21 -0
- data/lib/paperclip/thumbnail.rb +18 -3
- data/lib/paperclip/validators/attachment_content_type_validator.rb +38 -10
- data/lib/paperclip/validators/attachment_presence_validator.rb +8 -8
- data/lib/paperclip/validators/attachment_size_validator.rb +12 -7
- data/lib/paperclip/validators.rb +21 -2
- data/lib/paperclip/version.rb +1 -1
- data/lib/paperclip.rb +15 -44
- data/lib/tasks/paperclip.rake +26 -7
- data/paperclip.gemspec +11 -7
- data/test/attachment_definitions_test.rb +12 -0
- data/test/attachment_processing_test.rb +83 -0
- data/test/attachment_registry_test.rb +77 -0
- data/test/attachment_test.rb +253 -44
- data/test/content_type_detector_test.rb +50 -0
- data/test/file_command_content_type_detector_test.rb +25 -0
- data/test/filename_cleaner_test.rb +14 -0
- data/test/fixtures/animated +0 -0
- data/test/fixtures/animated.unknown +0 -0
- data/test/fixtures/rotated.jpg +0 -0
- data/test/generator_test.rb +26 -24
- data/test/geometry_detector_test.rb +24 -0
- data/test/geometry_parser_test.rb +73 -0
- data/test/geometry_test.rb +55 -4
- data/test/has_attached_file_test.rb +125 -0
- data/test/helper.rb +38 -7
- data/test/integration_test.rb +105 -89
- data/test/interpolations_test.rb +12 -0
- data/test/io_adapters/abstract_adapter_test.rb +58 -0
- data/test/io_adapters/attachment_adapter_test.rb +120 -33
- data/test/io_adapters/data_uri_adapter_test.rb +60 -0
- data/test/io_adapters/empty_string_adapter_test.rb +17 -0
- data/test/io_adapters/file_adapter_test.rb +32 -1
- data/test/io_adapters/stringio_adapter_test.rb +29 -10
- data/test/io_adapters/uploaded_file_adapter_test.rb +53 -5
- data/test/io_adapters/uri_adapter_test.rb +102 -0
- data/test/matchers/validate_attachment_presence_matcher_test.rb +22 -0
- data/test/meta_class_test.rb +32 -0
- data/test/paperclip_missing_attachment_styles_test.rb +4 -8
- data/test/paperclip_test.rb +27 -51
- data/test/plural_cache_test.rb +36 -0
- data/test/processor_test.rb +16 -0
- data/test/rake_test.rb +103 -0
- data/test/schema_test.rb +179 -77
- data/test/storage/filesystem_test.rb +26 -3
- data/test/storage/fog_test.rb +181 -3
- data/test/storage/s3_test.rb +239 -4
- data/test/style_test.rb +18 -14
- data/test/tempfile_factory_test.rb +13 -0
- data/test/thumbnail_test.rb +96 -16
- data/test/validators/attachment_content_type_validator_test.rb +181 -55
- data/test/validators/attachment_size_validator_test.rb +10 -0
- data/test/validators_test.rb +8 -1
- metadata +126 -92
- data/Gemfile.lock +0 -157
- data/features/support/fixtures/.boot_config.rb.swo +0 -0
- data/images.rake +0 -21
- data/lib/.DS_Store +0 -0
- data/lib/paperclip/.DS_Store +0 -0
- data/lib/paperclip/attachment_options.rb +0 -9
- data/lib/paperclip/instance_methods.rb +0 -35
- data/test/attachment_options_test.rb +0 -27
data/Gemfile.lock
DELETED
@@ -1,157 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
paperclip (3.0.3)
|
5
|
-
activemodel (>= 3.0.0)
|
6
|
-
activerecord (>= 3.0.0)
|
7
|
-
activesupport (>= 3.0.0)
|
8
|
-
cocaine (>= 0.0.2)
|
9
|
-
mime-types
|
10
|
-
|
11
|
-
GEM
|
12
|
-
remote: http://rubygems.org/
|
13
|
-
specs:
|
14
|
-
activemodel (3.2.3)
|
15
|
-
activesupport (= 3.2.3)
|
16
|
-
builder (~> 3.0.0)
|
17
|
-
activerecord (3.2.3)
|
18
|
-
activemodel (= 3.2.3)
|
19
|
-
activesupport (= 3.2.3)
|
20
|
-
arel (~> 3.0.2)
|
21
|
-
tzinfo (~> 0.3.29)
|
22
|
-
activesupport (3.2.3)
|
23
|
-
i18n (~> 0.6)
|
24
|
-
multi_json (~> 1.0)
|
25
|
-
addressable (2.2.7)
|
26
|
-
appraisal (0.4.1)
|
27
|
-
bundler
|
28
|
-
rake
|
29
|
-
arel (3.0.2)
|
30
|
-
aruba (0.4.11)
|
31
|
-
childprocess (>= 0.2.3)
|
32
|
-
cucumber (>= 1.1.1)
|
33
|
-
ffi (>= 1.0.11)
|
34
|
-
rspec (>= 2.7.0)
|
35
|
-
aws-sdk (1.4.1)
|
36
|
-
httparty (~> 0.7)
|
37
|
-
json (~> 1.4)
|
38
|
-
nokogiri (>= 1.4.4)
|
39
|
-
uuidtools (~> 2.1)
|
40
|
-
bourne (1.1.2)
|
41
|
-
mocha (= 0.10.5)
|
42
|
-
builder (3.0.0)
|
43
|
-
capybara (1.1.2)
|
44
|
-
mime-types (>= 1.16)
|
45
|
-
nokogiri (>= 1.3.3)
|
46
|
-
rack (>= 1.0.0)
|
47
|
-
rack-test (>= 0.5.4)
|
48
|
-
selenium-webdriver (~> 2.0)
|
49
|
-
xpath (~> 0.1.4)
|
50
|
-
childprocess (0.3.2)
|
51
|
-
ffi (~> 1.0.6)
|
52
|
-
cocaine (0.2.1)
|
53
|
-
coderay (1.0.6)
|
54
|
-
cucumber (1.1.9)
|
55
|
-
builder (>= 2.1.2)
|
56
|
-
diff-lcs (>= 1.1.2)
|
57
|
-
gherkin (~> 2.9.0)
|
58
|
-
json (>= 1.4.6)
|
59
|
-
term-ansicolor (>= 1.0.6)
|
60
|
-
diff-lcs (1.1.3)
|
61
|
-
excon (0.13.4)
|
62
|
-
fakeweb (1.3.0)
|
63
|
-
ffi (1.0.11)
|
64
|
-
fog (1.3.1)
|
65
|
-
builder
|
66
|
-
excon (~> 0.13.0)
|
67
|
-
formatador (~> 0.2.0)
|
68
|
-
mime-types
|
69
|
-
multi_json (~> 1.0)
|
70
|
-
net-scp (~> 1.0.4)
|
71
|
-
net-ssh (>= 2.1.3)
|
72
|
-
nokogiri (~> 1.5.0)
|
73
|
-
ruby-hmac
|
74
|
-
formatador (0.2.1)
|
75
|
-
gherkin (2.9.3)
|
76
|
-
json (>= 1.4.6)
|
77
|
-
httparty (0.8.3)
|
78
|
-
multi_json (~> 1.0)
|
79
|
-
multi_xml
|
80
|
-
i18n (0.6.0)
|
81
|
-
json (1.6.6)
|
82
|
-
launchy (2.1.0)
|
83
|
-
addressable (~> 2.2.6)
|
84
|
-
libwebsocket (0.1.3)
|
85
|
-
addressable
|
86
|
-
metaclass (0.0.1)
|
87
|
-
method_source (0.7.1)
|
88
|
-
mime-types (1.18)
|
89
|
-
mocha (0.10.5)
|
90
|
-
metaclass (~> 0.0.1)
|
91
|
-
multi_json (1.3.2)
|
92
|
-
multi_xml (0.4.4)
|
93
|
-
net-scp (1.0.4)
|
94
|
-
net-ssh (>= 1.99.1)
|
95
|
-
net-ssh (2.3.0)
|
96
|
-
nokogiri (1.5.2)
|
97
|
-
pry (0.9.9.3)
|
98
|
-
coderay (~> 1.0.5)
|
99
|
-
method_source (~> 0.7.1)
|
100
|
-
slop (>= 2.4.4, < 3)
|
101
|
-
rack (1.4.1)
|
102
|
-
rack-test (0.6.1)
|
103
|
-
rack (>= 1.0)
|
104
|
-
rake (0.9.2.2)
|
105
|
-
rspec (2.9.0)
|
106
|
-
rspec-core (~> 2.9.0)
|
107
|
-
rspec-expectations (~> 2.9.0)
|
108
|
-
rspec-mocks (~> 2.9.0)
|
109
|
-
rspec-core (2.9.0)
|
110
|
-
rspec-expectations (2.9.1)
|
111
|
-
diff-lcs (~> 1.1.3)
|
112
|
-
rspec-mocks (2.9.0)
|
113
|
-
ruby-hmac (0.4.0)
|
114
|
-
rubyzip (0.9.7)
|
115
|
-
selenium-webdriver (2.21.2)
|
116
|
-
childprocess (>= 0.2.5)
|
117
|
-
ffi (~> 1.0)
|
118
|
-
libwebsocket (~> 0.1.3)
|
119
|
-
multi_json (~> 1.0)
|
120
|
-
rubyzip
|
121
|
-
shoulda (3.0.1)
|
122
|
-
shoulda-context (~> 1.0.0)
|
123
|
-
shoulda-matchers (~> 1.0.0)
|
124
|
-
shoulda-context (1.0.0)
|
125
|
-
shoulda-matchers (1.0.0)
|
126
|
-
slop (2.4.4)
|
127
|
-
sqlite3 (1.3.6)
|
128
|
-
term-ansicolor (1.0.7)
|
129
|
-
tzinfo (0.3.33)
|
130
|
-
uuidtools (2.1.2)
|
131
|
-
xpath (0.1.4)
|
132
|
-
nokogiri (~> 1.3)
|
133
|
-
|
134
|
-
PLATFORMS
|
135
|
-
ruby
|
136
|
-
|
137
|
-
DEPENDENCIES
|
138
|
-
activerecord-jdbcsqlite3-adapter
|
139
|
-
appraisal
|
140
|
-
aruba
|
141
|
-
aws-sdk
|
142
|
-
bourne
|
143
|
-
bundler
|
144
|
-
capybara
|
145
|
-
cocaine (~> 0.2)
|
146
|
-
cucumber (~> 1.1.0)
|
147
|
-
fakeweb
|
148
|
-
fog
|
149
|
-
jruby-openssl
|
150
|
-
launchy
|
151
|
-
mocha
|
152
|
-
nokogiri
|
153
|
-
paperclip!
|
154
|
-
pry
|
155
|
-
rake
|
156
|
-
shoulda
|
157
|
-
sqlite3
|
Binary file
|
data/images.rake
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
namespace :images do
|
2
|
-
desc "Regenerate images"
|
3
|
-
task :regenerate => :environment do
|
4
|
-
require 'open-uri'
|
5
|
-
OpportunityPhoto.all.each do |photo|
|
6
|
-
begin
|
7
|
-
old_name = photo.image_file_name
|
8
|
-
new_image = open(photo.image.url(:original, escape: false))
|
9
|
-
class << new_image
|
10
|
-
def original_filename; @original_filename; end
|
11
|
-
def original_filename=(name); @original_filename = name; end
|
12
|
-
end
|
13
|
-
new_image.original_filename = old_name
|
14
|
-
photo.image = new_image
|
15
|
-
photo.save
|
16
|
-
rescue => e
|
17
|
-
puts "ERROR: #{e.message} while processing #{photo.id}"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/lib/.DS_Store
DELETED
Binary file
|
data/lib/paperclip/.DS_Store
DELETED
Binary file
|
@@ -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, self.class.attachment_definitions[name])
|
6
|
-
end
|
7
|
-
|
8
|
-
def each_attachment
|
9
|
-
self.class.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
|