Class: Snapshots::App
- Inherits:
-
Thor
- Object
- Thor
- Snapshots::App
- Defined in:
- lib/snapshots/app.rb
Instance Method Summary collapse
Instance Method Details
#dump ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/snapshots/app.rb', line 29 def dump goto_rails do load_environment! begin Snapshots.dump puts "Snapshot was successfully created." rescue => e puts "An error occured while creating snapshot." puts "#{e.class}: #{e.}" puts e.backtrace end end end |
#install ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/snapshots/app.rb', line 61 def install goto_rails do File.open('lib/tasks/snapshots.rake', 'w+') do |f| f.write <<-EOR begin require 'rubygems' require 'snapshots/tasks' rescue LoadError puts "Please install snapshots: [sudo] gem install snapshots" end EOR end puts "Rake tasks are successfully installed." end end |
#list ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/snapshots/app.rb', line 16 def list goto_rails do Snapshots.find.each do |snapshot| snapshot =~ /snapshot_(\d+)\.rb$/ = Time.at($1.to_i) puts "#{$1} @ #{} : #{snapshot}" end end end |
#load(version) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/snapshots/app.rb', line 45 def load(version) goto_rails do load_environment! begin Snapshots.load(version) puts "Snapshot #{version} was successfully restored." rescue => e puts "An error occured while restoring snapshot #{version}." puts "#{e.class}: #{e.}" puts e.backtrace end end end |