Sha256: 9142566146889e49dda100517841ed84be8f9c802d532f36b66338ae57de19eb

Contents?: true

Size: 816 Bytes

Versions: 3

Compression:

Stored size: 816 Bytes

Contents

namespace :db do
  namespace :sync do
    desc 'Download data from the databse into files.'
    task down: :environment do
      synchronizer = Db::Sync.new(sync_dir)
      synchronizer.sync_down
    end

    desc 'Upload data from the files into the database.'
    task up: :environment do
      commit = ENV['commit'].present? ? ENV['commit'] == 'true' : nil
      synchronizer = Db::Sync.new(sync_dir)
      sync_up_and_print(synchronizer, sync_dir, commit)
      if commit.nil? && synchronizer.log.present?
        print "Commit Changes? [y/n]\n"
        sync_up_and_print(synchronizer, true) if STDIN.gets.chomp == 'y'
      end
    end
  end
end

def self.sync_up_and_print(synchronizer, commit)
  synchronizer.sync_up(commit)
  print synchronizer.log.join("\n") + "\n"
end

def self.sync_dir
  ENV['dir']
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
db-sync-0.0.10 lib/tasks/db.rake
db-sync-0.0.9 lib/tasks/db.rake
db-sync-0.0.8 lib/tasks/db.rake