Module: Snapshots
- Defined in:
- lib/snapshots.rb,
lib/snapshots/app.rb,
lib/snapshots/database_dumper.rb,
lib/snapshots/database_loader.rb
Defined Under Namespace
Classes: App, DatabaseDumper, DatabaseLoader, TableLoader
Class Method Summary
collapse
Class Method Details
.dump(snapshot_path = "db/snapshots/snapshot_#{Time.now.to_i}.rb", connection = ActiveRecord::Base.connection) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/snapshots.rb', line 36
def dump(snapshot_path="db/snapshots/snapshot_#{Time.now.to_i}.rb", connection=ActiveRecord::Base.connection)
FileUtils.mkdir_p(File.dirname(snapshot_path))
File.open(snapshot_path, 'w+') do |f|
Snapshots::DatabaseDumper.dump(connection, f)
end
snapshot_path
end
|
.find(path = "db/snapshots/snapshot_*.rb") ⇒ Object
14
15
16
|
# File 'lib/snapshots.rb', line 14
def find(path="db/snapshots/snapshot_*.rb")
Dir.glob(path)
end
|
.load(version_or_path) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/snapshots.rb', line 18
def load(version_or_path)
unless String === version_or_path
raise ArgumentError, "argument must be a String"
end
path = if version_or_path =~ /\.rb$/
version_or_path
else
"db/snapshots/snapshot_#{version_or_path}.rb"
end
unless File.exists?(path)
raise LoadError, "missing snapshot: #{path}"
end
Kernel.load(path)
end
|