class BundleOutdatedFormatter::XMLFormatter
Formatter
for XML
Public Class Methods
new(options)
click to toggle source
Calls superclass method
BundleOutdatedFormatter::Formatter::new
# File lib/bundle_outdated_formatter/formatter/xml_formatter.rb, line 7 def initialize(options) super(options) @xml = REXML::Document.new(nil, raw: :all) @root = REXML::Element.new('gems') @root.add_text('') @xml.add_element(@root) end
Public Instance Methods
convert()
click to toggle source
# File lib/bundle_outdated_formatter/formatter/xml_formatter.rb, line 16 def convert @outdated_gems.each do |gem| add_outdated(gem) end io = StringIO.new io.write('<?xml version="1.0" encoding="UTF-8"?>') io.write("\n") if @pretty xml_formatter.write(@xml, io) io.string.chomp end
Private Instance Methods
add_outdated(gem)
click to toggle source
# File lib/bundle_outdated_formatter/formatter/xml_formatter.rb, line 30 def add_outdated(gem) elements = @root.add_element(REXML::Element.new('outdated')) @columns.each do |column| escaped_text = REXML::Text.new(gem[column], false, nil, false) elements.add_element(column).add_text(escaped_text) end end