very_safe_rm 0.2.2 → 0.2.3

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: b1e00eb78dae1552e2a12c44ec9f954d308e891a
4
- data.tar.gz: b3bd6468bd6c83c228f973349f7b2c3852876657
3
+ metadata.gz: 022a223eeb6885bae20e56962b06358c041f130a
4
+ data.tar.gz: 8253a54c8e105cdfd72bcc796f23b1bbec27b60d
5
5
  SHA512:
6
- metadata.gz: 0f8779cffc4171caa3059e970f3b4f3cb308a8fcf1f71900041a287989c11b56b5c2dbc5b65e428509e8fb382736ae9179654945236339d0880c77efdbbaa88e
7
- data.tar.gz: 6ccc4c81b6cd279e0e6e9e5dc20b3268f7d77a5206b902c7a3ee239b570cdaf1bc5497e9a9091cd4cef5636e4f2698f7ce551c2a55a5091c1e6c75647f724aaa
6
+ metadata.gz: 20b869a70a4f9caacc2b646597068dfe51a6ad95d02b78ea2a38ff330bd97b201f0fd7c7a1b2985d2e78e747f41f99aefa16759d0c60b90c8e2eb2b8efc74009
7
+ data.tar.gz: 5351867517f862208b4427489bd8c3be7e553d9cfc9949a872c292ae316d67cef741908873f1939e1b477e96f2c3f66c53f8732ee44a3ad3b41009cdba9a1017
data/exe/very_safe_rm CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'very_safe_rm'
4
4
 
5
- file, args = VerySafeRm.parse ARGV
5
+ file, args = VerySafeRm::Arg.parse ARGV
6
6
 
7
7
  if args.include? '--version'
8
8
  print 'very_safe_rm '
data/lib/very_safe_rm.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'very_safe_rm/version'
2
2
  require 'very_safe_rm/rm_one'
3
+ require 'very_safe_rm/args'
3
4
 
4
5
  # TODO
5
6
  module VerySafeRm
@@ -8,15 +9,4 @@ module VerySafeRm
8
9
  RM.rm_one name, args
9
10
  end
10
11
  end
11
-
12
- def self.parse(argv)
13
- a = argv.each_with_object(file: [], args: [], done: false) do |arg, obj|
14
- if obj[:done] then obj[:file] << arg
15
- elsif arg == '--' then obj[:done] = true
16
- elsif arg[0] == '-' then obj[:args] << arg
17
- else obj[:file] << arg
18
- end
19
- end
20
- [a[:file], a[:args]]
21
- end
22
12
  end
@@ -0,0 +1,22 @@
1
+ module VerySafeRm
2
+ module Arg
3
+ def self.parse(argv)
4
+ a = argv.each_with_object(file: [], args: [], done: false) do |arg, obj|
5
+ if obj[:done] then obj[:file] << arg
6
+ elsif arg == '--' then obj[:done] = true
7
+ elsif arg[0] == '-' then obj[:args].push(*Arg.arg(arg))
8
+ else obj[:file] << arg
9
+ end
10
+ end
11
+ [a[:file], a[:args]]
12
+ end
13
+
14
+ private_class_method
15
+
16
+ def self.arg(arg)
17
+ return [] unless arg[0] == '-'
18
+ return [arg] if arg[1] == '-'
19
+ arg[1..-1].each_char.each_with_object([]) { |a, obj| obj << "-#{a}" }
20
+ end
21
+ end
22
+ end
@@ -3,6 +3,7 @@ module VerySafeRm
3
3
  module RM
4
4
  def self.do_rm(file, args)
5
5
  return if RM.check_bang file
6
+ sleep 2
6
7
  system "rm #{args.join ' '} #{file}"
7
8
  end
8
9
 
@@ -1,3 +1,3 @@
1
1
  module VerySafeRm
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
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.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - 71e6fd52
@@ -72,6 +72,7 @@ files:
72
72
  - bin/setup
73
73
  - exe/very_safe_rm
74
74
  - lib/very_safe_rm.rb
75
+ - lib/very_safe_rm/args.rb
75
76
  - lib/very_safe_rm/rm_one.rb
76
77
  - lib/very_safe_rm/version.rb
77
78
  - very_safe_rm.gemspec