Class: Brillo::Loader

Inherits:
Object
  • Object
show all
Includes:
Helpers::ExecHelper, Logger
Defined in:
lib/brillo/loader.rb

Overview

Responsible for fetching an existing SQL scrub from S3, cleaning the database, and loading the SQL.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logger

#logger, logger, logger=

Methods included from Helpers::ExecHelper

#execute, #execute!

Constructor Details

#initialize(config) ⇒ Loader

Returns a new instance of Loader.



9
10
11
12
# File 'lib/brillo/loader.rb', line 9

def initialize(config)
  raise "⚠️ DON'T LOAD IN PRODUCTION! ⚠️" if production?
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/brillo/loader.rb', line 7

def config
  @config
end

Instance Method Details

#import_sqlObject



24
25
26
27
28
29
30
31
# File 'lib/brillo/loader.rb', line 24

def import_sql
  if config.compress
    execute!("gunzip -c #{config.compressed_dump_path} | #{sql_load_command}")
  else
    execute!("cat #{config.dump_path} | #{sql_load_command}")
  end
  logger.info "Import complete!"
end

#load!Object



14
15
16
17
18
# File 'lib/brillo/loader.rb', line 14

def load!
  config.transferrer.download
  recreate_db
  import_sql
end

#recreate_dbObject



20
21
22
# File 'lib/brillo/loader.rb', line 20

def recreate_db
  config.adapter.recreate_db
end