Class: Dabcup::Operation::Get

Inherits:
Base
  • Object
show all
Defined in:
lib/dabcup/operation/get.rb

Instance Attribute Summary

Attributes inherited from Base

#database

Instance Method Summary collapse

Methods inherited from Base

#best_dumps_path, #best_local_dumps_path, #check, #initialize, #remove_local_dump?, #same_ssh_as_database?, #terminate

Constructor Details

This class inherits a constructor from Dabcup::Operation::Base

Instance Method Details

#run(args) ⇒ Object

Raises:



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/dabcup/operation/get.rb', line 4

def run(args)
  raise Dabcup::Error.new("Not enough arguments. Try 'dabcup help get'.") if args.size < 3
  dump_name = args[2]
  local_path = args[3] || dump_name
  local_path = File.join(local_path, dump_name) if File.directory?(local_path)
  local_path = File.expand_path(local_path)
  if main_storage.exists?(dump_name)
    main_storage.get(dump_name, local_path)
  elsif spare_storage.exists?(dump_name)
    spare_storage.get(dump_name, local_path)
  else
    raise Dabcup::Error.new("Dump '#{dump_name}' not found.")
  end
end