Class: BundleOutdatedFormatter::XMLFormatter
- Defined in:
- lib/bundle_outdated_formatter/formatter/xml_formatter.rb
Overview
Formatter for XML
Constant Summary
Constants inherited from Formatter
Formatter::GEM_REGEXP, Formatter::GROUPS_REGEXP, Formatter::INSTALLED_REGEXP, Formatter::NEWEST_REGEXP, Formatter::REQUESTED_REGEXP
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(options) ⇒ XMLFormatter
constructor
A new instance of XMLFormatter.
Methods inherited from Formatter
Constructor Details
#initialize(options) ⇒ XMLFormatter
Returns a new instance of XMLFormatter.
7 8 9 10 11 12 13 14 |
# File 'lib/bundle_outdated_formatter/formatter/xml_formatter.rb', line 7 def initialize() super() @xml = REXML::Document.new(nil, raw: :all) @root = REXML::Element.new('gems') @root.add_text('') @xml.add_element(@root) end |
Instance Method Details
#convert ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# 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 |