paperclip 2.4.0 → 2.4.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.

data/README.md CHANGED
@@ -49,7 +49,7 @@ well with gems.
49
49
 
50
50
  Include the gem in your Gemfile:
51
51
 
52
- gem "paperclip", "~> 2.3"
52
+ gem "paperclip", "~> 2.4"
53
53
 
54
54
  Or, if you don't use Bundler (though you probably should, even in Rails 2), with config.gem
55
55
 
@@ -57,7 +57,7 @@ Or, if you don't use Bundler (though you probably should, even in Rails 2), with
57
57
  ...
58
58
  Rails::Initializer.run do |config|
59
59
  ...
60
- config.gem "paperclip", :version => "~> 2.3"
60
+ config.gem "paperclip", :version => "~> 2.4"
61
61
  ...
62
62
  end
63
63
 
data/Rakefile CHANGED
@@ -5,6 +5,7 @@ require 'bundler/setup'
5
5
  require 'rake'
6
6
  require 'rake/testtask'
7
7
  require 'rdoc/task'
8
+ require 'cucumber/rake/task'
8
9
 
9
10
  $LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
10
11
  require 'paperclip'
@@ -14,7 +15,7 @@ task :default => [:clean, 'appraisal:install', :all]
14
15
 
15
16
  desc 'Test the paperclip plugin under all supported Rails versions.'
16
17
  task :all do |t|
17
- exec('rake appraisal test')
18
+ exec('rake appraisal test cucumber')
18
19
  end
19
20
 
20
21
  desc 'Test the paperclip plugin.'
@@ -24,6 +25,11 @@ Rake::TestTask.new(:test) do |t|
24
25
  t.verbose = true
25
26
  end
26
27
 
28
+ desc 'Run integration test'
29
+ Cucumber::Rake::Task.new do |t|
30
+ t.cucumber_opts = %w{--format progress}
31
+ end
32
+
27
33
  desc 'Start an IRB session with all necessary files required.'
28
34
  task :shell do |t|
29
35
  chdir File.dirname(__FILE__)
@@ -142,7 +142,7 @@ module Paperclip
142
142
  end
143
143
  end
144
144
 
145
- # Log a paperclip-specific line. Uses ActiveRecord::Base.logger
145
+ # Log a paperclip-specific line. This will logs to STDOUT
146
146
  # by default. Set Paperclip.options[:log] to false to turn off.
147
147
  def log message
148
148
  logger.info("[paperclip] #{message}") if logging?
@@ -19,6 +19,8 @@ module Paperclip
19
19
  def self.insert
20
20
  ActiveRecord::Base.send(:include, Paperclip::Glue)
21
21
  File.send(:include, Paperclip::Upfile)
22
+
23
+ Paperclip.options[:logger] = defined?(ActiveRecord) ? ActiveRecord::Base.logger : Rails.logger
22
24
  end
23
25
  end
24
26
  end
@@ -122,8 +122,8 @@ module Paperclip
122
122
  @bucket
123
123
  end
124
124
 
125
- def s3_host_name
126
- @s3_host_name || "s3.amazonaws.com"
125
+ def s3_host_name
126
+ @s3_host_name || "s3.amazonaws.com"
127
127
  end
128
128
 
129
129
  def set_permissions permissions
@@ -153,7 +153,7 @@ module Paperclip
153
153
  end
154
154
  end
155
155
 
156
- def s3_protocol(style)
156
+ def s3_protocol(style = default_style)
157
157
  if @s3_protocol.is_a?(Proc)
158
158
  @s3_protocol.call(style)
159
159
  else
@@ -25,7 +25,7 @@ module Paperclip
25
25
  def type_from_file_command
26
26
  # On BSDs, `file` doesn't give a result code of 1 if the file doesn't exist.
27
27
  type = (self.original_filename.match(/\.(\w+)$/)[1] rescue "octet-stream").downcase
28
- mime_type = (Paperclip.run("file", "-b --mime-type :file", :file => self.path).split(':').last.strip rescue "application/x-#{type}")
28
+ mime_type = (Paperclip.run("file", "-b --mime :file", :file => self.path).split(/[:;]\s+/)[0] rescue "application/x-#{type}")
29
29
  mime_type = "application/x-#{type}" if mime_type.match(/\(.*?\)/)
30
30
  mime_type
31
31
  end
@@ -1,3 +1,3 @@
1
1
  module Paperclip
2
- VERSION = "2.4.0" unless defined? Paperclip::VERSION
2
+ VERSION = "2.4.1" unless defined? Paperclip::VERSION
3
3
  end
@@ -109,8 +109,14 @@ if defined?(ActionController::Integration::Session)
109
109
  end
110
110
  end
111
111
 
112
- class Factory
113
- include Paperclip::Shoulda #:nodoc:
112
+ if defined?(FactoryGirl::Factory)
113
+ class FactoryGirl::Factory
114
+ include Paperclip::Shoulda #:nodoc:
115
+ end
116
+ else
117
+ class Factory
118
+ include Paperclip::Shoulda #:nodoc:
119
+ end
114
120
  end
115
121
 
116
122
  class Test::Unit::TestCase #:nodoc:
@@ -1060,7 +1060,7 @@ class AttachmentTest < Test::Unit::TestCase
1060
1060
  assert File.exists?(@path)
1061
1061
  end
1062
1062
 
1063
- should "not delete the file when model is destroy" do
1063
+ should "not delete the file when model is destroyed" do
1064
1064
  @dummy.destroy
1065
1065
  assert File.exists?(@path)
1066
1066
  end
@@ -0,0 +1 @@
1
+ paperclip!
@@ -48,6 +48,7 @@ FIXTURES_DIR = File.join(File.dirname(__FILE__), "fixtures")
48
48
  config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
49
49
  ActiveRecord::Base.logger = ActiveSupport::BufferedLogger.new(File.dirname(__FILE__) + "/debug.log")
50
50
  ActiveRecord::Base.establish_connection(config['test'])
51
+ Paperclip.options[:logger] = ActiveRecord::Base.logger
51
52
 
52
53
  def reset_class class_name
53
54
  ActiveRecord::Base.send(:include, Paperclip::Glue)
@@ -24,14 +24,6 @@ class UpfileTest < Test::Unit::TestCase
24
24
 
25
25
  assert_equal content_type, file.content_type
26
26
  end
27
-
28
- should "return a content_type of text/plain on a real file whose content_type is determined with the file command" do
29
- file = File.new(File.join(File.dirname(__FILE__), "..", "LICENSE"))
30
- class << file
31
- include Paperclip::Upfile
32
- end
33
- assert_equal 'text/plain', file.content_type
34
- end
35
27
  end
36
28
  end
37
29
 
@@ -42,4 +34,20 @@ class UpfileTest < Test::Unit::TestCase
42
34
  end
43
35
  assert_equal 'text/plain', file.content_type
44
36
  end
37
+
38
+ { '5k.png' => 'image/png',
39
+ 'animated.gif' => 'image/gif',
40
+ 'text.txt' => 'text/plain',
41
+ 'twopage.pdf' => 'application/pdf'
42
+ }.each do |filename, content_type|
43
+ should "return a content type of #{content_type} from a file command for file #{filename}" do
44
+ file = File.new(File.join(File.dirname(__FILE__), "fixtures", filename))
45
+ class << file
46
+ include Paperclip::Upfile
47
+ end
48
+
49
+ assert_equal content_type, file.type_from_file_command
50
+ end
51
+ end
52
+
45
53
  end
metadata CHANGED
@@ -1,262 +1,236 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: paperclip
3
- version: !ruby/object:Gem::Version
4
- hash: 31
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.4.1
5
5
  prerelease:
6
- segments:
7
- - 2
8
- - 4
9
- - 0
10
- version: 2.4.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Jon Yurek
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-08-31 00:00:00 -04:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- type: :runtime
23
- requirement: &id001 !ruby/object:Gem::Requirement
12
+ date: 2011-09-07 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activerecord
16
+ requirement: &70313204575540 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 2
31
- - 3
32
- - 0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
33
21
  version: 2.3.0
34
- name: activerecord
35
- prerelease: false
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
22
  type: :runtime
39
- requirement: &id002 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ version_requirements: *70313204575540
25
+ - !ruby/object:Gem::Dependency
26
+ name: activesupport
27
+ requirement: &70313204575020 !ruby/object:Gem::Requirement
40
28
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 7
45
- segments:
46
- - 2
47
- - 3
48
- - 2
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
49
32
  version: 2.3.2
50
- name: activesupport
51
- prerelease: false
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
33
  type: :runtime
55
- requirement: &id003 !ruby/object:Gem::Requirement
34
+ prerelease: false
35
+ version_requirements: *70313204575020
36
+ - !ruby/object:Gem::Dependency
37
+ name: cocaine
38
+ requirement: &70313204574560 !ruby/object:Gem::Requirement
56
39
  none: false
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- hash: 27
61
- segments:
62
- - 0
63
- - 0
64
- - 2
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
65
43
  version: 0.0.2
66
- name: cocaine
67
- prerelease: false
68
- version_requirements: *id003
69
- - !ruby/object:Gem::Dependency
70
44
  type: :runtime
71
- requirement: &id004 !ruby/object:Gem::Requirement
72
- none: false
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- hash: 3
77
- segments:
78
- - 0
79
- version: "0"
80
- name: mime-types
81
45
  prerelease: false
82
- version_requirements: *id004
83
- - !ruby/object:Gem::Dependency
84
- type: :development
85
- requirement: &id005 !ruby/object:Gem::Requirement
46
+ version_requirements: *70313204574560
47
+ - !ruby/object:Gem::Dependency
48
+ name: mime-types
49
+ requirement: &70313204574180 !ruby/object:Gem::Requirement
86
50
  none: false
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- hash: 3
91
- segments:
92
- - 0
93
- version: "0"
94
- name: shoulda
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
95
56
  prerelease: false
96
- version_requirements: *id005
97
- - !ruby/object:Gem::Dependency
98
- type: :development
99
- requirement: &id006 !ruby/object:Gem::Requirement
57
+ version_requirements: *70313204574180
58
+ - !ruby/object:Gem::Dependency
59
+ name: shoulda
60
+ requirement: &70313204573700 !ruby/object:Gem::Requirement
100
61
  none: false
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- hash: 3
105
- segments:
106
- - 0
107
- version: "0"
108
- name: appraisal
109
- prerelease: false
110
- version_requirements: *id006
111
- - !ruby/object:Gem::Dependency
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
112
66
  type: :development
113
- requirement: &id007 !ruby/object:Gem::Requirement
67
+ prerelease: false
68
+ version_requirements: *70313204573700
69
+ - !ruby/object:Gem::Dependency
70
+ name: appraisal
71
+ requirement: &70313204573280 !ruby/object:Gem::Requirement
114
72
  none: false
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- hash: 3
119
- segments:
120
- - 0
121
- version: "0"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70313204573280
80
+ - !ruby/object:Gem::Dependency
122
81
  name: mocha
82
+ requirement: &70313204572860 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
123
89
  prerelease: false
124
- version_requirements: *id007
125
- - !ruby/object:Gem::Dependency
90
+ version_requirements: *70313204572860
91
+ - !ruby/object:Gem::Dependency
92
+ name: aws-s3
93
+ requirement: &70313204572440 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
126
99
  type: :development
127
- requirement: &id008 !ruby/object:Gem::Requirement
100
+ prerelease: false
101
+ version_requirements: *70313204572440
102
+ - !ruby/object:Gem::Dependency
103
+ name: sqlite3
104
+ requirement: &70313204572020 !ruby/object:Gem::Requirement
128
105
  none: false
129
- requirements:
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- hash: 3
133
- segments:
134
- - 0
135
- version: "0"
136
- name: aws-s3
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
137
111
  prerelease: false
138
- version_requirements: *id008
139
- - !ruby/object:Gem::Dependency
112
+ version_requirements: *70313204572020
113
+ - !ruby/object:Gem::Dependency
114
+ name: cucumber
115
+ requirement: &70313204571600 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
140
121
  type: :development
141
- requirement: &id009 !ruby/object:Gem::Requirement
122
+ prerelease: false
123
+ version_requirements: *70313204571600
124
+ - !ruby/object:Gem::Dependency
125
+ name: capybara
126
+ requirement: &70313204571180 !ruby/object:Gem::Requirement
142
127
  none: false
143
- requirements:
144
- - - ">="
145
- - !ruby/object:Gem::Version
146
- hash: 3
147
- segments:
148
- - 0
149
- version: "0"
150
- name: sqlite3
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
151
133
  prerelease: false
152
- version_requirements: *id009
134
+ version_requirements: *70313204571180
153
135
  description: Easy upload management for ActiveRecord
154
136
  email: jyurek@thoughtbot.com
155
137
  executables: []
156
-
157
138
  extensions: []
158
-
159
- extra_rdoc_files:
139
+ extra_rdoc_files:
160
140
  - README.md
161
- files:
141
+ files:
162
142
  - README.md
163
143
  - LICENSE
164
144
  - Rakefile
165
145
  - init.rb
166
- - lib/paperclip/storage/fog.rb
167
- - lib/paperclip/storage/s3.rb
168
- - lib/paperclip/storage/filesystem.rb
169
- - lib/paperclip/storage.rb
146
+ - lib/generators/paperclip/paperclip_generator.rb
147
+ - lib/generators/paperclip/templates/paperclip_migration.rb.erb
148
+ - lib/generators/paperclip/USAGE
170
149
  - lib/paperclip/attachment.rb
171
150
  - lib/paperclip/callback_compatibility.rb
172
- - lib/paperclip/matchers/have_attached_file_matcher.rb
173
- - lib/paperclip/matchers/validate_attachment_size_matcher.rb
174
- - lib/paperclip/matchers/validate_attachment_presence_matcher.rb
175
- - lib/paperclip/matchers/validate_attachment_content_type_matcher.rb
176
- - lib/paperclip/thumbnail.rb
177
- - lib/paperclip/processor.rb
178
151
  - lib/paperclip/geometry.rb
152
+ - lib/paperclip/interpolations.rb
179
153
  - lib/paperclip/iostream.rb
180
- - lib/paperclip/missing_attachment_styles.rb
154
+ - lib/paperclip/matchers/have_attached_file_matcher.rb
155
+ - lib/paperclip/matchers/validate_attachment_content_type_matcher.rb
156
+ - lib/paperclip/matchers/validate_attachment_presence_matcher.rb
157
+ - lib/paperclip/matchers/validate_attachment_size_matcher.rb
181
158
  - lib/paperclip/matchers.rb
182
- - lib/paperclip/upfile.rb
183
- - lib/paperclip/interpolations.rb
184
- - lib/paperclip/version.rb
159
+ - lib/paperclip/missing_attachment_styles.rb
160
+ - lib/paperclip/processor.rb
185
161
  - lib/paperclip/railtie.rb
162
+ - lib/paperclip/storage/filesystem.rb
163
+ - lib/paperclip/storage/fog.rb
164
+ - lib/paperclip/storage/s3.rb
165
+ - lib/paperclip/storage.rb
186
166
  - lib/paperclip/style.rb
187
- - lib/tasks/paperclip.rake
188
- - lib/generators/paperclip/USAGE
189
- - lib/generators/paperclip/paperclip_generator.rb
190
- - lib/generators/paperclip/templates/paperclip_migration.rb.erb
167
+ - lib/paperclip/thumbnail.rb
168
+ - lib/paperclip/upfile.rb
169
+ - lib/paperclip/version.rb
191
170
  - lib/paperclip.rb
192
- - test/processor_test.rb
193
- - test/paperclip_test.rb
194
- - test/upfile_test.rb
195
- - test/paperclip_missing_attachment_styles_test.rb
196
- - test/matchers/have_attached_file_matcher_test.rb
197
- - test/matchers/validate_attachment_presence_matcher_test.rb
198
- - test/matchers/validate_attachment_size_matcher_test.rb
199
- - test/matchers/validate_attachment_content_type_matcher_test.rb
200
- - test/storage_test.rb
201
- - test/style_test.rb
202
- - test/fixtures/fog.yml
203
- - test/fixtures/s3.yml
204
- - test/fixtures/50x50.png
171
+ - lib/tasks/paperclip.rake
172
+ - test/attachment_test.rb
173
+ - test/database.yml
205
174
  - test/fixtures/12k.png
206
- - test/fixtures/animated.gif
207
- - test/fixtures/uppercase.PNG
208
- - test/fixtures/twopage.pdf
209
- - test/fixtures/text.txt
175
+ - test/fixtures/50x50.png
210
176
  - test/fixtures/5k.png
177
+ - test/fixtures/animated.gif
211
178
  - test/fixtures/bad.png
212
- - test/geometry_test.rb
179
+ - test/fixtures/fog.yml
180
+ - test/fixtures/s3.yml
181
+ - test/fixtures/text.txt
182
+ - test/fixtures/twopage.pdf
183
+ - test/fixtures/uppercase.PNG
213
184
  - test/fog_test.rb
214
- - test/attachment_test.rb
185
+ - test/geometry_test.rb
215
186
  - test/helper.rb
216
- - test/interpolations_test.rb
217
- - test/thumbnail_test.rb
218
187
  - test/integration_test.rb
188
+ - test/interpolations_test.rb
219
189
  - test/iostream_test.rb
220
- - test/database.yml
190
+ - test/matchers/have_attached_file_matcher_test.rb
191
+ - test/matchers/validate_attachment_content_type_matcher_test.rb
192
+ - test/matchers/validate_attachment_presence_matcher_test.rb
193
+ - test/matchers/validate_attachment_size_matcher_test.rb
194
+ - test/paperclip_missing_attachment_styles_test.rb
195
+ - test/paperclip_test.rb
196
+ - test/processor_test.rb
197
+ - test/storage_test.rb
198
+ - test/style_test.rb
199
+ - test/thumbnail_test.rb
200
+ - test/upfile_test.rb
221
201
  - rails/init.rb
222
- - generators/paperclip/USAGE
223
202
  - generators/paperclip/paperclip_generator.rb
224
203
  - generators/paperclip/templates/paperclip_migration.rb.erb
204
+ - generators/paperclip/USAGE
225
205
  - shoulda_macros/paperclip.rb
226
- has_rdoc: true
227
206
  homepage: https://github.com/thoughtbot/paperclip
228
207
  licenses: []
229
-
230
208
  post_install_message:
231
- rdoc_options:
209
+ rdoc_options:
232
210
  - --line-numbers
233
211
  - --inline-source
234
- require_paths:
212
+ require_paths:
235
213
  - lib
236
- required_ruby_version: !ruby/object:Gem::Requirement
214
+ required_ruby_version: !ruby/object:Gem::Requirement
237
215
  none: false
238
- requirements:
239
- - - ">="
240
- - !ruby/object:Gem::Version
241
- hash: 3
242
- segments:
216
+ requirements:
217
+ - - ! '>='
218
+ - !ruby/object:Gem::Version
219
+ version: '0'
220
+ segments:
243
221
  - 0
244
- version: "0"
245
- required_rubygems_version: !ruby/object:Gem::Requirement
222
+ hash: -1991530113411237677
223
+ required_rubygems_version: !ruby/object:Gem::Requirement
246
224
  none: false
247
- requirements:
248
- - - ">="
249
- - !ruby/object:Gem::Version
250
- hash: 3
251
- segments:
252
- - 0
253
- version: "0"
254
- requirements:
225
+ requirements:
226
+ - - ! '>='
227
+ - !ruby/object:Gem::Version
228
+ version: '0'
229
+ requirements:
255
230
  - ImageMagick
256
231
  rubyforge_project: paperclip
257
- rubygems_version: 1.6.2
232
+ rubygems_version: 1.8.6
258
233
  signing_key:
259
234
  specification_version: 3
260
235
  summary: File attachments as attributes for ActiveRecord
261
236
  test_files: []
262
-