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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 022a223eeb6885bae20e56962b06358c041f130a
4
- data.tar.gz: 8253a54c8e105cdfd72bcc796f23b1bbec27b60d
3
+ metadata.gz: 792ea87c0f1f38eb3dd06d48d1997c2645d01c6a
4
+ data.tar.gz: 8868266655e70d1bc33fec575fa43a395157c27b
5
5
  SHA512:
6
- metadata.gz: 20b869a70a4f9caacc2b646597068dfe51a6ad95d02b78ea2a38ff330bd97b201f0fd7c7a1b2985d2e78e747f41f99aefa16759d0c60b90c8e2eb2b8efc74009
7
- data.tar.gz: 5351867517f862208b4427489bd8c3be7e553d9cfc9949a872c292ae316d67cef741908873f1939e1b477e96f2c3f66c53f8732ee44a3ad3b41009cdba9a1017
6
+ metadata.gz: 5f1e5a90a2194ac0ef5cbd749af09374d5a9fab204327a10ad627d5d274a585ae96147f57c50c6eb7948fe417b1e974fafd9e6c1bdcf5e52470362bad60901c4
7
+ data.tar.gz: f92d232e00ef46830ccaa7be3a3e1b318ad4532c9afc61995934d83c70aa042097b99a5ec4a49b4e8224f208d777b6b9b8c2749662dceceb99dd567a09831b43
data/exe/very_safe_rm CHANGED
@@ -20,6 +20,7 @@ end
20
20
  if args.include?('-r') || args.include?('-R') || args.include?('--recursive')
21
21
  STDERR.print 'Did you really want to delete directory? [y/N] '
22
22
  exit unless STDIN.gets.chomp =~ /^y(es)?$/i
23
+ args << '-f'
23
24
  end
24
25
 
25
26
  VerySafeRm.run file, args
@@ -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
- system "rm #{args.join ' '} #{file}"
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.do_rm file, ['-rvf']
13
- elsif Dir.empty? file then RM.do_rm file, ['-rfv']
14
- elsif File.empty? file then RM.do_rm file, ['-fv']
15
- else RM.do_rm file, ['-iv', *args]
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 == '!'
@@ -1,3 +1,3 @@
1
1
  module VerySafeRm
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.5"
3
3
  end
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.3
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-01 00:00:00.000000000 Z
11
+ date: 2017-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler