Class: Dumper::Database::Base

Inherits:
Object
  • Object
show all
Includes:
Utility::ObjectFinder
Defined in:
lib/dumper/database/base.rb

Direct Known Subclasses

MongoDB, MySQL, PostgreSQL, Redis

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utility::ObjectFinder

#find_instance_in_object_space

Instance Attribute Details

#configObject

Returns the value of attribute config.



6
7
8
# File 'lib/dumper/database/base.rb', line 6

def config
  @config
end

#filenameObject

Returns the value of attribute filename.



6
7
8
# File 'lib/dumper/database/base.rb', line 6

def filename
  @filename
end

#tmpdirObject

Returns the value of attribute tmpdir.



6
7
8
# File 'lib/dumper/database/base.rb', line 6

def tmpdir
  @tmpdir
end

Instance Method Details

#dump_pathObject



12
13
14
# File 'lib/dumper/database/base.rb', line 12

def dump_path
  "#{tmpdir}/#{filename}"
end

#dump_tool_pathObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/dumper/database/base.rb', line 16

def dump_tool_path
  tool = self.class::DUMP_TOOL
  path = `which #{tool}`.chomp
  if path.empty?
    # /usr/local/mysql/bin = OSX binary, /usr/local/bin = homebrew, /usr/bin = linux
    dir = [ '/usr/local/mysql/bin', '/usr/local/bin', '/usr/bin' ].find do |i|
      File.exist?("#{i}/#{tool}")
    end
    path = "#{dir}/#{tool}" if dir
  end
  path
end

#file_extObject



8
9
10
# File 'lib/dumper/database/base.rb', line 8

def file_ext
  self.class::FILE_EXT
end

#finalizeObject



29
30
31
# File 'lib/dumper/database/base.rb', line 29

def finalize
  FileUtils.remove_entry_secure(tmpdir) if tmpdir and File.exist?(tmpdir)
end