class LolDba::Writer

Public Class Methods

new(file_name) click to toggle source
# File lib/lol_dba/sql_migrations/writer.rb, line 3
def initialize(file_name)
  @file_name = file_name
end
reset_output_dir() click to toggle source
# File lib/lol_dba/sql_migrations/writer.rb, line 7
def self.reset_output_dir
  FileUtils.rm_rf output_dir
  Dir.mkdir output_dir
end

Private Class Methods

output_dir() click to toggle source
# File lib/lol_dba/sql_migrations/writer.rb, line 22
def self.output_dir
  File.join(Rails.root, 'db', 'migrate_sql')
end

Public Instance Methods

write(string) click to toggle source
# File lib/lol_dba/sql_migrations/writer.rb, line 12
def write(string)
  return unless @file_name.present?
  File.open(path, 'a') do |file|
    file << string << ";\n"
    file.close
  end
end

Private Instance Methods

path() click to toggle source
# File lib/lol_dba/sql_migrations/writer.rb, line 28
def path
  File.join(self.class.output_dir, @file_name)
end