Sha256: fd5d8a940b74156b86a341f1561ff30700702005a0594e4fd2c1c1f85e35c427
Contents?: true
Size: 536 Bytes
Versions: 5
Compression:
Stored size: 536 Bytes
Contents
# frozen_string_literal: true class File # Clean out all the empty dirs def self.clean(file_name) return unless File.directory? file_name # clean all subdirs subdirs = Dir.entries(file_name).select { |p| File.directory?(File.join(file_name, p)) } subdirs.reject! { |p| %w[. ..].include? p } subdirs.each { |sd| File.clean File.join(file_name, sd) } # if its empty then delete it contents = Dir.entries(file_name).reject { |p| %w[. ..].include? p } Dir.delete file_name if contents.empty? end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
bagit-0.6.0 | lib/bagit/file.rb |
bagit-0.5.0 | lib/bagit/file.rb |
bagit-0.4.6 | lib/bagit/file.rb |
bagit-0.4.5 | lib/bagit/file.rb |
bagit-0.4.4 | lib/bagit/file.rb |