Sha256: 2ca62105acf71366524769f5a3ef167484277001d85517fe7996d18398d13305
Contents?: true
Size: 886 Bytes
Versions: 2
Compression:
Stored size: 886 Bytes
Contents
module Mysql2xxxx class XML include ExtraOutputs attr_reader :properties def initialize(options = {}) @properties = Properties.new options end def client @client ||= Client.new properties 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) 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">} client.select_each(properties.execute) do |hsh| f.write %{<row>} hsh.each do |k, v| f.write %{<field name="#{k.to_xs}"#{' 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mysql2xxxx-0.0.2 | lib/mysql2xxxx/xml.rb |
mysql2xxxx-0.0.1 | lib/mysql2xxxx/xml.rb |