Sha256: 6f346d71417f2f6284ca126d0e35edd7c59b9ce78ad48710169003fed1b19b4b

Contents?: true

Size: 806 Bytes

Versions: 2

Compression:

Stored size: 806 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, 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

2 entries across 2 versions & 1 rubygems

Version Path
db-sync-0.0.12 lib/tasks/db.rake
db-sync-0.0.11 lib/tasks/db.rake