calligraphy 0.2.1 → 0.3.1
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.
- checksums.yaml +5 -5
- data/README.md +1 -1
- data/lib/calligraphy.rb +23 -17
- data/lib/calligraphy/rails/mapper.rb +150 -142
- data/lib/calligraphy/rails/web_dav_methods.rb +67 -0
- data/lib/calligraphy/rails/web_dav_preconditions.rb +114 -0
- data/lib/calligraphy/rails/web_dav_requests_controller.rb +72 -180
- data/lib/calligraphy/resource/file_resource.rb +377 -194
- data/lib/calligraphy/resource/resource.rb +192 -32
- data/lib/calligraphy/utils.rb +23 -6
- data/lib/calligraphy/version.rb +3 -1
- data/lib/calligraphy/{copy.rb → web_dav_request/copy.rb} +13 -8
- data/lib/calligraphy/{delete.rb → web_dav_request/delete.rb} +6 -2
- data/lib/calligraphy/web_dav_request/get.rb +18 -0
- data/lib/calligraphy/web_dav_request/lock.rb +89 -0
- data/lib/calligraphy/{mkcol.rb → web_dav_request/mkcol.rb} +7 -2
- data/lib/calligraphy/web_dav_request/move.rb +56 -0
- data/lib/calligraphy/web_dav_request/propfind.rb +24 -0
- data/lib/calligraphy/web_dav_request/proppatch.rb +29 -0
- data/lib/calligraphy/web_dav_request/put.rb +16 -0
- data/lib/calligraphy/{unlock.rb → web_dav_request/unlock.rb} +6 -1
- data/lib/calligraphy/web_dav_request/web_dav_request.rb +43 -0
- data/lib/calligraphy/xml/builder.rb +83 -117
- data/lib/calligraphy/xml/namespace.rb +12 -6
- data/lib/calligraphy/xml/node.rb +24 -10
- data/lib/calligraphy/xml/utils.rb +22 -11
- data/lib/calligraphy/xml/web_dav_elements.rb +92 -0
- data/lib/generators/calligraphy/install_generator.rb +4 -0
- data/lib/generators/templates/calligraphy.rb +2 -0
- metadata +109 -22
- data/lib/calligraphy/get.rb +0 -12
- data/lib/calligraphy/lock.rb +0 -52
- data/lib/calligraphy/move.rb +0 -31
- data/lib/calligraphy/propfind.rb +0 -18
- data/lib/calligraphy/proppatch.rb +0 -20
- data/lib/calligraphy/put.rb +0 -12
- data/lib/calligraphy/web_dav_request.rb +0 -31
- data/spec/spec_helper.rb +0 -46
data/lib/calligraphy/move.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
module Calligraphy
|
2
|
-
class Move < Copy
|
3
|
-
def request
|
4
|
-
return :locked if @resource.locked_to_user? @headers
|
5
|
-
|
6
|
-
options = copy_move_options
|
7
|
-
|
8
|
-
if @resource.is_true? options[:overwrite]
|
9
|
-
to_path = options[:destination].tap { |s| s.slice! @resource.mount_point }
|
10
|
-
to_resource = @resource.class.new resource: to_path, req: @request, root_dir: @resource.root_dir
|
11
|
-
|
12
|
-
if to_resource.exists?
|
13
|
-
to_resource.delete_collection
|
14
|
-
to_resource_existed = true
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
copy_status = super
|
19
|
-
return copy_status if [:precondition_failed, :conflict].include? copy_status
|
20
|
-
|
21
|
-
@resource.delete_collection
|
22
|
-
|
23
|
-
if copy_status == :created && to_resource_existed
|
24
|
-
return :no_content
|
25
|
-
else
|
26
|
-
response.headers['Location'] = options[:destination] if copy_status == :created
|
27
|
-
return copy_status
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/lib/calligraphy/propfind.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module Calligraphy
|
2
|
-
class Propfind < WebDavRequest
|
3
|
-
include Calligraphy::XML::Utils
|
4
|
-
|
5
|
-
def request
|
6
|
-
xml = xml_for body: body, node: 'propfind'
|
7
|
-
return :bad_request if xml == :bad_request
|
8
|
-
|
9
|
-
properties = @resource.propfind xml
|
10
|
-
|
11
|
-
builder = xml_builder
|
12
|
-
xml_res = builder.propfind_res @resource.full_request_path, properties
|
13
|
-
|
14
|
-
set_xml_content_type
|
15
|
-
return :multi_status, xml_res
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Calligraphy
|
2
|
-
class Proppatch < WebDavRequest
|
3
|
-
include Calligraphy::XML::Utils
|
4
|
-
|
5
|
-
def request
|
6
|
-
return :locked if @resource.locked_to_user? @headers
|
7
|
-
|
8
|
-
xml = xml_for body: body, node: 'propertyupdate'
|
9
|
-
return :bad_request if xml == :bad_request
|
10
|
-
|
11
|
-
actions = @resource.proppatch xml
|
12
|
-
|
13
|
-
builder = xml_builder
|
14
|
-
xml_res = builder.proppatch_res @resource.full_request_path, actions
|
15
|
-
|
16
|
-
set_xml_content_type
|
17
|
-
return :multi_status, xml_res
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/lib/calligraphy/put.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
module Calligraphy
|
2
|
-
class WebDavRequest
|
3
|
-
attr_accessor :resource, :response
|
4
|
-
attr_reader :headers, :request
|
5
|
-
|
6
|
-
def initialize(headers:, request:, response:, resource:)
|
7
|
-
@headers = headers
|
8
|
-
@request = request
|
9
|
-
@response = response
|
10
|
-
@resource = resource
|
11
|
-
end
|
12
|
-
|
13
|
-
def request
|
14
|
-
raise NotImplemented
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def body
|
20
|
-
@resource.request_body
|
21
|
-
end
|
22
|
-
|
23
|
-
def set_xml_content_type
|
24
|
-
@response.content_type = 'application/xml'
|
25
|
-
end
|
26
|
-
|
27
|
-
def xml_builder
|
28
|
-
Calligraphy::XML::Builder.new server_protocol: @request.env['SERVER_PROTOCOL']
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
RSpec.configure do |config|
|
2
|
-
config.expect_with :rspec do |expectations|
|
3
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
4
|
-
end
|
5
|
-
|
6
|
-
config.mock_with :rspec do |mocks|
|
7
|
-
mocks.verify_partial_doubles = true
|
8
|
-
end
|
9
|
-
|
10
|
-
config.shared_context_metadata_behavior = :apply_to_host_groups
|
11
|
-
|
12
|
-
config.filter_run_when_matching :focus
|
13
|
-
|
14
|
-
# Allows RSpec to persist some state between runs in order to support
|
15
|
-
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
16
|
-
# you configure your source control system to ignore this file.
|
17
|
-
# config.example_status_persistence_file_path = "spec/examples.txt"
|
18
|
-
|
19
|
-
# Limits the available syntax to the non-monkey patched syntax that is
|
20
|
-
# recommended. For more details, see:
|
21
|
-
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
22
|
-
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
23
|
-
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
24
|
-
config.disable_monkey_patching!
|
25
|
-
|
26
|
-
config.warnings = true
|
27
|
-
|
28
|
-
# Many RSpec users commonly either run the entire suite or an individual
|
29
|
-
# file, and it's useful to allow more verbose output when running an
|
30
|
-
# individual spec file.
|
31
|
-
if config.files_to_run.one?
|
32
|
-
# Use the documentation formatter for detailed output,
|
33
|
-
# unless a formatter has already been configured
|
34
|
-
# (e.g. via a command-line flag).
|
35
|
-
config.default_formatter = "doc"
|
36
|
-
end
|
37
|
-
|
38
|
-
# Print the 10 slowest examples and example groups at the
|
39
|
-
# end of the spec run, to help surface which specs are running
|
40
|
-
# particularly slow.
|
41
|
-
config.profile_examples = 10
|
42
|
-
|
43
|
-
config.order = :random
|
44
|
-
|
45
|
-
Kernel.srand config.seed
|
46
|
-
end
|