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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e11ad23555bd0bd1132f59108d1f53bed508141
4
- data.tar.gz: cccd92ad7ec15cc58493a7d1613253d757c89933
3
+ metadata.gz: 32d56f2666f7b7dbe339b3f483052fdd5c782ae0
4
+ data.tar.gz: f2670e3408bbc889567e34b38e3b3711e00cc812
5
5
  SHA512:
6
- metadata.gz: 04acb66942ca62be598b277f9234b2e9a345f4731b24f00ee89c3af63aa0f09b07b70af7aa356cd5f65a1035b19d8f7770de895a0a4f82de8725de3cd4fbd950
7
- data.tar.gz: ac4fd47ce4a6b907d622e35cb9c64e9ce2768b2cca48be8b87675466a8ef8824a7c966f98be271a1f936a413da4dd82a55ace1333ad71bc32969aa0d6a4470fb
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 =~ /y(es)?/i
14
+ exit unless STDIN.gets.chomp =~ /^y(es)?$/i
15
15
  end
16
16
 
17
17
  VerySafeRm.run file, args
@@ -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.do_rm(file, args)
14
- system "rm #{args.join ' '} #{file}"
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
@@ -1,3 +1,3 @@
1
1
  module VerySafeRm
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: very_safe_rm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 71e6fd52