Sha256: 9f76d5421ecb77a02edc3615044bb5faa12dd279caf97c089988254da3aa44ee
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
namespace :dm do %w[auto_migrate auto_upgrade].each do |t| alert = t == 'auto_migrate' ? 'ACHTUNG! This is a DESTRUCTIVE action!' : nil ObjectSpace.each_object(Class).select do |c| c.ancestors.include?(DataMapper::Resource) end.each do |m| run = lambda do puts '', ' Running %s.%s!' % [m.name, t], '' m.send(t + '!') end desc 'Run %s.%s! %s' % [m.name, t, alert] task [t, m.name]*':' do if alert puts '', alert puts ' The table for %s model will be destroyed and recreated from ground up.' % m.name puts ' Any data will be lost, so please consider to take some backups before continuing.', '' puts ' Type Y and press enter to continue' puts ' Press enter to cancel' answer = STDIN.gets.strip (puts 'exiting...'; exit(0)) unless answer == 'Y' end run.call end task([t, m.name ,'y']*':') { run.call } end run = lambda do puts '', ' Running DataMapper.%s!' % t, '' DataMapper.send(t + '!') end desc 'Run DataMapper.%s! %s' % [t, alert] task t do if alert puts '', alert puts ' ALL tables will be destroyed and recreated from ground up.' puts ' Any data will be lost, so please consider to take some backups before continuing.', '' puts ' Type Y and press enter to continue' puts ' Press enter to cancel' answer = STDIN.gets.strip (puts 'exiting...'; exit(0)) unless answer == 'Y' end run.call end task(t + ':y'){ run.call } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
my_enginery-0.2.8 | lib/enginery/rake-tasks/data_mapper.rb |