💡 About

This is a library for system file's trash in FreeDesktop Trash compliant environments.

📥 Installation

Install the gem and add to the application's Gemfile by executing:

bundle add trash_lib

If bundler is not being used to manage dependencies, install the gem by executing:

gem install trash_lib

⌨️ Usage

In Ruby do:

require 'trash'

Put files in trash:

Trash.put 'path/to/file'
Trash.put 'file1', 'file2', 'file3'

Empty the trash:

Trash.empty

List trashed files:

Trash.list
#=> [#<Trash::Entry:file1>,
     #<Trash::Entry:file2>,
     #<Trash::Entry:file3>]

trash_file = Trash.list.last

Returns the original path for file:

trash_file.origin  #=> 'original/path/to/file'

Returns the deletion time for file:

trash_file.dtime  #=> 2023-08-15 19:15:32.119439287 +0700

Restore file to original path:

trash_file.restore

Permanently delete the file:

trash_file.delete

💌 Credits