lib/metaforce/manifest.rb
def to_xml
      xml_builder = Nokogiri::XML::Builder.new do |xml|
        xml.Package('xmlns' => 'http://soap.sforce.com/2006/04/metadata') {
          self.each do |key, members|
            xml.types {
              members.each do |member|
                xml.members member
              end
              xml.name key.to_s.camelize
            }
          end
          xml.version Metaforce.configuration.api_version
        }
      end
      xml_builder.to_xml
    end
def to_xml
      xml_builder = Nokogiri::XML::Builder.new do |xml|
        xml.Package('xmlns' => 'http://soap.sforce.com/2006/04/metadata') {
          self.each do |key, members|
            xml.types {
              members.each do |member|
                xml.members member
              end
              xml.name key.to_s.camelize
            }
          end
          xml.version Metaforce.configuration.api_version
        }
      end
      xml_builder.to_xml
    end
Public: Initializes a new instance of a manifest (package.xml) file.

 It can either take a hash:
   {
     :apex_class => [
       "TestController",
       "TestClass"
     ],
     :apex_component => [
       "SiteLogin"
     ]
   }

 Or an xml string containing the contents of a packge.xml file:
  <?xml version="1.0"?>
  <Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
      <members>TestClass</members>
      <members>AnotherClass</members>
      <name>ApexClass</name>
    </types>
    <types>
      <members>Component</members>
      <name>ApexComponent</name>
    </types>
    <types>
      <members>Assets</members>
      <name>StaticResource</name>
    </types>
    <version>23.0</version>
  </Package>

 Public: Returns a string containing a package.xml file

  <?xml version="1.0"?>
  <Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
      <members>TestClass</members>
      <members>AnotherClass</members>
      <name>ApexClass</name>
    </types>
    <types>
      <members>Component</members>
      <name>ApexComponent</name>
    </types>
    <types>
      <members>Assets</members>
      <name>StaticResource</name>
    </types>
    <version>23.0</version>
  </Package>