Class: PoringBackup::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/poring_backup/database.rb

Direct Known Subclasses

PoringBackup::Databases::PostgreSQL

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(setting, &block) ⇒ Database

Returns a new instance of Database.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/poring_backup/database.rb', line 9

def initialize setting, &block
  @created_at = setting.created_at
  @setting = setting
  @path ||= 'db_backups'
  @file ||= 'db_backup.psql'
  
  gen_file_dir
  gen_file_path
  gen_tmp_dir
  gen_tmp_file_path
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



7
8
9
# File 'lib/poring_backup/database.rb', line 7

def created_at
  @created_at
end

#fileObject (readonly)

Returns the value of attribute file.



5
6
7
# File 'lib/poring_backup/database.rb', line 5

def file
  @file
end

#file_dirObject (readonly)

Returns the value of attribute file_dir.



6
7
8
# File 'lib/poring_backup/database.rb', line 6

def file_dir
  @file_dir
end

#file_pathObject (readonly)

Returns the value of attribute file_path.



5
6
7
# File 'lib/poring_backup/database.rb', line 5

def file_path
  @file_path
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/poring_backup/database.rb', line 6

def path
  @path
end

#settingObject (readonly)

Returns the value of attribute setting.



4
5
6
# File 'lib/poring_backup/database.rb', line 4

def setting
  @setting
end

#tmp_dirObject (readonly)

Returns the value of attribute tmp_dir.



6
7
8
# File 'lib/poring_backup/database.rb', line 6

def tmp_dir
  @tmp_dir
end

#tmp_file_pathObject (readonly)

Returns the value of attribute tmp_file_path.



5
6
7
# File 'lib/poring_backup/database.rb', line 5

def tmp_file_path
  @tmp_file_path
end

Instance Method Details

#backupObject



21
22
23
# File 'lib/poring_backup/database.rb', line 21

def backup
  FileUtils.mkdir_p(tmp_dir)
end

#clear_tmp!Object



25
26
27
# File 'lib/poring_backup/database.rb', line 25

def clear_tmp!
  FileUtils.rm_rf(tmp_file_path)
end