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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75c16e110946d251b05bcd6c1db9e5c7733d2deda45f495896004fae2b8b5e6a
4
- data.tar.gz: 5dd20ad59c2c4e7e214ceef63ee0435a761517f0f0a14c766ce25eebc5855db2
3
+ metadata.gz: a6e39776a6ccc6111fb404ecc529058d92896221e9c806357978e092969cff85
4
+ data.tar.gz: 7cef4b83bcd07f86ebb5c0ce34dc58941210700a975ae4e22a679c90ef184879
5
5
  SHA512:
6
- metadata.gz: f677937b43fb8328108f7c24117f42be1199201a152d69b4a021c96d8b37bcdf8e0850a5a9cf42d422e8fe8299aa71f9d1325dc52067f6e8a3a8f374a1e2b28d
7
- data.tar.gz: 33a16451d7c70668d8ce48ae78983d05931efe8a6e7de0264df885ccc6389e6e0367210af8f9a48597f296ae22a9c3fd94d3cbd136340a0ec29922a06dabe01d
6
+ metadata.gz: 14b5aac37a5841ab9a930cf59d1d55cd9e2e0335bc785bbcf3709059ac9ba694ad50cf9e6b0666ecd400e2f270ad2664ec9789be6725fef2a716660ec65562d2
7
+ data.tar.gz: e554d14771f0e76b5eae1a366efa947d5ffcca70954bf89f5f92ce7e735844931a66a928ad1780d2f6e57f98ffdf2d2cdf5dfd3ed4112b4f25bddac904e790ad
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [1.0.2] - 2023-08-16
2
+
3
+ - Hot fixed `Trash::Entry#restore` and `Trash::Entry#delete`.
4
+
5
+ ## [1.0.1] - 2023-08-16
6
+
7
+ - Hot fixed `Trash::put`.
8
+
1
9
  ## [1.0.0] - 2023-08-16
2
10
 
3
11
  - Initial release.
data/lib/trash/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Trash
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.2'
5
5
  end
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 path, origin, secure: true # FIXME
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.remove_entry_secure path, force: true
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.remove_entry_secure info_path, force: true
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 path, trash_path, secure: true
76
- make_trash_info trash_name
79
+ FileUtils.move(path, trash_path, secure: true)
80
+ make_trash_info(path, trash_name)
77
81
 
78
- Entry.new trash_path
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.open(File.join(TRASH_INFO_PATH, "#{trash_name}.trashinfo"), 'w') do |file|
113
- file.write <<~TRASH_INFO
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
- end
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.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-15 00:00:00.000000000 Z
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.