paperclip 3.2.1 → 3.3.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.

data/NEWS CHANGED
@@ -4,7 +4,7 @@ New in 3.2.0:
4
4
  * Bug fix: The rake task respects the updated_at column.
5
5
  * Bug fix: Strip newline from content type.
6
6
  * Feature: Fog file visibility can be specified per style.
7
- * Feature: Autonatically rotate images.
7
+ * Feature: Automatically rotate images.
8
8
  * Feature: Reduce class-oriented programming of the attachment definitions.
9
9
 
10
10
  New in 3.1.4:
data/README.md CHANGED
@@ -616,5 +616,5 @@ The names and logos for thoughtbot are trademarks of thoughtbot, inc.
616
616
  License
617
617
  -------
618
618
 
619
- Paperclip is Copyright © 2008-2011 thoughtbot. It is free software, and may be
619
+ Paperclip is Copyright © 2008-2012 thoughtbot. It is free software, and may be
620
620
  redistributed under the terms specified in the MIT-LICENSE file.
@@ -294,6 +294,7 @@ module Paperclip
294
294
  saved_only_process, @options[:only_process] = @options[:only_process], style_args
295
295
  begin
296
296
  assign(self)
297
+ save
297
298
  instance.save
298
299
  rescue Errno::EACCES => e
299
300
  warn "#{e} - skipping file."
@@ -321,19 +322,18 @@ module Paperclip
321
322
  # "avatar_file_name" field (assuming the attachment is called avatar).
322
323
  def instance_write(attr, value)
323
324
  setter = :"#{name}_#{attr}="
324
- responds = instance.respond_to?(setter)
325
- self.instance_variable_set("@_#{setter.to_s.chop}", value)
326
- instance.send(setter, value) if responds || attr.to_s == "file_name"
325
+ if instance.respond_to?(setter)
326
+ instance.send(setter, value)
327
+ end
327
328
  end
328
329
 
329
330
  # Reads the attachment-specific attribute on the instance. See instance_write
330
331
  # for more details.
331
332
  def instance_read(attr)
332
333
  getter = :"#{name}_#{attr}"
333
- responds = instance.respond_to?(getter)
334
- cached = self.instance_variable_get("@_#{getter}")
335
- return cached if cached
336
- instance.send(getter) if responds || attr.to_s == "file_name"
334
+ if instance.respond_to?(getter)
335
+ instance.send(getter)
336
+ end
337
337
  end
338
338
 
339
339
  private
@@ -22,11 +22,13 @@ module Paperclip
22
22
  #
23
23
  # :swallow_stderr -> Set to true if you don't care what happens on STDERR.
24
24
  #
25
- def run(cmd, arguments = "", local_options = {})
25
+ def run(cmd, arguments = "", interpolation_values = {}, local_options = {})
26
26
  command_path = options[:command_path]
27
- Cocaine::CommandLine.path = ( Cocaine::CommandLine.path ? [Cocaine::CommandLine.path].flatten | [command_path] : command_path )
28
- local_options = local_options.merge(:logger => logger) if logging? && (options[:log_command] || local_options[:log_command])
29
- Cocaine::CommandLine.new(cmd, arguments, local_options).run
27
+ Cocaine::CommandLine.path = [Cocaine::CommandLine.path, command_path].flatten.compact.uniq
28
+ if logging? && (options[:log_command] || local_options[:log_command])
29
+ local_options = local_options.merge(:logger => logger)
30
+ end
31
+ Cocaine::CommandLine.new(cmd, arguments, local_options).run(interpolation_values)
30
32
  end
31
33
 
32
34
  # Find all instances of the given Active Record model +klass+ with attachment +name+.
@@ -39,7 +41,11 @@ module Paperclip
39
41
 
40
42
  def class_for(class_name)
41
43
  class_name.split('::').inject(Object) do |klass, partial_class_name|
42
- klass.const_defined?(partial_class_name) ? klass.const_get(partial_class_name, false) : klass.const_missing(partial_class_name)
44
+ if klass.const_defined?(partial_class_name)
45
+ klass.const_get(partial_class_name, false)
46
+ else
47
+ klass.const_missing(partial_class_name)
48
+ end
43
49
  end
44
50
  end
45
51
 
@@ -1,3 +1,3 @@
1
1
  module Paperclip
2
- VERSION = "3.2.1" unless defined? Paperclip::VERSION
2
+ VERSION = "3.3.0" unless defined? Paperclip::VERSION
3
3
  end
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.add_dependency('activerecord', '>= 3.0.0')
29
29
  s.add_dependency('activemodel', '>= 3.0.0')
30
30
  s.add_dependency('activesupport', '>= 3.0.0')
31
- s.add_dependency('cocaine', '>= 0.0.2')
31
+ s.add_dependency('cocaine', '~> 0.4.0')
32
32
  s.add_dependency('mime-types')
33
33
 
34
34
  s.add_development_dependency('shoulda')
@@ -42,7 +42,7 @@ Gem::Specification.new do |s|
42
42
  s.add_development_dependency('nokogiri')
43
43
  s.add_development_dependency('capybara')
44
44
  s.add_development_dependency('bundler')
45
- s.add_development_dependency('cocaine', '~> 0.3.2')
45
+ s.add_development_dependency('cocaine', '~> 0.2')
46
46
  s.add_development_dependency('fog', '~> 1.4.0')
47
47
  s.add_development_dependency('pry')
48
48
  s.add_development_dependency('launchy')
@@ -1083,16 +1083,8 @@ class AttachmentTest < Test::Unit::TestCase
1083
1083
  assert_nothing_raised { @dummy.avatar = @file }
1084
1084
  end
1085
1085
 
1086
- should "return the time when sent #avatar_updated_at" do
1087
- now = Time.now
1088
- Time.stubs(:now).returns(now)
1086
+ should "not return the time when sent #avatar_updated_at" do
1089
1087
  @dummy.avatar = @file
1090
- assert_equal now.to_i, @dummy.avatar.updated_at.to_i
1091
- end
1092
-
1093
- should "return nil when reloaded and sent #avatar_updated_at" do
1094
- @dummy.save
1095
- @dummy.reload
1096
1088
  assert_nil @dummy.avatar.updated_at
1097
1089
  end
1098
1090
 
@@ -465,7 +465,9 @@ class IntegrationTest < Test::Unit::TestCase
465
465
  setup do
466
466
  @dummy.avatar.options[:styles][:mini] = "25x25#"
467
467
  @dummy.avatar.instance_variable_set :@normalized_styles, nil
468
- @dummy.avatar.reprocess! 'mini'
468
+ Time.stubs(:now => Time.now + 10)
469
+ @dummy.avatar.reprocess!
470
+ @dummy.reload
469
471
  end
470
472
 
471
473
  should "make all the styles accessible" do
@@ -33,6 +33,14 @@ class PaperclipTest < Test::Unit::TestCase
33
33
  end
34
34
  end
35
35
 
36
+ should 'not raise errors when doing a lot of running' do
37
+ Paperclip.options[:command_path] = ["/usr/local/bin"] * 1024
38
+ Cocaine::CommandLine.path = "/something/else"
39
+ 100.times do |x|
40
+ Paperclip.run("echo", x.to_s)
41
+ end
42
+ end
43
+
36
44
  context "Calling Paperclip.log without options[:logger] set" do
37
45
  setup do
38
46
  Paperclip.logger = nil
@@ -80,6 +80,8 @@ class ThumbnailTest < Test::Unit::TestCase
80
80
  should "let us know when a command isn't found versus a processing error" do
81
81
  old_path = ENV['PATH']
82
82
  begin
83
+ Cocaine::CommandLine.path = ''
84
+ Paperclip.options[:command_path] = ''
83
85
  ENV['PATH'] = ''
84
86
  assert_raises(Paperclip::Errors::CommandNotFoundError) do
85
87
  silence_stream(STDERR) do
@@ -209,6 +211,8 @@ class ThumbnailTest < Test::Unit::TestCase
209
211
  should "let us know when a command isn't found versus a processing error" do
210
212
  old_path = ENV['PATH']
211
213
  begin
214
+ Cocaine::CommandLine.path = ''
215
+ Paperclip.options[:command_path] = ''
212
216
  ENV['PATH'] = ''
213
217
  assert_raises(Paperclip::Errors::CommandNotFoundError) do
214
218
  silence_stream(STDERR) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-08 00:00:00.000000000 Z
12
+ date: 2012-10-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -64,17 +64,17 @@ dependencies:
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
- - - ! '>='
67
+ - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: 0.0.2
69
+ version: 0.4.0
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
- - - ! '>='
75
+ - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: 0.0.2
77
+ version: 0.4.0
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: mime-types
80
80
  requirement: !ruby/object:Gem::Requirement
@@ -274,7 +274,7 @@ dependencies:
274
274
  requirements:
275
275
  - - ~>
276
276
  - !ruby/object:Gem::Version
277
- version: 0.3.2
277
+ version: '0.2'
278
278
  type: :development
279
279
  prerelease: false
280
280
  version_requirements: !ruby/object:Gem::Requirement
@@ -282,7 +282,7 @@ dependencies:
282
282
  requirements:
283
283
  - - ~>
284
284
  - !ruby/object:Gem::Version
285
- version: 0.3.2
285
+ version: '0.2'
286
286
  - !ruby/object:Gem::Dependency
287
287
  name: fog
288
288
  requirement: !ruby/object:Gem::Requirement