lib/db/sync.rb in db-sync-0.0.8 vs lib/db/sync.rb in db-sync-0.0.9
- old
+ new
@@ -10,11 +10,11 @@
include ActiveSupport::Configurable
attr_accessor :sync_dir
def initialize(sync_dir = nil)
- self.sync_dir = sync_dir || 'data'
+ self.sync_dir = File.join((Rails.root || '.'), 'db', (sync_dir || 'data'))
end
def log
@log ||= []
end
@@ -94,10 +94,11 @@
end
end
def sync_down
# TODO: change to row by row saving
+ Dir.mkdir(sync_dir)
working_tables.each do |table|
File.open(table_filename(table), 'w') do |f|
current_records = table_model_records(table)
f << current_records.to_yaml
end
@@ -120,10 +121,10 @@
end
end
def table_filename(table)
# TODO: change data with custom dir
- File.join(Rails.root || '.', 'db', sync_dir, "#{table}.yml")
+ File.join(sync_dir, "#{table}.yml")
end
def configure
yield(config)
end