rack_dav_sp 0.2.dev
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/.gitignore +4 -0
- data/CHANGELOG.md +27 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +31 -0
- data/LICENSE +18 -0
- data/README.md +107 -0
- data/Rakefile +36 -0
- data/bin/rack_dav +23 -0
- data/lib/rack_dav.rb +14 -0
- data/lib/rack_dav/builder_namespace.rb +21 -0
- data/lib/rack_dav/controller.rb +495 -0
- data/lib/rack_dav/file_resource.rb +168 -0
- data/lib/rack_dav/handler.rb +41 -0
- data/lib/rack_dav/http_status.rb +108 -0
- data/lib/rack_dav/resource.rb +185 -0
- data/lib/rack_dav/version.rb +16 -0
- data/rack_dav.gemspec +23 -0
- data/spec/controller_spec.rb +441 -0
- data/spec/file_resource_spec.rb +11 -0
- data/spec/fixtures/folder/01.txt +0 -0
- data/spec/fixtures/folder/02.txt +0 -0
- data/spec/fixtures/requests/lock.xml +12 -0
- data/spec/handler_spec.rb +37 -0
- data/spec/spec_helper.rb +27 -0
- data/spec/support/lockable_file_resource.rb +30 -0
- metadata +104 -0
File without changes
|
File without changes
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RackDAV::Handler do
|
4
|
+
|
5
|
+
describe "#initialize" do
|
6
|
+
it "accepts zero parameters" do
|
7
|
+
lambda do
|
8
|
+
klass.new
|
9
|
+
end.should_not raise_error
|
10
|
+
end
|
11
|
+
|
12
|
+
it "accepts a hash of options" do
|
13
|
+
lambda do
|
14
|
+
klass.new({})
|
15
|
+
klass.new :foo => "bar"
|
16
|
+
end.should_not raise_error
|
17
|
+
end
|
18
|
+
|
19
|
+
it "sets options from argument" do
|
20
|
+
instance = klass.new :foo => "bar"
|
21
|
+
instance.options[:foo].should == "bar"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "defaults option :resource_class to FileResource" do
|
25
|
+
instance = klass.new
|
26
|
+
instance.options[:resource_class].should be(RackDAV::FileResource)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "defaults option :root to current directory" do
|
30
|
+
path = File.expand_path("../../bin", __FILE__)
|
31
|
+
Dir.chdir(path)
|
32
|
+
instance = klass.new
|
33
|
+
instance.options[:root].should == path
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'rack_dav'
|
3
|
+
|
4
|
+
unless defined?(SPEC_ROOT)
|
5
|
+
SPEC_ROOT = File.expand_path("../", __FILE__)
|
6
|
+
end
|
7
|
+
|
8
|
+
module Helpers
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
# Gets the currently described class.
|
13
|
+
# Conversely to +subject+, it returns the class
|
14
|
+
# instead of an instance.
|
15
|
+
def klass
|
16
|
+
described_class
|
17
|
+
end
|
18
|
+
|
19
|
+
def fixture(*names)
|
20
|
+
File.join(SPEC_ROOT, "fixtures", *names)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
RSpec.configure do |config|
|
26
|
+
config.include Helpers
|
27
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module RackDAV
|
2
|
+
|
3
|
+
# Quick & Dirty
|
4
|
+
class LockableFileResource < FileResource
|
5
|
+
@@locks = {}
|
6
|
+
|
7
|
+
def lock(token, timeout, scope = nil, type = nil, owner = nil)
|
8
|
+
if scope && type && owner
|
9
|
+
# Create lock
|
10
|
+
@@locks[token] = {
|
11
|
+
:timeout => timeout,
|
12
|
+
:scope => scope,
|
13
|
+
:type => type,
|
14
|
+
:owner => owner
|
15
|
+
}
|
16
|
+
return true
|
17
|
+
else
|
18
|
+
# Refresh lock
|
19
|
+
lock = @@locks[token]
|
20
|
+
return false unless lock
|
21
|
+
return [ lock[:timeout], lock[:scope], lock[:type], lock[:owner] ]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def unlock(token)
|
26
|
+
!!@@locks.delete(token)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rack_dav_sp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.dev
|
5
|
+
prerelease: 4
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Matthias Georgi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-10-20 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rack
|
16
|
+
requirement: &70331008298980 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.2.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70331008298980
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: builder
|
27
|
+
requirement: &70331008298520 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70331008298520
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &70331008297880 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.6.0
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70331008297880
|
47
|
+
description: WebDAV handler for Rack.
|
48
|
+
email: matti.georgi@gmail.com
|
49
|
+
executables:
|
50
|
+
- rack_dav
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files:
|
53
|
+
- README.md
|
54
|
+
files:
|
55
|
+
- .gitignore
|
56
|
+
- CHANGELOG.md
|
57
|
+
- Gemfile
|
58
|
+
- Gemfile.lock
|
59
|
+
- LICENSE
|
60
|
+
- README.md
|
61
|
+
- Rakefile
|
62
|
+
- bin/rack_dav
|
63
|
+
- lib/rack_dav.rb
|
64
|
+
- lib/rack_dav/builder_namespace.rb
|
65
|
+
- lib/rack_dav/controller.rb
|
66
|
+
- lib/rack_dav/file_resource.rb
|
67
|
+
- lib/rack_dav/handler.rb
|
68
|
+
- lib/rack_dav/http_status.rb
|
69
|
+
- lib/rack_dav/resource.rb
|
70
|
+
- lib/rack_dav/version.rb
|
71
|
+
- rack_dav.gemspec
|
72
|
+
- spec/controller_spec.rb
|
73
|
+
- spec/file_resource_spec.rb
|
74
|
+
- spec/fixtures/folder/01.txt
|
75
|
+
- spec/fixtures/folder/02.txt
|
76
|
+
- spec/fixtures/requests/lock.xml
|
77
|
+
- spec/handler_spec.rb
|
78
|
+
- spec/spec_helper.rb
|
79
|
+
- spec/support/lockable_file_resource.rb
|
80
|
+
homepage: http://www.matthias-georgi.de/rack_dav
|
81
|
+
licenses: []
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ! '>'
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 1.3.1
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 1.8.10
|
101
|
+
signing_key:
|
102
|
+
specification_version: 3
|
103
|
+
summary: WebDAV handler for Rack.
|
104
|
+
test_files: []
|