Class: Calligraphy::XML::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/calligraphy/xml/builder.rb

Constant Summary collapse

SUPPORTED_NS_TAGS =
%w(
  creationdate displayname exclusive getcontentlanguage getcontentlength
  getcontenttype getetag getlastmodified href lockdiscovery lockscope
  locktype owner write
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dav_ns: 'D', server_protocol: 'HTTP/1.1') ⇒ Builder

Returns a new instance of Builder.



11
12
13
14
15
# File 'lib/calligraphy/xml/builder.rb', line 11

def initialize(dav_ns: 'D', server_protocol: 'HTTP/1.1')
  @dav_ns = dav_ns
  @default_ns = { "xmlns:#{@dav_ns}" => 'DAV:' }
  @server_protocol = server_protocol
end

Instance Attribute Details

#dav_nsObject (readonly)

Returns the value of attribute dav_ns.



9
10
11
# File 'lib/calligraphy/xml/builder.rb', line 9

def dav_ns
  @dav_ns
end

#default_nsObject (readonly)

Returns the value of attribute default_ns.



9
10
11
# File 'lib/calligraphy/xml/builder.rb', line 9

def default_ns
  @default_ns
end

#server_protocolObject (readonly)

Returns the value of attribute server_protocol.



9
10
11
# File 'lib/calligraphy/xml/builder.rb', line 9

def server_protocol
  @server_protocol
end

Instance Method Details

#lock_res(activelock_properties) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/calligraphy/xml/builder.rb', line 17

def lock_res(activelock_properties)
  build :prop do |xml|
    xml.lockdiscovery do
      activelock_properties.each do |properties|
        activelock xml, properties
      end
    end
  end
end

#propfind_res(path, properties) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/calligraphy/xml/builder.rb', line 27

def propfind_res(path, properties)
  multistatus do |xml|
    href xml, path
    propstat xml, properties[:found], :ok
    propstat xml, properties[:not_found], :not_found
  end
end

#proppatch_res(path, actions) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/calligraphy/xml/builder.rb', line 35

def proppatch_res(path, actions)
  multistatus do |xml|
    href xml, path
    propstat xml, actions[:set]
    propstat xml, actions[:remove]
  end
end