rack-uploads 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.1
@@ -7,17 +7,23 @@ module Rack
7
7
  @nginx = options[:nginx] || [{ :tmp_path => "_tmp_path", :filename => "_file_name" }]
8
8
  end
9
9
 
10
+ def extract_uploads_from_arguments(req, params, uploads=[])
11
+ params.each do |key,param|
12
+ if param_file = file(req, key, param)
13
+ uploads << param_file
14
+ params[key] = param_file
15
+ elsif param.instance_of?(Hash)
16
+ uploads = extract_uploads_from_arguments(req, param, uploads)
17
+ end
18
+ end
19
+ uploads
20
+ end
21
+
10
22
  def call(env)
11
23
  req = Rack::Request.new(env)
12
24
  if req.post? && req.form_data?
13
25
  return not_authorized unless @session_authorized == true || (@session_authorized.respond_to?(:call) && @session_authorized.call(req) == true)
14
- uploads = []
15
- req.params.each do |key,param|
16
- if param_file = file(req, key)
17
- uploads << param_file
18
- req.params[key] = param_file
19
- end
20
- end
26
+ uploads = extract_uploads_from_arguments(req, req.params)
21
27
  env['rack.uploads'] = uploads if uploads.size > 0
22
28
  end
23
29
  resp = @app.call(env)
@@ -31,8 +37,7 @@ module Rack
31
37
  req.media_type == "multipart/form-data"
32
38
  end
33
39
 
34
- def file(req, key)
35
- param = req.params[key]
40
+ def file(req, key, param)
36
41
  return UploadedFile.new(key, param) if param.instance_of?(Hash) && param[:tempfile]
37
42
  @nginx.each do |nginx|
38
43
  if key =~ %r{^(.+)#{nginx[:tmp_path]}$}
data/rack-uploads.gemspec CHANGED
@@ -1,12 +1,15 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{rack-uploads}
5
- s.version = "0.1.0"
8
+ s.version = "0.2.1"
6
9
 
7
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
11
  s.authors = ["Mutwin Kraus"]
9
- s.date = %q{2009-06-13}
12
+ s.date = %q{2009-10-13}
10
13
  s.email = %q{mutle@blogage.de}
11
14
  s.extra_rdoc_files = [
12
15
  "LICENSE",
@@ -32,7 +35,7 @@ Gem::Specification.new do |s|
32
35
  s.homepage = %q{http://github.com/mutle/rack-uploads}
33
36
  s.rdoc_options = ["--charset=UTF-8"]
34
37
  s.require_paths = ["lib"]
35
- s.rubygems_version = %q{1.3.3}
38
+ s.rubygems_version = %q{1.3.5}
36
39
  s.summary = %q{Rack Upload handler with Nginx Upload Module support}
37
40
  s.test_files = [
38
41
  "spec/middleware_spec.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-uploads
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mutwin Kraus
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-13 00:00:00 +02:00
12
+ date: 2009-10-13 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -62,8 +62,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
62
  requirements: []
63
63
 
64
64
  rubyforge_project:
65
- rubygems_version: 1.3.3
65
+ rubygems_version: 1.3.5
66
66
  signing_key:
67
+ source:
67
68
  specification_version: 3
68
69
  summary: Rack Upload handler with Nginx Upload Module support
69
70
  test_files: