Class: GameIcons::Update
- Inherits:
-
Object
- Object
- GameIcons::Update
- Defined in:
- lib/game_icons/tasks/update.rb
Constant Summary collapse
- @@URL =
'https://game-icons.net/archives/svg/zip/ffffff/000000/game-icons.net.svg.zip'- @@TMP_ZIP =
'game-icons.net.svg.zip'
Class Method Summary collapse
Class Method Details
.clear ⇒ Object
23 24 25 26 |
# File 'lib/game_icons/tasks/update.rb', line 23 def self.clear FileUtils.rm_rf('resources/icons') FileUtils.mkdir('resources/icons') end |
.download ⇒ Object
28 29 30 31 32 |
# File 'lib/game_icons/tasks/update.rb', line 28 def self.download File.open("resources/#{@@TMP_ZIP}", 'wb+') do |save_file| URI.open(@@URL, 'rb') { |read_file| save_file.write(read_file.read) } end end |
.run ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/game_icons/tasks/update.rb', line 11 def self.run puts "Clearing..." clear puts "Downloading..." download puts "Unzipping..." unzip puts "Done." end |
.unzip ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/game_icons/tasks/update.rb', line 34 def self.unzip Zip.on_exists_proc = true #overwrite files if they already exist Dir.chdir('./resources/') do zip_file = Zip::File.new(@@TMP_ZIP) zip_file.each do |entry| fpath = "./#{entry.name}" FileUtils.mkdir_p File.dirname entry.name zip_file.extract(entry, fpath) unless File.exist?(fpath) print '.' end end end |