Class: Dabcup::Database
- Inherits:
-
Object
- Object
- Dabcup::Database
- Defined in:
- lib/dabcup/database.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#main_storage ⇒ Object
readonly
Returns the value of attribute main_storage.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#spare_storage ⇒ Object
readonly
Returns the value of attribute spare_storage.
Instance Method Summary collapse
- #dump(dump_path) ⇒ Object
-
#initialize(name, config) ⇒ Database
constructor
A new instance of Database.
- #retention ⇒ Object
- #system(command, interpolation = {}) ⇒ Object
- #tunnel ⇒ Object
- #via_ssh? ⇒ Boolean
Constructor Details
#initialize(name, config) ⇒ Database
Returns a new instance of Database.
11 12 13 14 15 16 17 |
# File 'lib/dabcup/database.rb', line 11 def initialize(name, config) @name = name @config = config @main_storage = Dabcup::Storage.new(config['storage']) @spare_storage = Dabcup::Storage.new(config['spare_storage']) if config['spare_storage'] extend(Tunnel) if tunnel end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/dabcup/database.rb', line 7 def config @config end |
#main_storage ⇒ Object (readonly)
Returns the value of attribute main_storage.
8 9 10 |
# File 'lib/dabcup/database.rb', line 8 def main_storage @main_storage end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/dabcup/database.rb', line 6 def name @name end |
#spare_storage ⇒ Object (readonly)
Returns the value of attribute spare_storage.
9 10 11 |
# File 'lib/dabcup/database.rb', line 9 def spare_storage @spare_storage end |
Instance Method Details
#dump(dump_path) ⇒ Object
27 28 29 |
# File 'lib/dabcup/database.rb', line 27 def dump(dump_path) system(config['dump'], :dump_path => File.(dump_path)) end |
#retention ⇒ Object
39 40 41 |
# File 'lib/dabcup/database.rb', line 39 def retention config['retention'] end |
#system(command, interpolation = {}) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/dabcup/database.rb', line 31 def system(command, interpolation = {}) command = command % interpolation # TODO Found a nice way to get the exit status. stdin, stdout, stderr = Open3.popen3(command + "; echo $?") raise Dabcup::Error.new("Failed to execute '#{command}', stderr is '#{stderr.read}'.") if not stderr.eof? [stdin, stdout, stderr] end |
#tunnel ⇒ Object
19 20 21 |
# File 'lib/dabcup/database.rb', line 19 def tunnel @tunnel ||= Addressable::URI.parse(config['tunnel']) if config['tunnel'] end |
#via_ssh? ⇒ Boolean
23 24 25 |
# File 'lib/dabcup/database.rb', line 23 def via_ssh? tunnel != nil end |