paperclip 2.7.5 → 2.8.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
@@ -1,22 +1,3 @@
1
- New in 2.7.5:
2
-
3
- * Feature: :s3_host_name can be a proc
4
-
5
- New in 2.7.4:
6
-
7
- * Feature: Allow :escape_url as an option in the defaults
8
- * Bug fix: Correcting some PATH-based tests.
9
- * Compatability: Cucumber tests work for Rails 3.2.8
10
-
11
- New in 2.7.2
12
-
13
- * Bug fix: Ensured the correct cocaine version.
14
- * Bug fix: Fixed some tests that shouldn't have been passing.
15
-
16
- New in 2.7.1:
17
-
18
- * Bug fix: Fixed the problem with E2BIG errors and an ever-expanding path
19
-
20
1
  New in 2.7.0:
21
2
 
22
3
  * Bug fix: Checking the existence of a file on S3 handles all AWS errors.
@@ -12,8 +12,8 @@ Feature: Rails integration
12
12
  Given I add this snippet to the User model:
13
13
  """
14
14
  has_attached_file :attachment
15
+ attr_protected
15
16
  """
16
- And I add attr_accessible to a Rails 3.2 application
17
17
  And I start the rails application
18
18
  When I go to the new user page
19
19
  And I fill in "Name" with "something"
@@ -30,8 +30,8 @@ Feature: Rails integration
30
30
  :storage => :s3,
31
31
  :path => "/:attachment/:id/:style/:filename",
32
32
  :s3_credentials => Rails.root.join("config/s3.yml")
33
+ attr_protected
33
34
  """
34
- And I add attr_accessible to a Rails 3.2 application
35
35
  And I write to "config/s3.yml" with:
36
36
  """
37
37
  bucket: paperclip
@@ -6,7 +6,6 @@ Feature: Rake tasks
6
6
  And I run a paperclip generator to add a paperclip "attachment" to the "User" model
7
7
  And I run a migration
8
8
  And I add the paperclip rake task to a Rails 2.3 application
9
- And I add attr_accessible to a Rails 3.2 application
10
9
  And I add this snippet to the User model:
11
10
  """
12
11
  has_attached_file :attachment, :path => ":rails_root/public/system/:attachment/:style/:filename"
@@ -18,7 +17,6 @@ Feature: Rake tasks
18
17
  has_attached_file :attachment, :path => ":rails_root/public/system/:attachment/:style/:filename",
19
18
  :styles => { :medium => "200x200#" }
20
19
  """
21
- And I add attr_accessible to a Rails 3.2 application
22
20
  And I upload the fixture "5k.png"
23
21
  Then the attachment "medium/5k.png" should have a dimension of 200x200
24
22
  When I modify my attachment definition to:
@@ -26,7 +24,6 @@ Feature: Rake tasks
26
24
  has_attached_file :attachment, :path => ":rails_root/public/system/:attachment/:style/:filename",
27
25
  :styles => { :medium => "100x100#" }
28
26
  """
29
- And I add attr_accessible to a Rails 3.2 application
30
27
  When I successfully run `bundle exec rake paperclip:refresh:thumbnails CLASS=User --trace`
31
28
  Then the attachment "original/5k.png" should exist
32
29
  And the attachment "medium/5k.png" should have a dimension of 100x100
@@ -47,7 +44,6 @@ Feature: Rake tasks
47
44
  has_attached_file :attachment, :path => ":rails_root/public/system/:attachment/:style/:filename",
48
45
  :styles => { :medium => "200x200#" }
49
46
  """
50
- And I add attr_accessible to a Rails 3.2 application
51
47
  When I successfully run `bundle exec rake paperclip:refresh:missing_styles --trace`
52
48
  Then the attachment file "original/5k.png" should exist
53
49
  And the attachment file "medium/5k.png" should exist
@@ -62,7 +58,6 @@ Feature: Rake tasks
62
58
  has_attached_file :attachment, :path => ":rails_root/public/system/:attachment/:style/:filename"
63
59
  validates_attachment_size :attachment, :less_than => 10.kilobytes
64
60
  """
65
- And I add attr_accessible to a Rails 3.2 application
66
61
  And I successfully run `bundle exec rake paperclip:clean CLASS=User --trace`
67
62
  Then the attachment file "original/5k.png" should exist
68
63
  But the attachment file "original/12k.png" should not exist
@@ -71,7 +71,11 @@ Given /^I update my user view to include the attachment$/ do
71
71
  end
72
72
 
73
73
  Given /^I add this snippet to the User model:$/ do |snippet|
74
- insert_snippet_into_file("app/models/user.rb", snippet)
74
+ file_name = "app/models/user.rb"
75
+ in_current_dir do
76
+ content = File.read(file_name)
77
+ File.open(file_name, 'w') { |f| f << content.sub(/end\Z/, "#{snippet}\nend") }
78
+ end
75
79
  end
76
80
 
77
81
  Given /^I start the rails application$/ do
@@ -109,12 +113,6 @@ Given /^I update my application to use Bundler$/ do
109
113
  end
110
114
  end
111
115
 
112
- Given /^I add attr_accessible to a Rails 3.2 application$/ do
113
- if framework_version?("3.2")
114
- insert_snippet_into_file("app/models/user.rb", "attr_accessible :attachment\n")
115
- end
116
- end
117
-
118
116
  Given /^I add the paperclip rake task to a Rails 2.3 application$/ do
119
117
  if framework_version?("2.3")
120
118
  require 'fileutils'
@@ -159,14 +157,6 @@ When /^I comment out the gem "([^"]*)" from the Gemfile$/ do |gemname|
159
157
  end
160
158
 
161
159
  module FileHelpers
162
- def insert_snippet_into_file(file_name, snippet)
163
- in_current_dir do
164
- content = File.read(file_name)
165
- File.open(file_name, 'w') { |f| f << content.sub(/end\Z/, "#{snippet}\nend") }
166
- content = File.read(file_name)
167
- end
168
- end
169
-
170
160
  def append_to(path, contents)
171
161
  in_current_dir do
172
162
  File.open(path, "a") do |file|
@@ -92,14 +92,14 @@ module Paperclip
92
92
  #
93
93
  # :swallow_stderr -> Set to true if you don't care what happens on STDERR.
94
94
  #
95
- def run(cmd, arguments = "", local_options = {})
95
+ def run(cmd, arguments = "", interpolation_values = {}, local_options = {})
96
96
  if options[:image_magick_path]
97
97
  Paperclip.log("[DEPRECATION] :image_magick_path is deprecated and will be removed. Use :command_path instead")
98
98
  end
99
99
  command_path = options[:command_path] || options[:image_magick_path]
100
100
  Cocaine::CommandLine.path = [Cocaine::CommandLine.path, command_path].flatten.compact.uniq
101
101
  local_options = local_options.merge(:logger => logger) if logging? && (options[:log_command] || local_options[:log_command])
102
- Cocaine::CommandLine.new(cmd, arguments, local_options).run
102
+ Cocaine::CommandLine.new(cmd, arguments, local_options).run(interpolation_values)
103
103
  end
104
104
 
105
105
  def processor(name) #:nodoc:
@@ -14,7 +14,6 @@ module Paperclip
14
14
  :convert_options => {},
15
15
  :default_style => :original,
16
16
  :default_url => "/:attachment/:style/missing.png",
17
- :escape_url => true,
18
17
  :restricted_characters => /[&$+,\/:;=?@<>\[\]\{\}\|\\\^~%# ]/,
19
18
  :hash_data => ":class/:attachment/:id/:style/:updated_at",
20
19
  :hash_digest => "SHA1",
@@ -63,7 +62,6 @@ module Paperclip
63
62
  # +preserve_files+ - whether to keep files on the filesystem when deleting to clearing the attachment. Defaults to false
64
63
  # +interpolator+ - the object used to interpolate filenames and URLs. Defaults to Paperclip::Interpolations
65
64
  # +url_generator+ - the object used to generate URLs, using the interpolator. Defaults to Paperclip::UrlGenerator
66
- # +escape_url+ - Perform URI escaping to URLs. Defaults to true
67
65
  def initialize(name, instance, options = {})
68
66
  @name = name
69
67
  @instance = instance
@@ -151,7 +149,7 @@ module Paperclip
151
149
  # +#new(Paperclip::Attachment, options_hash)+
152
150
  # +#for(style_name, options_hash)+
153
151
  def url(style_name = default_style, options = {})
154
- default_options = {:timestamp => @options[:use_timestamp], :escape => @options[:escape_url]}
152
+ default_options = {:timestamp => @options[:use_timestamp], :escape => true}
155
153
 
156
154
  if options == true || options == false # Backwards compatibility.
157
155
  @url_generator.for(style_name, default_options.merge(:timestamp => options))
@@ -150,10 +150,7 @@ module Paperclip
150
150
  end
151
151
 
152
152
  def s3_host_name
153
- host_name = @options[:s3_host_name]
154
- host_name = host_name.call(self) if host_name.is_a?(Proc)
155
-
156
- host_name || s3_credentials[:s3_host_name] || "s3.amazonaws.com"
153
+ @options[:s3_host_name] || s3_credentials[:s3_host_name] || "s3.amazonaws.com"
157
154
  end
158
155
 
159
156
  def s3_host_alias
@@ -1,3 +1,3 @@
1
1
  module Paperclip
2
- VERSION = "2.7.5" unless defined? Paperclip::VERSION
2
+ VERSION = "2.8.0" unless defined? Paperclip::VERSION
3
3
  end
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.add_dependency('activerecord', '>= 2.3.0')
24
24
  s.add_dependency('activesupport', '>= 2.3.2')
25
- s.add_dependency('cocaine', '~> 0.3.0')
25
+ s.add_dependency('cocaine', '>= 0.0.2')
26
26
  s.add_dependency('mime-types')
27
27
 
28
28
  s.add_development_dependency('shoulda')
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
34
34
  s.add_development_dependency('aruba')
35
35
  s.add_development_dependency('capybara')
36
36
  s.add_development_dependency('bundler')
37
- s.add_development_dependency('cocaine', '~> 0.3.0')
37
+ s.add_development_dependency('cocaine', '~> 0.4.0')
38
38
  s.add_development_dependency('fog')
39
39
  s.add_development_dependency('rake')
40
40
  s.add_development_dependency('fakeweb')
@@ -95,28 +95,6 @@ class AttachmentTest < Test::Unit::TestCase
95
95
  assert mock_url_generator_builder.has_generated_url_with_options?(:escape => true, :timestamp => true)
96
96
  end
97
97
 
98
- should "pass the option :escape => true if :escape_url is true and :escape is not passed" do
99
- mock_url_generator_builder = MockUrlGeneratorBuilder.new
100
- attachment = Paperclip::Attachment.new(:name,
101
- :instance,
102
- :url_generator => mock_url_generator_builder,
103
- :escape_url => true)
104
-
105
- attachment.url(:style_name)
106
- assert mock_url_generator_builder.has_generated_url_with_options?(:escape => true)
107
- end
108
-
109
- should "pass the option :escape => false if :escape_url is false and :escape is not passed" do
110
- mock_url_generator_builder = MockUrlGeneratorBuilder.new
111
- attachment = Paperclip::Attachment.new(:name,
112
- :instance,
113
- :url_generator => mock_url_generator_builder,
114
- :escape_url => false)
115
-
116
- attachment.url(:style_name)
117
- assert mock_url_generator_builder.has_generated_url_with_options?(:escape => false)
118
- end
119
-
120
98
  should "return the path based on the url by default" do
121
99
  @attachment = attachment :url => "/:class/:id/:basename"
122
100
  @model = @attachment.instance
@@ -176,26 +176,6 @@ class S3Test < Test::Unit::TestCase
176
176
  end
177
177
  end
178
178
 
179
- context "dynamic s3_host_name" do
180
- setup do
181
- rebuild_model :storage => :s3,
182
- :s3_credentials => {},
183
- :bucket => "bucket",
184
- :path => ":attachment/:basename.:extension",
185
- :s3_host_name => lambda {|a| a.instance.value }
186
- @dummy = Dummy.new
187
- class << @dummy
188
- attr_accessor :value
189
- end
190
- @dummy.avatar = StringIO.new(".")
191
- end
192
-
193
- should "use s3_host_name as a proc if available" do
194
- @dummy.value = "s3.something.com"
195
- assert_equal "http://s3.something.com/bucket/avatars/stringio.txt", @dummy.avatar.url(:original, :timestamp => false)
196
- end
197
- end
198
-
199
179
  context "An attachment that uses S3 for storage and has styles that return different file types" do
200
180
  setup do
201
181
  rebuild_model :styles => { :large => ['500x500#', :jpg] },
@@ -76,9 +76,9 @@ class ThumbnailTest < Test::Unit::TestCase
76
76
  should "let us know when a command isn't found versus a processing error" do
77
77
  old_path = ENV['PATH']
78
78
  begin
79
+ ENV['PATH'] = ''
79
80
  Cocaine::CommandLine.path = ''
80
81
  Paperclip.options[:command_path] = ''
81
- ENV['PATH'] = ''
82
82
  assert_raises(Paperclip::CommandNotFoundError) do
83
83
  @thumb.make
84
84
  end
@@ -204,8 +204,6 @@ class ThumbnailTest < Test::Unit::TestCase
204
204
  should "let us know when a command isn't found versus a processing error" do
205
205
  old_path = ENV['PATH']
206
206
  begin
207
- Cocaine::CommandLine.path = ''
208
- Paperclip.options[:command_path] = ''
209
207
  ENV['PATH'] = ''
210
208
  assert_raises(Paperclip::CommandNotFoundError) do
211
209
  @thumb.make
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: 2.7.5
4
+ version: 2.8.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: 2013-01-25 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
@@ -48,17 +48,17 @@ dependencies:
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ~>
51
+ - - ! '>='
52
52
  - !ruby/object:Gem::Version
53
- version: 0.3.0
53
+ version: 0.0.2
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ~>
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.3.0
61
+ version: 0.0.2
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: mime-types
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -226,7 +226,7 @@ dependencies:
226
226
  requirements:
227
227
  - - ~>
228
228
  - !ruby/object:Gem::Version
229
- version: 0.3.0
229
+ version: 0.4.0
230
230
  type: :development
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
@@ -234,7 +234,7 @@ dependencies:
234
234
  requirements:
235
235
  - - ~>
236
236
  - !ruby/object:Gem::Version
237
- version: 0.3.0
237
+ version: 0.4.0
238
238
  - !ruby/object:Gem::Dependency
239
239
  name: fog
240
240
  requirement: !ruby/object:Gem::Requirement
@@ -417,7 +417,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
417
417
  requirements:
418
418
  - ImageMagick
419
419
  rubyforge_project: paperclip
420
- rubygems_version: 1.8.23
420
+ rubygems_version: 1.8.24
421
421
  signing_key:
422
422
  specification_version: 3
423
423
  summary: File attachments as attributes for ActiveRecord