very_safe_rm 0.2.3 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/very_safe_rm +1 -0
- data/lib/very_safe_rm/rm_one.rb +17 -5
- data/lib/very_safe_rm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 792ea87c0f1f38eb3dd06d48d1997c2645d01c6a
|
4
|
+
data.tar.gz: 8868266655e70d1bc33fec575fa43a395157c27b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f1e5a90a2194ac0ef5cbd749af09374d5a9fab204327a10ad627d5d274a585ae96147f57c50c6eb7948fe417b1e974fafd9e6c1bdcf5e52470362bad60901c4
|
7
|
+
data.tar.gz: f92d232e00ef46830ccaa7be3a3e1b318ad4532c9afc61995934d83c70aa042097b99a5ec4a49b4e8224f208d777b6b9b8c2749662dceceb99dd567a09831b43
|
data/exe/very_safe_rm
CHANGED
data/lib/very_safe_rm/rm_one.rb
CHANGED
@@ -1,21 +1,33 @@
|
|
1
1
|
module VerySafeRm
|
2
2
|
# TODO
|
3
3
|
module RM
|
4
|
+
def self.rm(file, args)
|
5
|
+
system "rm #{args.join ' '} -- #{file}"
|
6
|
+
end
|
7
|
+
|
4
8
|
def self.do_rm(file, args)
|
5
9
|
return if RM.check_bang file
|
6
10
|
sleep 2
|
7
|
-
|
11
|
+
RM.rm file, args
|
8
12
|
end
|
9
13
|
|
10
14
|
def self.rm_one(file, args)
|
11
15
|
filesystem = `stat -fc %T #{file}`
|
12
|
-
if filesystem == 'nilfs' then RM.
|
13
|
-
elsif Dir.empty? file then RM.
|
14
|
-
elsif File.empty? file then RM.
|
15
|
-
|
16
|
+
if filesystem == 'nilfs' then RM.rm file, ['-r', '-v', '-f']
|
17
|
+
elsif Dir.empty? file then RM.rm file, ['-r', '-f', '-v']
|
18
|
+
elsif File.empty? file then RM.rm file, ['-f', '-v']
|
19
|
+
elsif RM.check_force_rm? file then RM.rm file, ['-v', *args]
|
20
|
+
else RM.do_rm file, ['-i', '-v', *args]
|
16
21
|
end
|
17
22
|
end
|
18
23
|
|
24
|
+
def self.check_force_rm(file)
|
25
|
+
return false unless File.exist? \
|
26
|
+
File.expand_path("-#{file}.rm", File.dirname(file))
|
27
|
+
RM.rm "-#{file}.rm", ['-r', '-f']
|
28
|
+
true
|
29
|
+
end
|
30
|
+
|
19
31
|
def self.check_bang(file)
|
20
32
|
file.reverse.each_char do |char|
|
21
33
|
return false unless char == '!'
|
data/lib/very_safe_rm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: very_safe_rm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 71e6fd52
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|