Class: Backup

Inherits:
Object
  • Object
show all
Defined in:
lib/travis-backup.rb,
lib/backup/move_logs.rb,
lib/backup/remove_orphans.rb,
lib/backup/load_from_files.rb,
lib/backup/remove_specified.rb,
lib/backup/remove_specified/shared.rb,
lib/backup/remove_specified/remove_heavy_data.rb,
lib/backup/remove_specified/remove_with_all_dependencies.rb

Overview

main travis-backup class

Defined Under Namespace

Classes: LoadFromFiles, MoveLogs, RemoveOrphans, RemoveSpecified

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_args = {}) ⇒ Backup

Returns a new instance of Backup.



48
49
50
51
52
53
54
55
# File 'lib/travis-backup.rb', line 48

def initialize(config_args={})
  @config = Config.new(config_args)
  @db_helper = DbHelper.new(@config)

  if @config.dry_run
    @dry_run_reporter = DryRunReporter.new
  end
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



46
47
48
# File 'lib/travis-backup.rb', line 46

def config
  @config
end

Instance Method Details

#dry_run_reportObject



57
58
59
# File 'lib/travis-backup.rb', line 57

def dry_run_report
  @dry_run_reporter.report
end

#run(args = {}) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/travis-backup.rb', line 61

def run(args={})
  if @config.move_logs
    Backup::MoveLogs.new(@config, @db_helper, @dry_run_reporter).run
  elsif @config.load_from_files
    Backup::LoadFromFiles.new(@config, @dry_run_reporter).run
  elsif @config.remove_orphans
    Backup::RemoveOrphans.new(@config, @dry_run_reporter).run
  else
    Backup::RemoveSpecified.new(@config, @dry_run_reporter).run(args)
  end

  @dry_run_reporter.print_report if @config.dry_run
end