Skip to content
This repository
Browse code

Provide option to enable pretty xml output

  • Loading branch information...
commit 217557807cfc935a6c06f573e20706f0f8b68158 1 parent 3aff3a2
Chris Roberts authored March 18, 2012
5  bin/dav4rack
@@ -27,7 +27,8 @@ opts = GetoptLong.new(
27 27
   ['--version', '-v', GetoptLong::NO_ARGUMENT],
28 28
   ['--root', '-r', GetoptLong::REQUIRED_ARGUMENT],
29 29
   ['--log', '-l', GetoptLong::OPTIONAL_ARGUMENT],
30  
-  ['--verbosity', '-V', GetoptLong::REQUIRED_ARGUMENT]
  30
+  ['--verbosity', '-V', GetoptLong::REQUIRED_ARGUMENT],
  31
+  ['--pretty-xml', '-P', GetoptLong::REQUIRED_ARGUMENT]
31 32
 )
32 33
 
33 34
 credentials = {}
@@ -47,6 +48,8 @@ opts.each do |opt,arg|
47 48
       puts "ERROR: Path provided is not a valid directory (#{arg})"
48 49
       exit(-1)
49 50
     end
  51
+  when '--pretty-xml'
  52
+    credentials[:pretty_xml] = true
50 53
   when '--version'
51 54
     print_version_info
52 55
     exit(0)
10  lib/dav4rack/controller.rb
@@ -412,8 +412,14 @@ def render_xml(root_type)
412 412
           yield xml
413 413
         end
414 414
       end
415  
-      
416  
-      response.body = doc.to_xml(:save_with => Nokogiri::XML::Node::SaveOptions::AS_XML)
  415
+     
  416
+      if(@options[:pretty_xml])
  417
+        response.body = doc.to_xml
  418
+      else
  419
+        response.body = doc.to_xml(
  420
+          :save_with => Nokogiri::XML::Node::SaveOptions::AS_XML
  421
+        )
  422
+      end
417 423
       response["Content-Type"] = 'text/xml; charset="utf-8"'
418 424
       response["Content-Length"] = response.body.size.to_s
419 425
     end

0 notes on commit 2175578

Please sign in to comment.
Something went wrong with that request. Please try again.