Module: Protocol::Caldav::XmlBuilder

Defined in:
lib/protocol/caldav/xml_builder.rb

Constant Summary collapse

NAMESPACES =
{
  "xmlns:d"  => "DAV:",
  "xmlns:c"  => "urn:ietf:params:xml:ns:caldav",
  "xmlns:cr" => "urn:ietf:params:xml:ns:carddav",
  "xmlns:cs" => "http://calendarserver.org/ns/",
  "xmlns:x"  => "http://apple.com/ns/ical/"
}.freeze

Class Method Summary collapse

Class Method Details

.multistatusObject



18
19
20
21
22
23
24
25
# File 'lib/protocol/caldav/xml_builder.rb', line 18

def multistatus
  xml = Builder::XmlMarkup.new
  xml.instruct! :xml, version: "1.0", encoding: "UTF-8"
  xml.tag!("d:multistatus", NAMESPACES) do
    yield xml
  end
  xml.target!
end

.propstat_ok(xml) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/protocol/caldav/xml_builder.rb', line 34

def propstat_ok(xml)
  xml.tag!("d:propstat") do
    xml.tag!("d:prop") do
      yield xml
    end
    xml.tag!("d:status", "HTTP/1.1 200 OK")
  end
end

.response(xml, href:) ⇒ Object



27
28
29
30
31
32
# File 'lib/protocol/caldav/xml_builder.rb', line 27

def response(xml, href:)
  xml.tag!("d:response") do
    xml.tag!("d:href", href)
    yield xml if block_given?
  end
end