Class: S3Backup::Pg::Obfuscate

Inherits:
Object
  • Object
show all
Defined in:
lib/s3_backup/pg/obfuscate.rb

Constant Summary collapse

LINE_SEPARATOR =
"\t".freeze
END_OF_STATEMENT =
'\.'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dump_file, file_path) ⇒ Obfuscate

Returns a new instance of Obfuscate.



13
14
15
16
# File 'lib/s3_backup/pg/obfuscate.rb', line 13

def initialize(dump_file, file_path)
  @dump_file = dump_file
  @file_path = file_path
end

Instance Attribute Details

#dump_fileObject (readonly)

Returns the value of attribute dump_file.



11
12
13
# File 'lib/s3_backup/pg/obfuscate.rb', line 11

def dump_file
  @dump_file
end

#file_pathObject (readonly)

Returns the value of attribute file_path.



11
12
13
# File 'lib/s3_backup/pg/obfuscate.rb', line 11

def file_path
  @file_path
end

Instance Method Details

#obfuscate_dump!Object



18
19
20
21
22
23
24
25
# File 'lib/s3_backup/pg/obfuscate.rb', line 18

def obfuscate_dump!
  file = Zlib::GzipWriter.open(file_path)

  File.open(dump_file).each do |line|
    file.write(obfuscate_line(line.chomp) + "\n")
  end
  file.close
end