Skip to content

Commit

Permalink
Add Rakefile
Browse files Browse the repository at this point in the history
  • Loading branch information
BGMP committed Jan 13, 2022
1 parent bcb77e6 commit 7181bc3
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# JetBrains
.idea

# Vim generated files
*~
*.swp

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Re-Volt Paintkits
*.psd
*.pdn
*.xcf
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source 'https://rubygems.org'

ruby '2.7.3'

gem 'rake', '~> 13.0', '>= 13.0.6'

13 changes: 13 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
GEM
remote: https://rubygems.org/
specs:
rake (13.0.6)

PLATFORMS
x64-mingw32

DEPENDENCIES
rake (~> 13.0, >= 13.0.6)

BUNDLED WITH
2.2.26
46 changes: 46 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
task :default => [:clean]

task :clean do
deleted_bytes = 0.0.to_f

# Remove unnecessary directories
delete_dir = %w[extra paintkit additional]
Dir[File.join('cars', '**', '*')].select { |p| File.directory? p }.each do |d|
next unless delete_dir.include? File.basename(d)

puts "Removing #{d}/"
subdirs = Dir[File.join(d, '**', '*')].reject { |p| File.directory? p }
i = 0
subdirs.each do |f|
branch = if subdirs.size == i + 1
' └──'
else
' ├──'
end

deleted_bytes += File.size(f).to_f
puts("#{branch} #{f} (#{'%.2f' % (File.size(f).to_f / 2**20)} MB) ...")
i += 1
end

FileUtils.remove_dir(d) if File.exist?(d)
end

# Remove unnecessary files
delete_ext = %w[.psd .pdn .xcf]
Dir[File.join('cars', '**', '*')].reject { |p| File.directory? p }.each do |f|
next unless delete_ext.include? File.extname(f)

deleted_bytes += File.size(f).to_f
puts("Removing #{f} (#{'%.2f' % (File.size(f).to_f / 2**20)} MB) ...")
File.delete(f) if File.exist?(f)
end

if deleted_bytes == 0.0
puts 'Nothing to remove.'
else
puts "Total removed: #{'%.2f' % (deleted_bytes / 2**20)} MB."
end

puts 'OK.'
end

0 comments on commit 7181bc3

Please sign in to comment.