rack-raw-upload 0.1.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  module Rack
2
2
  class RawUpload
3
3
 
4
- VERSION = '0.1.1'
4
+ VERSION = '1.0.3'
5
5
 
6
6
  def initialize(app, opts = {})
7
7
  @app = app
@@ -28,7 +28,13 @@ module Rack
28
28
 
29
29
  def convert_and_pass_on(env)
30
30
  tempfile = Tempfile.new('raw-upload.', @tmpdir)
31
- tempfile = open(tempfile.path, "r+:BINARY")
31
+ if (RUBY_VERSION.split('.').map{|e| e.to_i} <=> [1, 9]) > 0
32
+ # 1.8.7: if the 'original' tempfile has no open file-handler,
33
+ # the garbage collector will unlink this file.
34
+ # in this case, only the path to the 'original' tempfile is used
35
+ # and the physical file will be deleted, if the gc runs.
36
+ tempfile = open(tempfile.path, "r+:BINARY")
37
+ end
32
38
  tempfile << env['rack.input'].read
33
39
  tempfile.flush
34
40
  tempfile.rewind
@@ -63,6 +63,13 @@ class RawUploadTest < Test::Unit::TestCase
63
63
  assert_successful_non_upload
64
64
  end
65
65
 
66
+ should "be compatible to rails 1.8.7 and tempfile must exist after garbage collection" do
67
+ upload('CONTENT_TYPE' => 'application/octet-stream')
68
+ received = last_request.POST["file"]
69
+ GC.start
70
+ assert File.exists?(received[:tempfile].path)
71
+ end
72
+
66
73
  context "with X-File-Upload: smart" do
67
74
  should "perform a file upload if appropriate" do
68
75
  upload('CONTENT_TYPE' => 'multipart/form-data', 'HTTP_X_FILE_UPLOAD' => 'smart')
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-raw-upload
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
4
  prerelease: false
6
5
  segments:
7
- - 0
8
- - 1
9
6
  - 1
10
- version: 0.1.1
7
+ - 0
8
+ - 3
9
+ version: 1.0.3
11
10
  platform: ruby
12
11
  authors:
13
12
  - Pablo Brasero
@@ -15,18 +14,16 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-01-12 00:00:00 +00:00
17
+ date: 2011-05-31 00:00:00 +01:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: json
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
25
  - - ">="
28
26
  - !ruby/object:Gem::Version
29
- hash: 3
30
27
  segments:
31
28
  - 0
32
29
  version: "0"
@@ -36,11 +33,9 @@ dependencies:
36
33
  name: rake
37
34
  prerelease: false
38
35
  requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
36
  requirements:
41
37
  - - ">="
42
38
  - !ruby/object:Gem::Version
43
- hash: 3
44
39
  segments:
45
40
  - 0
46
41
  version: "0"
@@ -50,11 +45,9 @@ dependencies:
50
45
  name: rack-test
51
46
  prerelease: false
52
47
  requirement: &id003 !ruby/object:Gem::Requirement
53
- none: false
54
48
  requirements:
55
49
  - - ">="
56
50
  - !ruby/object:Gem::Version
57
- hash: 3
58
51
  segments:
59
52
  - 0
60
53
  version: "0"
@@ -64,11 +57,9 @@ dependencies:
64
57
  name: shoulda
65
58
  prerelease: false
66
59
  requirement: &id004 !ruby/object:Gem::Requirement
67
- none: false
68
60
  requirements:
69
61
  - - ">="
70
62
  - !ruby/object:Gem::Version
71
- hash: 3
72
63
  segments:
73
64
  - 0
74
65
  version: "0"
@@ -102,27 +93,23 @@ rdoc_options:
102
93
  require_paths:
103
94
  - lib
104
95
  required_ruby_version: !ruby/object:Gem::Requirement
105
- none: false
106
96
  requirements:
107
97
  - - ">="
108
98
  - !ruby/object:Gem::Version
109
- hash: 3
110
99
  segments:
111
100
  - 0
112
101
  version: "0"
113
102
  required_rubygems_version: !ruby/object:Gem::Requirement
114
- none: false
115
103
  requirements:
116
104
  - - ">="
117
105
  - !ruby/object:Gem::Version
118
- hash: 3
119
106
  segments:
120
107
  - 0
121
108
  version: "0"
122
109
  requirements: []
123
110
 
124
111
  rubyforge_project:
125
- rubygems_version: 1.3.7
112
+ rubygems_version: 1.3.6
126
113
  signing_key:
127
114
  specification_version: 3
128
115
  summary: Rack Raw Upload middleware