Module: EveApp::SDE::Downloader

Included in:
DataImporter
Defined in:
lib/eve_app/sde/downloader.rb

Instance Method Summary collapse

Instance Method Details

#downloadObject



4
5
6
7
8
9
10
# File 'lib/eve_app/sde/downloader.rb', line 4

def download
  within SDE.config.tmp_path do
    execute :wget, '-q', download_uri + '{,.md5}'
    verify!
    execute :bunzip2, SDE.config.archive
  end
end

#restoreObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/eve_app/sde/downloader.rb', line 12

def restore
  table_list.each do |table_name,normalized_name|
    sql %Q(DROP TABLE IF EXISTS "#{table_name}")
    sql %Q(DROP TABLE IF EXISTS "#{normalized_name}")
  end

  options = ['-x -O']
  options << "-h #{db_config[:host]}" if db_config[:host]
  options << "-p #{db_config[:port]}" if db_config[:port]
  options << "-U #{db_config[:username]}" if db_config[:username]
  options << "-d #{db_config[:database]}"
  options += table_list.keys.map { |name| "-t #{name}" }
  options << local_archive.gsub('.bz2', '')

  execute :pg_restore, *options
end