Class: Mysql2xxxx::XML
Constant Summary
Constants inherited from Writer
Writer::ICONV_FROM, Writer::ICONV_TO, Writer::MYSQL_CHARSET
Instance Attribute Summary
Attributes inherited from Writer
Instance Method Summary collapse
- #escaped_keys ⇒ Object
-
#to_file(f) ⇒ Object
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.
Methods inherited from Writer
#close, #dbh, #initialize, #keys, #last_statement, #recode_as_utf8, #result, #stream_arrays, #stream_hashes, #to_path, #to_s, #to_stdout
Constructor Details
This class inherits a constructor from Mysql2xxxx::Writer
Instance Method Details
#escaped_keys ⇒ Object
3 4 5 |
# File 'lib/mysql2xxxx/writer/xml.rb', line 3 def escaped_keys @escaped_keys ||= keys.map { |k| k.to_xs } end |
#to_file(f) ⇒ Object
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
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/mysql2xxxx/writer/xml.rb', line 10 def to_file(f) f.write %{<?xml version="1.0" encoding="utf-8" ?>} f.write %{<resultset statement="#{config.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 |