module Kmc::Refresher
Public Class Methods
update_packages!()
click to toggle source
Fetch packages from online and delete the old packages, if any.
# File lib/kmc/refresher.rb, line 5 def update_packages! new_packages_dir = File.join(fetch_packages, 'packages-master', 'packages') kmc_packages_path = Kmc::Configuration.packages_path output_path = File.join(kmc_packages_path, '..') remove_old_packages(kmc_packages_path) FileUtils.cp_r(new_packages_dir, output_path) end
Private Class Methods
fetch_packages()
click to toggle source
# File lib/kmc/refresher.rb, line 18 def fetch_packages zipped_packages = HTTParty.get(Kmc.config.packages_url) tmp_zip = PackageDownloads.download_to_tempdir( 'downloaded_packages.zip', zipped_packages) output_path = Pathname.new(tmp_zip.path).parent.to_s PackageDownloads.unzip_file(tmp_zip.path, output_path) output_path end
remove_old_packages(kmc_packages_path)
click to toggle source
# File lib/kmc/refresher.rb, line 29 def remove_old_packages(kmc_packages_path) Dir["#{kmc_packages_path}/*.rb"].each do |file| File.delete(file) end end