Sha256: 5bf51b7714a63859c28a6fa426cf0fcebef0b631f542b1f5bf83c167fac12170

Contents?: true

Size: 750 Bytes

Versions: 1

Compression:

Stored size: 750 Bytes

Contents

namespace :db do
  namespace :sync do
    desc 'Download data from the databse into files.'
    task down: :environment do
      synchronizer = Db::Sync.new
      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_up_and_print(synchronizer, 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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
db-sync-0.0.7 lib/tasks/db.rake