Sha256: 19f23f548934284c6710b7c209bfb4ba9a6d460f92b45c262cce908294674186
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
require 'dumpdb/db' module Dumpdb::Settings class Base attr_reader :proc def initialize(proc = nil) @proc = proc.kind_of?(::Proc) ? proc : Proc.new { proc } end def value(script) script.instance_eval &@proc end end class Ssh < Base; end class DumpFile < Base; end class SourceTarget < Base def value(script) hash = super Dumpdb::Db.new(script.dump_file, hash) end end class Cmd < Base def value(script, placeholder_vals) hsub(super(script), placeholder_vals) end private def hsub(string, hash) hash.inject(string){ |new_str, (k, v)| new_str.gsub(":#{k}", v.to_s) } end end class DumpCmd < Cmd def value(script, placeholder_vals = {}) val = super(script, script.source.to_hash.merge(placeholder_vals)) if script.ssh? val = val.gsub("\\", "\\\\\\").gsub('"', '\"') val = "ssh -A #{script.ssh_opts} #{script.ssh} \"#{val}\"" end val end end class RestoreCmd < Cmd def value(script, placeholder_vals = {}) super(script, script.target.to_hash.merge(placeholder_vals)) end end class CopyDumpCmd < Cmd def value(script) if script.ssh? "sftp #{script.ssh_opts} #{script.ssh}:#{script.source.dump_file} #{script.target.dump_file}" else "cp #{script.source.dump_file} #{script.target.dump_file}" end end end class CmdList < ::Array def value(script, placeholder_vals = {}) self.map{ |cmd| cmd.value(script, placeholder_vals) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dumpdb-2.1.0 | lib/dumpdb/settings.rb |