class Ruian::FilesUpdater

Constants

URL

Public Instance Methods

csv_directory() click to toggle source
# File lib/ruian/files_updater.rb, line 46
def csv_directory
  Ruian.root.join('fixtures', 'CSV')
end
download() click to toggle source
# File lib/ruian/files_updater.rb, line 16
def download
  File.open(filepath, "wb") do |file|
    open(URL) do |url|
      file.write(url.read)
    end
  end
end
filepath() click to toggle source
# File lib/ruian/files_updater.rb, line 50
def filepath
  Ruian.root.join('fixtures', 'csv.zip')
end
fixtures_directory() click to toggle source
# File lib/ruian/files_updater.rb, line 42
def fixtures_directory
  Ruian.root.join('fixtures')
end
remove_old() click to toggle source
# File lib/ruian/files_updater.rb, line 38
def remove_old
  FileUtils.rm_rf(csv_directory)
end
remove_temp() click to toggle source
# File lib/ruian/files_updater.rb, line 34
def remove_temp
  FileUtils.rm(filepath)
end
unpack() click to toggle source
# File lib/ruian/files_updater.rb, line 24
def unpack
  Zip::File.open(filepath) do |zip_file|
    zip_file.each do |entry|
      fullpath = fixtures_directory.join(entry.name)
      FileUtils.mkdir_p(File.dirname(fullpath))
      entry.extract(fullpath)
    end
  end
end
update!() click to toggle source
# File lib/ruian/files_updater.rb, line 9
def update!
  download
  remove_old
  unpack
  remove_temp
end