very_safe_rm 0.1.1 → 0.2.0
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 -1
- data/lib/very_safe_rm/rm_one.rb +11 -2
- data/lib/very_safe_rm/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32d56f2666f7b7dbe339b3f483052fdd5c782ae0
|
4
|
+
data.tar.gz: f2670e3408bbc889567e34b38e3b3711e00cc812
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f398083dfac4a2d815f8522ed35bfab076e31eb8d797b5e8669ba2ac6fd6c5e9f95f30d474f9790cc1c1ed0671980b6f77bd8026b2915582cc520c33cc7701b6
|
7
|
+
data.tar.gz: 280d8ab607f073eac4b8176535183a9b9657d8637f72ab208c143e1c1e293962d5b04e3f5acd88fb0785d47f4e92918eca8f06faa3a831cf4fd4253e30059ced
|
data/exe/very_safe_rm
CHANGED
@@ -11,7 +11,7 @@ end
|
|
11
11
|
|
12
12
|
if args.include?('-r') || args.include?('-R') || args.include?('--recursive')
|
13
13
|
STDERR.print 'Did you really want to delete directory? [y/N] '
|
14
|
-
exit unless STDIN.gets.chomp =~
|
14
|
+
exit unless STDIN.gets.chomp =~ /^y(es)?$/i
|
15
15
|
end
|
16
16
|
|
17
17
|
VerySafeRm.run file, args
|
data/lib/very_safe_rm/rm_one.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
module VerySafeRm
|
2
2
|
# TODO
|
3
3
|
module RM
|
4
|
+
def self.do_rm(file, args)
|
5
|
+
return if RM.check_bang file
|
6
|
+
system "rm #{args.join ' '} #{file}"
|
7
|
+
end
|
8
|
+
|
4
9
|
def self.rm_one(file, args)
|
5
10
|
filesystem = `stat -fc %T #{file}`
|
6
11
|
if filesystem == 'nilfs' then RM.do_rm file, ['-rvf']
|
@@ -10,8 +15,12 @@ module VerySafeRm
|
|
10
15
|
end
|
11
16
|
end
|
12
17
|
|
13
|
-
def self.
|
14
|
-
|
18
|
+
def self.check_bang(file)
|
19
|
+
file.reverse.each_char do |char|
|
20
|
+
return true unless char == '!'
|
21
|
+
STDERR.print "Did you really want to delete `#{file}? [y/N] "
|
22
|
+
return false unless STDIN.gets =~ /^y(es)?$/i
|
23
|
+
end
|
15
24
|
end
|
16
25
|
end
|
17
26
|
end
|
data/lib/very_safe_rm/version.rb
CHANGED