Sha256: 1eb86e19b492bf18668c08e76c928e5abac16dfb248d86933dc1731488e5cff1

Contents?: true

Size: 524 Bytes

Versions: 17

Compression:

Stored size: 524 Bytes

Contents

class File

  # Clean out all the empty dirs
  def File.clean(file_name)

    if 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

end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
bagit-0.4.2 lib/bagit/file.rb
bagit-0.4.1 lib/bagit/file.rb
bagit-0.4.0 lib/bagit/file.rb
bagit-0.3.5 lib/bagit/file.rb
bagit-0.3.4 lib/bagit/file.rb
flazz-bagit-0.0.1 lib/bagit/file.rb
flazz-bagit-0.0.2 lib/bagit/file.rb
bagit-0.3.2 lib/bagit/file.rb
bagit-0.3.2.pre lib/bagit/file.rb
bagit-0.3.1 lib/bagit/file.rb
bagit-0.3.0 lib/bagit/file.rb
bagit-0.3.0.pre lib/bagit/file.rb
bagit-0.2.0 lib/bagit/file.rb
bagit-0.1.0 lib/bagit/file.rb
bagit-0.0.4 lib/bagit/file.rb
bagit-0.0.3 lib/bagit/file.rb
bagit-0.0.2 lib/bagit/file.rb