dragonfly 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of dragonfly might be problematic. Click here for more details.

data/History.md CHANGED
@@ -1,3 +1,10 @@
1
+ 0.9.4 (2011-06-10)
2
+ ==================
3
+ Fixes
4
+ -----
5
+ - Made use of Rack calling `close` on the response body to clean up tempfiles.
6
+ The response body is now the job, which delegates `each` to the temp_object.
7
+
1
8
  0.9.3 (2011-06-03)
2
9
  ==================
3
10
  Fixes
data/README.md CHANGED
@@ -12,7 +12,7 @@ For the lazy Rails user...
12
12
  **Gemfile**:
13
13
 
14
14
  gem 'rack-cache', :require => 'rack/cache'
15
- gem 'dragonfly', '~>0.9.2'
15
+ gem 'dragonfly', '~>0.9.4'
16
16
 
17
17
  **Initializer** (e.g. config/initializers/dragonfly.rb):
18
18
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.3
1
+ 0.9.4
data/dragonfly.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dragonfly}
8
- s.version = "0.9.3"
8
+ s.version = "0.9.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mark Evans"]
12
- s.date = %q{2011-06-03}
12
+ s.date = %q{2011-06-10}
13
13
  s.description = %q{Dragonfly is a framework that enables on-the-fly processing for any content type.
14
14
  It is especially suited to image handling. Its uses range from image thumbnails to standard attachments to on-demand text generation.}
15
15
  s.email = %q{mark@new-bamboo.co.uk}
data/extra_docs/Rails3.md CHANGED
@@ -33,7 +33,7 @@ application.rb:
33
33
  Gemfile
34
34
  -------
35
35
 
36
- gem 'dragonfly', '~>0.9.2'
36
+ gem 'dragonfly', '~>0.9.4'
37
37
  gem 'rack-cache', :require => 'rack/cache'
38
38
 
39
39
  Capistrano
data/lib/dragonfly/job.rb CHANGED
@@ -19,7 +19,7 @@ module Dragonfly
19
19
 
20
20
  extend Forwardable
21
21
  def_delegators :result,
22
- :data, :file, :tempfile, :path, :to_file, :size
22
+ :data, :file, :tempfile, :path, :to_file, :size, :each
23
23
  def_delegator :app, :server
24
24
 
25
25
  class Step
@@ -201,6 +201,7 @@ module Dragonfly
201
201
  @steps = []
202
202
  @next_step_index = 0
203
203
  @meta = {}
204
+ @previous_temp_objects = []
204
205
  update(content, meta)
205
206
  end
206
207
 
@@ -211,8 +212,13 @@ module Dragonfly
211
212
  end
212
213
  end
213
214
 
214
- attr_accessor :temp_object
215
215
  attr_reader :app, :steps
216
+ attr_reader :temp_object
217
+
218
+ def temp_object=(temp_object)
219
+ previous_temp_objects.push(@temp_object) if @temp_object
220
+ @temp_object = temp_object
221
+ end
216
222
 
217
223
  # define fetch(), fetch!(), process(), etc.
218
224
  STEPS.each do |step_class|
@@ -317,10 +323,6 @@ module Dragonfly
317
323
  to_app.call(env)
318
324
  end
319
325
 
320
- def to_path
321
- "/#{serialize}"
322
- end
323
-
324
326
  def to_fetched_job(uid)
325
327
  new_job = self.class.new(app, temp_object, meta)
326
328
  new_job.fetch!(uid)
@@ -418,6 +420,11 @@ module Dragonfly
418
420
  end
419
421
  end
420
422
 
423
+ def close
424
+ previous_temp_objects.each{|temp_object| temp_object.close }
425
+ temp_object.close if temp_object
426
+ end
427
+
421
428
  protected
422
429
 
423
430
  attr_writer :steps
@@ -425,6 +432,8 @@ module Dragonfly
425
432
 
426
433
  private
427
434
 
435
+ attr_reader :previous_temp_objects
436
+
428
437
  def format_from_meta
429
438
  meta[:format] || (ext.to_sym if ext && app.trust_file_extensions)
430
439
  end
@@ -24,7 +24,7 @@ module Dragonfly
24
24
  elsif request.get?
25
25
  job.apply
26
26
  env['dragonfly.job'] = job
27
- [200, success_headers, job.result]
27
+ [200, success_headers, job]
28
28
  end
29
29
  rescue DataStorage::DataNotFound, DataStorage::BadUID => e
30
30
  app.log.warn(e.message)
@@ -1022,4 +1022,28 @@ describe Dragonfly::Job do
1022
1022
  end
1023
1023
  end
1024
1024
 
1025
+ describe "close" do
1026
+ before(:each) do
1027
+ @app = test_app
1028
+ @app.generator.add(:toast){ "toast" }
1029
+ @app.processor.add(:upcase){|t| t.data.upcase }
1030
+ @job = @app.generate(:toast)
1031
+ @path1 = @job.tempfile.path
1032
+ @job.process!(:upcase)
1033
+ @path2 = @job.tempfile.path
1034
+ end
1035
+
1036
+ it "should clean up tempfiles for the last temp_object" do
1037
+ File.exist?(@path2).should be_true
1038
+ @job.close
1039
+ File.exist?(@path2).should be_false
1040
+ end
1041
+
1042
+ it "should clean up tempfiles for previous temp_objects" do
1043
+ File.exist?(@path1).should be_true
1044
+ @job.close
1045
+ File.exist?(@path1).should be_false
1046
+ end
1047
+ end
1048
+
1025
1049
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: dragonfly
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.9.3
5
+ version: 0.9.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mark Evans
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-03 00:00:00 +01:00
13
+ date: 2011-06-10 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -401,7 +401,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
401
401
  requirements:
402
402
  - - ">="
403
403
  - !ruby/object:Gem::Version
404
- hash: 3515566453882631482
404
+ hash: 1699270307650863016
405
405
  segments:
406
406
  - 0
407
407
  version: "0"