# frozen_string_literal: true require 'rake/clean' WARNING = <<-EOS WARNING: you may not have wget installed, you could just download the correct version of propane-examples (see EXAMPLES vendors directory) EOS SOUND = 'sound.zip'.freeze SOUND_VERSION = 'v1.3.2' # version 1.3.2 GLVIDEO = 'processing-glvideo.zip' VIDEO = 'video-2.zip' VIDEO_VERSION = '2' # version 1.0.1 EXAMPLES = '2.1'.freeze HOME_DIR = ENV['HOME'] MAC_OR_LINUX = /linux|mac|darwin/ =~ RbConfig::CONFIG['host_os'] desc 'download, and copy propane examples' task default: [:download_and_copy_samples] desc 'download and copy examples to user home' task download_and_copy_samples: [:download_examples, :copy_examples] task :download_examples file_name = MAC_OR_LINUX.nil? ? "#{EXAMPLES}.zip" : "#{EXAMPLES}.tar.gz" wget_base = 'wget https://github.com/ruby-processing/propane-examples' wget_string = [wget_base, 'archive', file_name].join('/') file file_name do begin sh wget_string rescue warn(WARNING) end end desc 'download and copy sound library to ~/.propane' task download_and_copy_sound: [:download_sound, :copy_sound] desc 'download and copy video library to ~/.propane' task download_and_copy_video: [:download_video, :copy_video] desc 'download and copy glvideo library to ~/.propane' task download_and_copy_glvideo: [:download_glvideo, :copy_glvideo] desc 'download sound library' task :download_sound do wget_base = 'wget https://github.com/processing/processing-sound' wget_string = [wget_base, 'releases/download', SOUND_VERSION, SOUND].join('/') begin sh wget_string rescue warn(WARNING) end end desc 'download glvideo library' task :download_glvideo do wget_base = 'wget https://github.com/gohai/processing-glvideo' wget_string = [wget_base, 'releases/download/latest', GLVIDEO].join('/') begin sh wget_string rescue warn(WARNING) end end desc 'download video library' task :download_video do wget_base = 'wget https://github.com/processing/processing-video' wget_string = [wget_base, 'releases/download', VIDEO_VERSION, VIDEO].join('/') begin sh wget_string rescue warn(WARNING) end end desc 'copy examples' task :copy_examples => file_name do if MAC_OR_LINUX.nil? sh "unzip #{EXAMPLES}.zip" else sh "tar xzvf #{EXAMPLES}.tar.gz" end sh "rm -r #{HOME_DIR}/propane_samples" if File.exist? "#{HOME_DIR}/propane_samples" sh "cp -r propane-examples-#{EXAMPLES} #{HOME_DIR}/propane_samples" sh "rm -r propane-examples-#{EXAMPLES}" end desc 'copy sound library' task :copy_sound => SOUND do sh "unzip #{SOUND}" sh "rm -r #{HOME_DIR}/.propane/libraries/sound" if File.exist? "#{HOME_DIR}/.propane/libraries/sound" sh "cp -r sound #{HOME_DIR}/.propane/libraries/sound" sh 'rm -r sound' end desc 'copy video library' task :copy_video => VIDEO do sh "unzip #{VIDEO}" sh "rm -r #{HOME_DIR}/.propane/libraries/video" if File.exist? "#{HOME_DIR}/.propane/libraries/video" sh "cp -r video #{HOME_DIR}/.propane/libraries/video" sh 'rm -r video' end desc 'copy glvideo library' task :copy_glvideo => GLVIDEO do sh "unzip #{GLVIDEO}" sh "rm -r #{HOME_DIR}/.propane/libraries/glvideo" if File.exist? "#{HOME_DIR}/.propane/libraries/glvideo" sh "cp -r glvideo #{HOME_DIR}/.propane/libraries/glvideo" sh 'rm -r glvideo' end