module Mysql2xxxx class XML include ExtraOutputs attr_reader :properties def initialize(options = {}) @properties = Properties.new options end # this matches the xml generated by "mysql --xml" # i tried to use builder, but the String#to_xs nonsense got in the way def to_file(f) @client = ::Mysql2::Client.new properties.database_config f.write %{} f.write %{} @client.query(properties.execute).each do |hsh| f.write %{} hsh.each do |k, v| f.write %{#{v.to_s.to_xs}} end f.write %{} end f.write %{} nil ensure @client.try :close end end end