Sha256: b1736e33195e9605f590b65accc120a298f6d9b98992021009ecc938b84c0cb6

Contents?: true

Size: 889 Bytes

Versions: 2

Compression:

Stored size: 889 Bytes

Contents

require "database_stalker/version"
require "database_stalker/parser"

module DatabaseStalker

  class  << self

    def start(log_file, table_log_file)
      clean_up_file(log_file) if File.exist?(log_file)
      Process.fork do
        watch_test_process
        save_stalked_tables(log_file, table_log_file)
      end
    end

    def clean_up_file(file)
      File.open(file,'w'){ |f| f = nil }
    end

    def save_stalked_tables(log_file, table_log_file)
      File.open(table_log_file, 'w') do |f|
        if File.exist?(log_file)
          parser = Parser.new(log_file)
          parser.table_names.each { |table| f.puts table }
        else
          f = nil
        end
      end
    end

    def watch_test_process
      while true
        return if Process.ppid == 1
      end
    end
  end

  private_class_method :save_stalked_tables, :watch_test_process, :clean_up_file
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
database_stalker-0.1.1 lib/database_stalker.rb
database_stalker-0.1.0 lib/database_stalker.rb