dav4rack 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/dav4rack +29 -1
- data/lib/dav4rack/controller.rb +5 -4
- data/lib/dav4rack/file_resource.rb +1 -2
- data/lib/dav4rack/handler.rb +3 -1
- data/lib/dav4rack/version.rb +1 -1
- metadata +9 -3
data/bin/dav4rack
CHANGED
@@ -12,6 +12,8 @@ def print_help_msg
|
|
12
12
|
puts " --username name Set username"
|
13
13
|
puts " --password pass Set password"
|
14
14
|
puts " --root /share/path Set path to share directory"
|
15
|
+
puts " --log /path/to/log Set path for logging file"
|
16
|
+
puts " --verbosity opt Set logging verbosity. (Valid: debug,info,warn,fatal)"
|
15
17
|
end
|
16
18
|
|
17
19
|
def print_version_info
|
@@ -23,7 +25,9 @@ opts = GetoptLong.new(
|
|
23
25
|
['--password', '-p', GetoptLong::REQUIRED_ARGUMENT],
|
24
26
|
['--help', '-h', GetoptLong::NO_ARGUMENT],
|
25
27
|
['--version', '-v', GetoptLong::NO_ARGUMENT],
|
26
|
-
['--root', '-r', GetoptLong::REQUIRED_ARGUMENT]
|
28
|
+
['--root', '-r', GetoptLong::REQUIRED_ARGUMENT],
|
29
|
+
['--log', '-l', GetoptLong::OPTIONAL_ARGUMENT],
|
30
|
+
['--verbosity', '-V', GetoptLong::REQUIRED_ARGUMENT]
|
27
31
|
)
|
28
32
|
|
29
33
|
credentials = {}
|
@@ -46,6 +50,30 @@ opts.each do |opt,arg|
|
|
46
50
|
when '--version'
|
47
51
|
print_version_info
|
48
52
|
exit(0)
|
53
|
+
when '--log'
|
54
|
+
require 'pathname'
|
55
|
+
require 'logger'
|
56
|
+
credentials[:log_to] = [nil, Logger::FATAL] unless credentials[:log_to]
|
57
|
+
if(arg && !arg.empty?)
|
58
|
+
dirname = Pathname.new(arg).dirname
|
59
|
+
if((File.exists?(arg) && File.writable?(arg)) || (File.exists?(dirname) && File.writable?(dirname)))
|
60
|
+
credentials[:log_to][0] = arg
|
61
|
+
else
|
62
|
+
puts "ERROR: Log file is not writable: #{arg}"
|
63
|
+
exit(-1)
|
64
|
+
end
|
65
|
+
else
|
66
|
+
credentials[:log_to][0] = $stdout
|
67
|
+
end
|
68
|
+
when '--verbosity'
|
69
|
+
require 'logger'
|
70
|
+
begin
|
71
|
+
credentials[:log_to] = [] unless credentials[:log_to]
|
72
|
+
credentials[:log_to][1] = Logger.const_get(arg.upcase)
|
73
|
+
rescue NameError
|
74
|
+
puts "ERROR: Unknown verbosity level given: #{arg}"
|
75
|
+
exit(-1)
|
76
|
+
end
|
49
77
|
else
|
50
78
|
puts "ERROR: Unknown option provided"
|
51
79
|
exit(-1)
|
data/lib/dav4rack/controller.rb
CHANGED
@@ -362,9 +362,10 @@
|
|
362
362
|
# Render XML and set Rack::Response#body= to final XML
|
363
363
|
def render_xml(root_type)
|
364
364
|
raise ArgumentError.new 'Expecting block' unless block_given?
|
365
|
-
doc = Nokogiri::XML::Builder.new do |
|
366
|
-
|
367
|
-
|
365
|
+
doc = Nokogiri::XML::Builder.new do |xml_base|
|
366
|
+
xml_base.send(root_type.to_s, 'xmlns:D' => 'DAV:') do
|
367
|
+
xml_base.parent.namespace = xml_base.parent.namespace_definitions.first
|
368
|
+
xml = xml_base['D']
|
368
369
|
yield xml
|
369
370
|
end
|
370
371
|
end
|
@@ -402,7 +403,7 @@
|
|
402
403
|
for name in names
|
403
404
|
begin
|
404
405
|
val = resource.get_property(name)
|
405
|
-
stats[OK].push [name, val]
|
406
|
+
stats[OK].push [name, val]
|
406
407
|
rescue Unauthorized => u
|
407
408
|
raise u
|
408
409
|
rescue Status
|
data/lib/dav4rack/handler.rb
CHANGED
@@ -19,6 +19,8 @@ module DAV4Rack
|
|
19
19
|
request = Rack::Request.new(env)
|
20
20
|
response = Rack::Response.new
|
21
21
|
|
22
|
+
Logger.info "Processing WebDAV request: #{request.path} (for #{request.ip} at #{Time.now}) [#{request.request_method}]"
|
23
|
+
|
22
24
|
controller = nil
|
23
25
|
begin
|
24
26
|
controller = Controller.new(request, response, @options.dup)
|
@@ -48,7 +50,7 @@ module DAV4Rack
|
|
48
50
|
buf = true
|
49
51
|
buf = request.body.read(8192) while buf
|
50
52
|
|
51
|
-
Logger.
|
53
|
+
Logger.debug "Response in string form. Outputting contents: \n#{response.body}" if response.body.is_a?(String)
|
52
54
|
Logger.info "Completed in: #{((Time.now.to_f - start.to_f) * 1000).to_i} ms | #{response.status} [#{request.url}]"
|
53
55
|
|
54
56
|
response.body.is_a?(Rack::File) ? response.body.call(env) : response.finish
|
data/lib/dav4rack/version.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dav4rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Chris Roberts
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-10-22 00:00:00 -07:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -25,6 +26,7 @@ dependencies:
|
|
25
26
|
requirements:
|
26
27
|
- - ~>
|
27
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
28
30
|
segments:
|
29
31
|
- 1
|
30
32
|
- 4
|
@@ -40,6 +42,7 @@ dependencies:
|
|
40
42
|
requirements:
|
41
43
|
- - ~>
|
42
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 9
|
43
46
|
segments:
|
44
47
|
- 2
|
45
48
|
- 1
|
@@ -55,6 +58,7 @@ dependencies:
|
|
55
58
|
requirements:
|
56
59
|
- - ">="
|
57
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 19
|
58
62
|
segments:
|
59
63
|
- 1
|
60
64
|
- 1
|
@@ -104,6 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
104
108
|
requirements:
|
105
109
|
- - ">="
|
106
110
|
- !ruby/object:Gem::Version
|
111
|
+
hash: 3
|
107
112
|
segments:
|
108
113
|
- 0
|
109
114
|
version: "0"
|
@@ -112,6 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
117
|
requirements:
|
113
118
|
- - ">="
|
114
119
|
- !ruby/object:Gem::Version
|
120
|
+
hash: 3
|
115
121
|
segments:
|
116
122
|
- 0
|
117
123
|
version: "0"
|