Module: Dumpdb
- Defined in:
- lib/dumpdb.rb,
lib/dumpdb/db.rb,
lib/dumpdb/runner.rb,
lib/dumpdb/version.rb
Defined Under Namespace
Modules: Settings, SettingsDslMethods, SettingsMethods Classes: BadDatabaseName, Db, Runner
Constant Summary collapse
- VERSION =
"1.1.0"
Class Method Summary collapse
Instance Method Summary collapse
- #after_cmd_run(*args) ⇒ Object
- #after_copy_dump(*args) ⇒ Object
- #after_dump(*args) ⇒ Object
- #after_restore(*args) ⇒ Object
- #after_run(*args) ⇒ Object
- #after_setup(*args) ⇒ Object
- #after_teardown(*args) ⇒ Object
- #before_cmd_run(*args) ⇒ Object
- #before_copy_dump(*args) ⇒ Object
- #before_dump(*args) ⇒ Object
- #before_restore(*args) ⇒ Object
-
#before_run(*args) ⇒ Object
Callbacks.
- #before_setup(*args) ⇒ Object
- #before_teardown(*args) ⇒ Object
- #db(database_name, other_vals = nil) ⇒ Object
- #dump_cmd(&block) ⇒ Object
- #restore_cmd(&block) ⇒ Object
- #run(cmd_runner = nil) ⇒ Object
- #ssh? ⇒ Boolean
- #ssh_opts ⇒ Object
Class Method Details
.included(receiver) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/dumpdb.rb', line 11 def self.included(receiver) receiver.class_eval do include NsOptions :settings do option 'ssh', Settings::Ssh, :default => '' option 'databases', Settings::Databases, :default => {} option 'dump_file', Settings::DumpFile, :default => '' option 'source', Settings::SourceTarget, :default => {} option 'target', Settings::SourceTarget, :default => {} option 'dump_cmds', Settings::CmdList, :default => [] option 'restore_cmds', Settings::CmdList, :default => [] end extend SettingsDslMethods include SettingsMethods def self.inherited(subclass) subclass.settings.apply(self.settings.to_hash) end end end |
Instance Method Details
#after_cmd_run(*args) ⇒ Object
100 |
# File 'lib/dumpdb.rb', line 100 def after_cmd_run(*args); end |
#after_copy_dump(*args) ⇒ Object
94 |
# File 'lib/dumpdb.rb', line 94 def after_copy_dump(*args); end |
#after_dump(*args) ⇒ Object
92 |
# File 'lib/dumpdb.rb', line 92 def after_dump(*args); end |
#after_restore(*args) ⇒ Object
96 |
# File 'lib/dumpdb.rb', line 96 def after_restore(*args); end |
#after_run(*args) ⇒ Object
88 |
# File 'lib/dumpdb.rb', line 88 def after_run(*args); end |
#after_setup(*args) ⇒ Object
90 |
# File 'lib/dumpdb.rb', line 90 def after_setup(*args); end |
#after_teardown(*args) ⇒ Object
98 |
# File 'lib/dumpdb.rb', line 98 def after_teardown(*args); end |
#before_cmd_run(*args) ⇒ Object
99 |
# File 'lib/dumpdb.rb', line 99 def before_cmd_run(*args); end |
#before_copy_dump(*args) ⇒ Object
93 |
# File 'lib/dumpdb.rb', line 93 def before_copy_dump(*args); end |
#before_dump(*args) ⇒ Object
91 |
# File 'lib/dumpdb.rb', line 91 def before_dump(*args); end |
#before_restore(*args) ⇒ Object
95 |
# File 'lib/dumpdb.rb', line 95 def before_restore(*args); end |
#before_run(*args) ⇒ Object
Callbacks
87 |
# File 'lib/dumpdb.rb', line 87 def before_run(*args); end |
#before_setup(*args) ⇒ Object
89 |
# File 'lib/dumpdb.rb', line 89 def before_setup(*args); end |
#before_teardown(*args) ⇒ Object
97 |
# File 'lib/dumpdb.rb', line 97 def before_teardown(*args); end |
#db(database_name, other_vals = nil) ⇒ Object
63 64 65 66 67 68 |
# File 'lib/dumpdb.rb', line 63 def db(database_name, other_vals=nil) if (db_vals = self.databases[database_name]).nil? raise BadDatabaseName, "no database named `#{database_name}'." end Db.new(self.dump_file, db_vals.merge(other_vals || {})) end |
#dump_cmd(&block) ⇒ Object
70 |
# File 'lib/dumpdb.rb', line 70 def dump_cmd(&block); Settings::DumpCmd.new(block).value(self); end |
#restore_cmd(&block) ⇒ Object
71 |
# File 'lib/dumpdb.rb', line 71 def restore_cmd(&block) Settings::RestoreCmd.new(block).value(self); end |
#run(cmd_runner = nil) ⇒ Object
81 82 83 |
# File 'lib/dumpdb.rb', line 81 def run(cmd_runner=nil) Runner.new(self, :cmd_runner => cmd_runner).run end |
#ssh? ⇒ Boolean
73 74 75 |
# File 'lib/dumpdb.rb', line 73 def ssh? self.ssh && !self.ssh.empty? end |
#ssh_opts ⇒ Object
77 78 79 |
# File 'lib/dumpdb.rb', line 77 def ssh_opts "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=10" end |