trash_lib 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/trash/version.rb +1 -1
- data/lib/trash.rb +18 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6e39776a6ccc6111fb404ecc529058d92896221e9c806357978e092969cff85
|
4
|
+
data.tar.gz: 7cef4b83bcd07f86ebb5c0ce34dc58941210700a975ae4e22a679c90ef184879
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14b5aac37a5841ab9a930cf59d1d55cd9e2e0335bc785bbcf3709059ac9ba694ad50cf9e6b0666ecd400e2f270ad2664ec9789be6725fef2a716660ec65562d2
|
7
|
+
data.tar.gz: e554d14771f0e76b5eae1a366efa947d5ffcca70954bf89f5f92ce7e735844931a66a928ad1780d2f6e57f98ffdf2d2cdf5dfd3ed4112b4f25bddac904e790ad
|
data/CHANGELOG.md
CHANGED
data/lib/trash/version.rb
CHANGED
data/lib/trash.rb
CHANGED
@@ -25,7 +25,7 @@ module Trash
|
|
25
25
|
|
26
26
|
# Restore file to original path.
|
27
27
|
def restore
|
28
|
-
FileUtils.move
|
28
|
+
FileUtils.move(trash_path, origin, secure: true)
|
29
29
|
delete_info
|
30
30
|
|
31
31
|
nil
|
@@ -33,7 +33,7 @@ module Trash
|
|
33
33
|
|
34
34
|
# Permanently delete the file.
|
35
35
|
def delete
|
36
|
-
FileUtils.
|
36
|
+
FileUtils.rm_rf(trash_path, secure: true)
|
37
37
|
delete_info
|
38
38
|
|
39
39
|
nil
|
@@ -41,6 +41,10 @@ module Trash
|
|
41
41
|
|
42
42
|
private
|
43
43
|
|
44
|
+
def trash_path
|
45
|
+
File.join(TRASH_FILE_PATH, path)
|
46
|
+
end
|
47
|
+
|
44
48
|
def info
|
45
49
|
File.file?(info_path) ? File.read(info_path) : ''
|
46
50
|
end
|
@@ -50,7 +54,7 @@ module Trash
|
|
50
54
|
end
|
51
55
|
|
52
56
|
def delete_info
|
53
|
-
FileUtils.
|
57
|
+
FileUtils.rm_rf(info_path, secure: true)
|
54
58
|
end
|
55
59
|
end
|
56
60
|
|
@@ -72,21 +76,20 @@ module Trash
|
|
72
76
|
trash_name = trash_name(path)
|
73
77
|
trash_path = File.join(TRASH_FILE_PATH, trash_name)
|
74
78
|
|
75
|
-
FileUtils.move
|
76
|
-
make_trash_info trash_name
|
79
|
+
FileUtils.move(path, trash_path, secure: true)
|
80
|
+
make_trash_info(path, trash_name)
|
77
81
|
|
78
|
-
|
82
|
+
Dir.chdir TRASH_FILE_PATH do
|
83
|
+
Entry.new(File.basename(trash_path))
|
84
|
+
end
|
79
85
|
end
|
80
86
|
end
|
81
87
|
|
82
88
|
# Empty the trash.
|
83
89
|
def empty
|
90
|
+
FileUtils.rm_rf([TRASH_FILE_PATH, TRASH_INFO_PATH], secure: true)
|
84
91
|
make_trash_paths
|
85
92
|
|
86
|
-
[TRASH_FILE_PATH, TRASH_INFO_PATH]
|
87
|
-
.map { Dir.children _1 }.flatten
|
88
|
-
.each { FileUtils.remove_entry_secure _1, force: true }
|
89
|
-
|
90
93
|
nil
|
91
94
|
end
|
92
95
|
|
@@ -108,18 +111,17 @@ module Trash
|
|
108
111
|
trash_name
|
109
112
|
end
|
110
113
|
|
111
|
-
def make_trash_info(trash_name)
|
112
|
-
File.
|
113
|
-
|
114
|
+
def make_trash_info(path, trash_name)
|
115
|
+
File.write(
|
116
|
+
File.join(TRASH_INFO_PATH, "#{trash_name}.trashinfo"),
|
117
|
+
<<~TRASH_INFO
|
114
118
|
[Trash Info]
|
115
119
|
Path=#{File.absolute_path path}
|
116
120
|
DeletionDate=#{Time.now.strftime '%Y-%m-%dT%T'}
|
117
121
|
TRASH_INFO
|
118
|
-
|
122
|
+
)
|
119
123
|
end
|
120
124
|
end
|
121
125
|
|
122
126
|
private_constant :Entry, :TRASH_PATH, :TRASH_FILE_PATH, :TRASH_INFO_PATH
|
123
127
|
end
|
124
|
-
|
125
|
-
pp Trash.list
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trash_lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NNB
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This is a library for system file's trash in FreeDesktop Trash compliant
|
14
14
|
environments.
|