class DbBlaster::S3KeyBuilder
Builds the key to be used for the uploaded S3 Object
Attributes
batch_start_time[R]
source_table_name[R]
Public Class Methods
build(source_table_name:, batch_start_time:)
click to toggle source
# File lib/db_blaster/s3_key_builder.rb, line 13 def self.build(source_table_name:, batch_start_time:) new(source_table_name, batch_start_time).build end
new(source_table_name, batch_start_time)
click to toggle source
# File lib/db_blaster/s3_key_builder.rb, line 8 def initialize(source_table_name, batch_start_time) @source_table_name = source_table_name @batch_start_time = batch_start_time end
Public Instance Methods
build()
click to toggle source
# File lib/db_blaster/s3_key_builder.rb, line 17 def build key = starting_key substitutions.each do |replace, value| key = key.gsub(replace, value) end key end
starting_key()
click to toggle source
# File lib/db_blaster/s3_key_builder.rb, line 36 def starting_key DbBlaster.configuration.s3_key.presence || Configuration::DEFAULT_S3_KEY end
substitutions()
click to toggle source
# File lib/db_blaster/s3_key_builder.rb, line 25 def substitutions date_time = DateTime.now.utc.strftime(DbBlaster::Configuration::DEFAULT_DATETIME_FORMAT) date, time = batch_start_time.split('T') { '<batch_date_time>' => batch_start_time, '<batch_date>' => date, '<batch_time>' => time, '<date_time>' => date_time, '<uuid>' => SecureRandom.uuid, '<table_name>' => source_table_name } end