Add Resource class

This commit is contained in:
Brandon Robins
2017-10-24 22:41:10 -05:00
parent 2dcf872c7f
commit 1023029663
2 changed files with 99 additions and 0 deletions

View File

@@ -6,6 +6,8 @@ require 'calligraphy/xml/namespace'
require 'calligraphy/xml/node' require 'calligraphy/xml/node'
require 'calligraphy/xml/utils' require 'calligraphy/xml/utils'
require 'calligraphy/resource'
require 'calligraphy/web_dav_request' require 'calligraphy/web_dav_request'
module Calligraphy module Calligraphy

View File

@@ -0,0 +1,97 @@
module Calligraphy
class Resource
attr_accessor :contents
attr_reader :full_request_path
attr_reader :mount_point
attr_reader :request_body
attr_reader :request_path
def initialize(resource: nil, req: nil, mount: nil)
@full_request_path = req&.original_url
@mount_point = mount || req&.path&.tap { |s| s.slice! resource }
@request_body = req&.body&.read || ''
@request_path = mount.nil? ? resource : resource.split(mount)[-1]
end
def ancestor_exist?
raise NotImplemented
end
def can_copy?(options)
raise NotImplemented
end
def collection?
raise NotImplemented
end
def copy(options)
raise NotImplemented
end
def create_collection
raise NotImplemented
end
def delete_collection
raise NotImplemented
end
def etag
raise NotImplemented
end
def exists?
raise NotImplemented
end
def lock(nodes, depth='infinity')
raise NotImplemented
end
def lock_is_exclusive?
raise NotImplemented
end
def lock_tokens
raise NotImplemented
end
def locked?
raise NotImplemented
end
def locked_to_user?(headers=nil)
raise NotImplemented
end
def propfind(nodes)
raise NotImplemented
end
def proppatch(nodes)
raise NotImplemented
end
def read
raise NotImplemented
end
def readable?
exists? && !collection?
end
def refresh_lock
raise NotImplemented
end
def unlock(token)
raise NotImplemented
end
def write(contents=@request_body.to_s)
raise NotImplemented
end
end
end