Sha256: f9a119cab3f666c6f8431b20b3a807ff6b93db61ed82ce19d86da72ba2162685

Contents?: true

Size: 505 Bytes

Versions: 1

Compression:

Stored size: 505 Bytes

Contents

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

1 entries across 1 versions & 1 rubygems

Version Path
bagit-0.4.3 lib/bagit/file.rb