Reorganize WebDavRequest and Resource classes

This commit is contained in:
Brandon Robins
2017-12-23 15:53:50 -06:00
parent 9dff70a3c0
commit a8ac618519
15 changed files with 145 additions and 18 deletions

View File

@@ -10,17 +10,17 @@ require 'calligraphy/utils'
require 'calligraphy/resource/resource'
require 'calligraphy/resource/file_resource'
require 'calligraphy/web_dav_request'
require 'calligraphy/copy'
require 'calligraphy/delete'
require 'calligraphy/get'
require 'calligraphy/lock'
require 'calligraphy/mkcol'
require 'calligraphy/move'
require 'calligraphy/propfind'
require 'calligraphy/proppatch'
require 'calligraphy/put'
require 'calligraphy/unlock'
require 'calligraphy/web_dav_request/web_dav_request'
require 'calligraphy/web_dav_request/copy'
require 'calligraphy/web_dav_request/delete'
require 'calligraphy/web_dav_request/get'
require 'calligraphy/web_dav_request/lock'
require 'calligraphy/web_dav_request/mkcol'
require 'calligraphy/web_dav_request/move'
require 'calligraphy/web_dav_request/propfind'
require 'calligraphy/web_dav_request/proppatch'
require 'calligraphy/web_dav_request/put'
require 'calligraphy/web_dav_request/unlock'
module Calligraphy
# Constants used throughout Calligraphy.

View File

@@ -421,17 +421,25 @@ module Calligraphy
def get_property(prop)
case prop.name
when 'creationdate'
prop.content = @stats[:created_at]
prop.content = creationdate
when 'displayname'
prop.content = @name
prop.content = displayname
when 'getcontentlanguage'
prop.content = getcontentlanguage
when 'getcontentlength'
prop.content = @stats[:size]
prop.content = getcontentlength
when 'getcontenttype'
prop.content = getcontenttype
when 'getetag'
prop.content = getetag
when 'getlastmodified'
prop.content = @updated_at
when 'resourcetype'
prop.content = 'collection'
prop.content = getlastmodified
when 'lockdiscovery'
return get_lock_info
when 'resourcetype'
prop.content = resourcetype
when 'supportedlock'
prop.content = supportedlock
else
return get_custom_property prop.name
end
@@ -439,6 +447,46 @@ module Calligraphy
prop
end
def creationdate
@stats[:created_at]
end
def displayname
@name
end
def getcontentlanguage
nil
end
def getcontentlength
@stats[:size]
end
def getcontenttype
nil
end
def getetag
nil
end
def getlastmodified
@updated_at
end
def lockdiscovery
get_lock_info
end
def resourcetype
'collection'
end
def supportedlock
nil
end
def get_custom_property(prop)
@store_properties ||= @store.transaction(true) { @store[:properties] }
@store_properties[prop.to_sym] unless @store_properties.nil? || prop.nil?

View File

@@ -89,5 +89,51 @@ module Calligraphy
def write(contents=@request_body.to_s)
raise NotImplementedError
end
end
private
def creationdate
raise NotImplementedError
end
def displayname
raise NotImplementedError
end
def getcontentlanguage
raise NotImplementedError
end
def getcontentlength
raise NotImplementedError
end
def getcontenttype
raise NotImplementedError
end
def getetag
raise NotImplementedError
end
def getlastmodified
raise NotImplementedError
end
def lockdiscovery
raise NotImplementedError
end
def resourcetype
raise NotImplementedError
end
def supportedlock
raise NotImplementedError
end
def get_custom_property(prop)
raise NotImplementedError
end
end
end