Class: Xcodeproj::XCScheme::XMLFormatter

Inherits:
REXML::Formatters::Pretty
  • Object
show all
Defined in:
lib/xcodeproj/scheme.rb

Overview

XML formatter which closely mimics the output generated by Xcode.

Serialization collapse

Instance Method Details

#write_element(node, output) ⇒ Object



346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/xcodeproj/scheme.rb', line 346

def write_element(node, output)
  @indentation = 3
  output << ' ' * @level
  output << "<#{node.expanded_name}"

  @level += @indentation
  node.context = node.parent.context # HACK: to ensure strings are properly quoted
  node.attributes.each_attribute do |attr|
    output << "\n"
    output << ' ' * @level
    output << attr.to_string.sub(/=/, ' = ')
  end unless node.attributes.empty?

  output << '>'

  output << "\n"
  node.children.each do |child|
    next if child.is_a?(REXML::Text) && child.to_s.strip.length == 0
    write(child, output)
    output << "\n"
  end
  @level -= @indentation
  output << ' ' * @level
  output << "</#{node.expanded_name}>"
end