Permalink
Browse files

regex instead of string comparison when formatting yaml for dump

  • Loading branch information...
seanbehan committed Jul 2, 2011
1 parent 66414be commit 14ebdb79805d71501fbd742e52ad7887765138dc
Showing with 5 additions and 5 deletions.
  1. +5 −5 lib/yaml_db.rb
View
@@ -8,7 +8,7 @@
module YamlDb
module Helper
def self.loader
- YamlDb::Load
+ YamlDb::Load
end
def self.dumper
@@ -24,15 +24,15 @@ def self.extension
module Utils
def self.chunk_records(records)
yaml = [ records ].to_yaml
- yaml.sub!("---\n", "")
+ yaml.sub!(/---\s\n|---\n/, '')
yaml.sub!('- - -', ' - -')
yaml
end
end
class Dump < SerializationHelper::Dump
-
+
def self.dump_table_columns(io, table)
io.write("\n")
io.write({ table => { 'columns' => table_column_names(table) } }.to_yaml)
@@ -56,7 +56,7 @@ def self.table_record_header(io)
end
class Load < SerializationHelper::Load
- def self.load_documents(io, truncate = true)
+ def self.load_documents(io, truncate = true)
YAML.load_documents(io) do |ydoc|
ydoc.keys.each do |table_name|
next if ydoc[table_name].nil?
@@ -68,7 +68,7 @@ def self.load_documents(io, truncate = true)
class Railtie < Rails::Railtie
rake_tasks do
- load File.expand_path('../tasks/yaml_db_tasks.rake',
+ load File.expand_path('../tasks/yaml_db_tasks.rake',
__FILE__)
end
end

0 comments on commit 14ebdb7

Please sign in to comment.