class EDB::Dumper
Constants
- PATTERN
Public Class Methods
new(opts = nil)
click to toggle source
# File lib/edb/dumper.rb, line 29 def initialize(opts = nil) ::EDB.opts ||= opts if opts end
Public Instance Methods
run()
click to toggle source
# File lib/edb/dumper.rb, line 33 def run create_dir ::EDB.opts[:DBMS].each do |dbms| dbms_name = dbms[0] unless EDB::DBMS.supports?(dbms_name) module_not_supported(dbms_name) next end dir_name = File.join(@dir_name, dbms_name.to_s) FileUtils.mkdir(dir_name) unless Dir.exists?(dir_name) files = EDB::DBMS.backup(dbms_name, dir_name) if ::EDB.opts[:CRYPTOGRAPHY] != nil ::EDB.opts[:CRYPTOGRAPHY].each do |cryptography| algorithm = cryptography[0] if ::EDB::Cryptography.supports?(algorithm) files.each { |file| ::EDB::Cryptography.encrypt(algorithm, file) } else module_not_supported(algorithm) end end end if ::EDB.opts[:STORAGE] != nil ::EDB.opts[:STORAGE].each do |storage| service = storage[0] if ::EDB::Storage.supports?(service) files.each { |file| ::EDB::Storage.upload(service, file) } else module_not_supported(service) end end end end end
Private Instance Methods
create_dir()
click to toggle source
# File lib/edb/dumper.rb, line 76 def create_dir @dir_name = PATTERN.call(Time.now) Dir.mkdir(@dir_name) unless Dir.exists?(@dir_name) end
module_not_supported(module_name)
click to toggle source
# File lib/edb/dumper.rb, line 81 def module_not_supported(module_name) ::EDB::Logger.log(:error, "No support for #{module_name}.") end