Sha256: 72ee7657096a225867dbef38f6c50ff48d1af6d7da02e7d5ec54c1b2675c325e
Contents?: true
Size: 867 Bytes
Versions: 3
Compression:
Stored size: 867 Bytes
Contents
module Mysql2xxxx class XML < Writer def escaped_keys @escaped_keys ||= keys.map { |k| k.to_xs } end # sabshere 2/10/11 dkastner pointed out that this doesn't include metadata like later versions of mysql do # 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) f.write %{<?xml version="1.0" encoding="utf-8" ?>} f.write %{<resultset statement="#{properties.execute.to_xs}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">} stream_arrays do |ary| f.write %{<row>} ary.each_with_index do |v, i| f.write %{<field name="#{escaped_keys[i]}"#{' xsi:nil="true"' if v.nil?}>#{v.to_s.to_xs}</field>} end f.write %{</row>} end f.write %{</resultset>} nil end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mysql2xxxx-0.1.1 | lib/mysql2xxxx/writer/xml.rb |
mysql2xxxx-0.1.0 | lib/mysql2xxxx/writer/xml.rb |
mysql2xxxx-0.0.4 | lib/mysql2xxxx/writer/xml.rb |