fackup 0.0.1.1 → 0.0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/lib/fackup.rb +1 -1
  2. data/lib/fackup/cli.rb +22 -2
  3. metadata +2 -2
@@ -22,7 +22,7 @@ require 'fackup/db'
22
22
  require 'fackup/image'
23
23
 
24
24
  module FackUp
25
- VERSION = '0.0.1.1'
25
+ VERSION = '0.0.1.2'
26
26
 
27
27
  def self.restore (image)
28
28
  FackUp::Image.new(image, 'r', true) {|img|
@@ -30,14 +30,21 @@ module FackUp
30
30
  puts "fackup v#{FackUp::VERSION}"
31
31
  end
32
32
 
33
- desc 'add FILE... [OPTIONS]', 'add file to backup'
33
+ desc 'add FILE... [OPTIONS]', 'add files to backup'
34
34
  method_option :recursive, aliases: '-r', type: :boolean, default: false,
35
35
  desc: 'Add files in directories recursively'
36
36
  def add (*files)
37
37
  files.each {|file|
38
38
  if File.directory?(file)
39
39
  if options[:recursive]
40
- add(Dir["#{file}/*"])
40
+ Dir[File.join(file, '**', '*')].each {|f|
41
+ next unless File.file?(f)
42
+
43
+ unless DB << f
44
+ say '* ', :red
45
+ say "Can't add #{file}, unknown error."
46
+ end
47
+ }
41
48
  else
42
49
  say '* ', :red
43
50
  say "#{file} is a directory."
@@ -54,6 +61,19 @@ module FackUp
54
61
  }
55
62
  end
56
63
 
64
+ desc 'delete PATTERN...', 'delete files from backup, it supports wildcards'
65
+ def delete (*patterns)
66
+ patterns.map! {|pattern|
67
+ File.expand_path(pattern)
68
+ }
69
+
70
+ DB.each {|file|
71
+ patterns.each {|pattern|
72
+ DB.delete(file) if File.fnmatch?(pattern, file)
73
+ }
74
+ }
75
+ end
76
+
57
77
  desc 'backup [FILE]', 'backup files'
58
78
  def backup (file=File.join(Dir.home, 'fackup_backup.img'))
59
79
  FackUp.backup(file)
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.0.1.1
9
+ - 2
10
+ version: 0.0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - shura