dav4rack 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -2,9 +2,19 @@
2
2
 
3
3
  DAV4Rack is a framework for providing WebDAV via Rack allowing content
4
4
  authoring over HTTP. It is based off the {original RackDAV framework}[http://github.com/georgi/rack_dav]
5
- to provide better Resource support for building customized WebDAV resources
6
- completely abstracted from the filesystem. Support for authentication and
7
- locking has been added as well as a move from REXML to Nokogiri. Enjoy!
5
+ adding some useful new features:
6
+
7
+ * Better resource support for building fully virtualized resource structures
8
+ * Generic locking as well as Resource level specific locking
9
+ * Interceptor middleware to provide virtual mapping to resources
10
+ * Mapped resource paths
11
+ * Authentication support
12
+ * Resource callbacks
13
+ * Remote file proxying (including sendfile support for remote files)
14
+ * Nokogiri based document parsing and building
15
+
16
+ If you find issues, please create a new issue on github. If you have fixes, please fork the repo and send me
17
+ a pull request with your modifications. If you are just here to use the library, enjoy!
8
18
 
9
19
  == Install
10
20
 
@@ -283,7 +293,7 @@ without getting stuck in a loop.
283
293
 
284
294
  === Unknown Issues
285
295
 
286
- Please use the issues at github: http://github.com/chrisroberts/dav4rack
296
+ Please use the issues at github: http://github.com/chrisroberts/dav4rack/issues
287
297
 
288
298
  == License
289
299
 
data/bin/dav4rack CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'rubygems'
4
- require 'dav4rack'
4
+ require 'dav4rack/version'
5
5
  require 'getoptlong'
6
6
 
7
7
  def print_help_msg
@@ -52,6 +52,8 @@ opts.each do |opt,arg|
52
52
  end
53
53
  end
54
54
 
55
+ require 'dav4rack'
56
+
55
57
  app = Rack::Builder.new do
56
58
  use Rack::ShowExceptions
57
59
  use Rack::CommonLogger
@@ -62,14 +64,28 @@ app = Rack::Builder.new do
62
64
 
63
65
  end.to_app
64
66
 
65
- begin
66
- puts 'Attempting to start unicorn...'
67
+ runners = []
68
+ runners << lambda do |x|
69
+ print 'Looking for unicorn... '
67
70
  require 'unicorn'
68
- Unicorn.run(app, :listeners => ["0.0.0.0:3000"])
69
- rescue => e
70
- puts "Failed to start unicorn (#{e}). Starting mongrel..."
71
- Rack::Handler::Mongrel.run(app, :Port => 3000)
72
- rescue => e
73
- puts "Failed to start mongrel (#{e}). Falling back to WEBrick."
74
- Rack::Handler::WEBrick.run(app, :Port => 3000)
71
+ puts 'OK'
72
+ Unicorn.run(x, :listeners => ["0.0.0.0:3000"])
73
+ end
74
+ runners << lambda do |x|
75
+ print 'Looking for mongrel... '
76
+ require 'mongrel'
77
+ puts 'OK'
78
+ Rack::Handler::Mongrel.run(x, :Port => 3000)
79
+ end
80
+ runners << lambda do |x|
81
+ puts 'Loading WEBrick'
82
+ Rack::Handler::WEBrick.run(x, :Port => 3000)
83
+ end
84
+
85
+ begin
86
+ runner = runners.shift
87
+ runner.call(app)
88
+ rescue LoadError
89
+ puts 'FAILED'
90
+ retry unless runners.empty?
75
91
  end
data/dav4rack.gemspec CHANGED
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.extra_rdoc_files = ['README.rdoc']
15
15
  s.add_dependency 'nokogiri', '~> 1.4.2'
16
16
  s.add_dependency 'uuidtools', '~> 2.1.1'
17
+ s.add_dependency 'rack', '>= 1.1.0'
17
18
  s.files = %w{
18
19
  .gitignore
19
20
  LICENSE
@@ -6,12 +6,8 @@ module DAV4Rack
6
6
 
7
7
  include WEBrick::HTTPUtils
8
8
 
9
- def authenticate(user, pass)
10
- if(options[:username])
11
- options[:username] == user && options[:password] == pass
12
- else
13
- true
14
- end
9
+ before do |resource, method_name|
10
+ resource.send(:check_authentication)
15
11
  end
16
12
 
17
13
  # If this is a collection, return the child resources.
@@ -159,6 +155,29 @@ module DAV4Rack
159
155
 
160
156
  private
161
157
 
158
+ def check_authentication
159
+ valid = true
160
+ if(options[:username])
161
+ valid = false
162
+ if(request.env['HTTP_AUTHORIZATION'])
163
+ auth = Rack::Auth::Basic::Request.new(request.env)
164
+ if(auth.basic? && auth.credentials)
165
+ valid = options[:username] == auth.credentials[0] && options[:password] == auth.credentials[1]
166
+ end
167
+ end
168
+ end
169
+ raise Unauthorized unless valid
170
+ valid
171
+ end
172
+
173
+ def authenticate(user, pass)
174
+ if(options[:username])
175
+ options[:username] == user && options[:password] == pass
176
+ else
177
+ true
178
+ end
179
+ end
180
+
162
181
  def root
163
182
  @options[:root]
164
183
  end
@@ -42,7 +42,7 @@ module DAV4Rack
42
42
  response['Content-Length'] = response.body.to_s.length unless response['Content-Length'] || !response.body.is_a?(String)
43
43
  response.body = [response.body] if not response.body.respond_to? :each
44
44
  response.status = response.status ? response.status.to_i : 200
45
- response.headers.each_pair{|k,v| response[k] = v.to_s}
45
+ response.headers.keys.each{|k| response.headers[k] = response[k].to_s}
46
46
 
47
47
  # Apache wants the body dealt with, so just read it and junk it
48
48
  buf = true
@@ -1,3 +1,3 @@
1
1
  module DAV4Rack
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dav4rack
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 1
9
- - 2
10
- version: 0.1.2
8
+ - 3
9
+ version: 0.1.3
11
10
  platform: ruby
12
11
  authors:
13
12
  - Chris Roberts
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-08-12 00:00:00 -07:00
17
+ date: 2010-09-30 00:00:00 -07:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - ~>
28
27
  - !ruby/object:Gem::Version
29
- hash: 3
30
28
  segments:
31
29
  - 1
32
30
  - 4
@@ -42,7 +40,6 @@ dependencies:
42
40
  requirements:
43
41
  - - ~>
44
42
  - !ruby/object:Gem::Version
45
- hash: 9
46
43
  segments:
47
44
  - 2
48
45
  - 1
@@ -50,6 +47,21 @@ dependencies:
50
47
  version: 2.1.1
51
48
  type: :runtime
52
49
  version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: rack
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 1
60
+ - 1
61
+ - 0
62
+ version: 1.1.0
63
+ type: :runtime
64
+ version_requirements: *id003
53
65
  description: WebDAV handler for Rack
54
66
  email: chrisroberts.code@gmail.com
55
67
  executables:
@@ -92,7 +104,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
104
  requirements:
93
105
  - - ">="
94
106
  - !ruby/object:Gem::Version
95
- hash: 3
96
107
  segments:
97
108
  - 0
98
109
  version: "0"
@@ -101,7 +112,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
112
  requirements:
102
113
  - - ">="
103
114
  - !ruby/object:Gem::Version
104
- hash: 3
105
115
  segments:
106
116
  - 0
107
117
  version: "0"