Class: DumpCleaner::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/dump_cleaner/processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Processor

Returns a new instance of Processor.



7
8
9
# File 'lib/dump_cleaner/processor.rb', line 7

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/dump_cleaner/processor.rb', line 5

def options
  @options
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dump_cleaner/processor.rb', line 11

def run
  start_time = Time.now

  cleaner_class = case config.dump_format
                  when "mysql_shell"
                    Cleaners::MysqlShellDumpCleaner
                  else
                    raise Config::ConfigurationError, "Unsupported dump format #{config.dump_format}"
                  end

  Log.debug { "Starting cleanup with #{cleaner_class}" }
  cleaner = cleaner_class.new(config:, options:)
  cleaner.pre_cleanup
  cleaner.clean
  cleaner.post_cleanup

  diff = Time.now - start_time
  Log.info { "Finished in #{diff.div(60)}m #{(diff % 60).to_i}s." }
end