Class: Dbcp::DatabaseSnapshotFile
- Inherits:
-
Object
- Object
- Dbcp::DatabaseSnapshotFile
- Defined in:
- lib/dbcp/database_snapshot_file.rb
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(environment) ⇒ DatabaseSnapshotFile
constructor
A new instance of DatabaseSnapshotFile.
- #transfer_to(destination_environment) ⇒ DatabaseSnapshotFile
Constructor Details
#initialize(environment) ⇒ DatabaseSnapshotFile
Returns a new instance of DatabaseSnapshotFile.
6 7 8 9 |
# File 'lib/dbcp/database_snapshot_file.rb', line 6 def initialize(environment) @environment = environment @path = "/tmp/dbcp_#{Time.now.to_f}" end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
4 5 6 |
# File 'lib/dbcp/database_snapshot_file.rb', line 4 def environment @environment end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/dbcp/database_snapshot_file.rb', line 3 def path @path end |
Instance Method Details
#delete ⇒ Object
36 37 38 |
# File 'lib/dbcp/database_snapshot_file.rb', line 36 def delete environment.execution_host.execute %W(rm #{path}).shelljoin end |
#transfer_to(destination_environment) ⇒ DatabaseSnapshotFile
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/dbcp/database_snapshot_file.rb', line 12 def transfer_to(destination_environment) source_host = environment.execution_host destination_host = destination_environment.execution_host return self if source_host.local? && destination_host.local? return self if source_host == destination_host destination_snapshot_file = DatabaseSnapshotFile.new(destination_environment) if source_host.local? && destination_host.remote? destination_host.upload path, destination_snapshot_file.path elsif source_host.remote? && destination_host.local? source_host.download path, destination_snapshot_file.path else # both remote source_host.download path, path destination_host.upload path, destination_snapshot_file.path end destination_snapshot_file end |