Class: CsvDb::Dump
Class Method Summary
collapse
dump_table, each_table_page, table_column_names, table_record_count, tables
Class Method Details
.after_table(io, table) ⇒ Object
55
56
57
|
# File 'lib/csv_db.rb', line 55
def self.after_table(io,table)
io.write ""
end
|
.before_table(io, table) ⇒ Object
43
44
45
|
# File 'lib/csv_db.rb', line 43
def self.before_table(io,table)
io.write "BEGIN_CSV_TABLE_DECLARATION#{table}END_CSV_TABLE_DECLARATION\n"
end
|
.dump(io) ⇒ Object
47
48
49
50
51
52
53
|
# File 'lib/csv_db.rb', line 47
def self.dump(io)
tables.each do |table|
before_table(io, table)
dump_table(io, table)
after_table(io, table)
end
end
|
.dump_table_columns(io, table) ⇒ Object
59
60
61
|
# File 'lib/csv_db.rb', line 59
def self.dump_table_columns(io, table)
io.write(table_column_names(table).to_csv)
end
|
.dump_table_records(io, table) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/csv_db.rb', line 63
def self.dump_table_records(io, table)
column_names = table_column_names(table)
each_table_page(table) do |records|
rows = SerializationHelper::Utils.unhash_records(records, column_names)
records.each do |record|
io.write(record.to_csv)
end
end
end
|