railsdav 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -1
- data/lib/railsdav/routing_extensions.rb +18 -8
- metadata +2 -2
data/README.md
CHANGED
@@ -175,7 +175,8 @@ is_webdav_request? checks whether an Incoming request is issued by a WebDAV clie
|
|
175
175
|
|
176
176
|
## Changelog
|
177
177
|
|
178
|
-
* 0.0.
|
178
|
+
* 0.0.6: Fix update_all for Rails 3.2
|
179
|
+
* 0.0.5: Rails 3.2.x compatibility, add encoding hints, fix ResourceDescriptor load error
|
179
180
|
* 0.0.4: Basic support for allprop in PROPFIND
|
180
181
|
* 0.0.3: Change the API within the responder block to a more concise one
|
181
182
|
* 0.0.2: More or less a complete rewrite: Use more sensible API, modularize the renderer code, get rid of controller monkey patching
|
@@ -50,21 +50,29 @@ class ActionDispatch::Routing::Mapper
|
|
50
50
|
end
|
51
51
|
|
52
52
|
module Resources
|
53
|
-
CANONICAL_ACTIONS <<
|
53
|
+
CANONICAL_ACTIONS << 'update_all'
|
54
54
|
|
55
55
|
class WebDAVResource < Resource
|
56
56
|
DEFAULT_ACTIONS = [:index, :create, :new, :show, :update, :destroy, :edit, :update_all]
|
57
|
+
|
58
|
+
def default_actions
|
59
|
+
DEFAULT_ACTIONS
|
60
|
+
end
|
57
61
|
end
|
58
62
|
|
59
63
|
class WebDAVSingletonResource < SingletonResource
|
60
64
|
DEFAULT_ACTIONS = [:show, :create, :update, :destroy, :new, :edit]
|
65
|
+
|
66
|
+
def default_actions
|
67
|
+
DEFAULT_ACTIONS
|
68
|
+
end
|
61
69
|
end
|
62
70
|
|
63
71
|
def resource_scope?
|
64
72
|
[:webdav_resource, :webdav_resources, :resource, :resources].include?(@scope[:scope_level])
|
65
73
|
end
|
66
74
|
|
67
|
-
if Rails.version
|
75
|
+
if Rails.version < '3.2'
|
68
76
|
# Rails versions after 3.1 expect two arguments here, the first being :resource, :resources,
|
69
77
|
# :webdav_resource etc.so we don't need the inferring logic anymore in newer versions.
|
70
78
|
def resource_scope(resource)
|
@@ -87,7 +95,7 @@ class ActionDispatch::Routing::Mapper
|
|
87
95
|
end
|
88
96
|
|
89
97
|
def dav_options_response(*allowed_http_verbs)
|
90
|
-
|
98
|
+
proc { [200, {'Allow' => allowed_http_verbs.flatten.map{|s| s.to_s.upcase}.join(' '), 'DAV' => '1'}, ['']] }
|
91
99
|
end
|
92
100
|
|
93
101
|
def dav_match(*args)
|
@@ -96,13 +104,13 @@ class ActionDispatch::Routing::Mapper
|
|
96
104
|
end
|
97
105
|
|
98
106
|
def webdav_resource(*resources, &block)
|
99
|
-
options = resources.extract_options
|
107
|
+
options = resources.extract_options!.dup
|
100
108
|
|
101
109
|
if apply_common_behavior_for(:webdav_resource, resources, options, &block)
|
102
110
|
return self
|
103
111
|
end
|
104
112
|
|
105
|
-
sub_block =
|
113
|
+
sub_block = proc do
|
106
114
|
yield if block_given?
|
107
115
|
|
108
116
|
if parent_resource.actions.include?(:create)
|
@@ -127,7 +135,7 @@ class ActionDispatch::Routing::Mapper
|
|
127
135
|
end
|
128
136
|
end
|
129
137
|
|
130
|
-
if Rails.version
|
138
|
+
if Rails.version < '3.2'
|
131
139
|
resource_scope(WebDAVSingletonResource.new(resources.pop, options), &sub_block)
|
132
140
|
else
|
133
141
|
resource_scope(:webdav_resource, WebDAVSingletonResource.new(resources.pop, options), &sub_block)
|
@@ -143,7 +151,7 @@ class ActionDispatch::Routing::Mapper
|
|
143
151
|
return self
|
144
152
|
end
|
145
153
|
|
146
|
-
sub_block =
|
154
|
+
sub_block = proc do
|
147
155
|
yield if block_given?
|
148
156
|
|
149
157
|
opts = []
|
@@ -161,6 +169,8 @@ class ActionDispatch::Routing::Mapper
|
|
161
169
|
if parent_resource.actions.include?(:update_all)
|
162
170
|
put :index, :action => :update_all
|
163
171
|
opts << :put
|
172
|
+
else
|
173
|
+
puts "parent_resource #{parent_resource.inspect} does not include update_all: #{parent_resource.actions}"
|
164
174
|
end
|
165
175
|
dav_options :index, :to => dav_options_response(opts)
|
166
176
|
end
|
@@ -200,7 +210,7 @@ class ActionDispatch::Routing::Mapper
|
|
200
210
|
end
|
201
211
|
end
|
202
212
|
|
203
|
-
if Rails.version
|
213
|
+
if Rails.version < '3.2'
|
204
214
|
resource_scope(WebDAVResource.new(resources.pop, options), &sub_block)
|
205
215
|
else
|
206
216
|
resource_scope(:webdav_resources, WebDAVResource.new(resources.pop, options), &sub_block)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: railsdav
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-24 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Provides basic Rails 3/Rails 4 extensions for making your business resources
|
15
15
|
accessible via WebDAV. This gem does by no means by no means implement the full
|