rbackup 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/gemspec.rb CHANGED
@@ -16,5 +16,5 @@ GEM_SPEC = Gem::Specification.new do |s|
16
16
  s.name = GEM_NAME
17
17
  s.platform = Gem::Platform::RUBY
18
18
  s.require_path = "lib"
19
- s.version = "0.1.4"
19
+ s.version = "0.1.5"
20
20
  end
@@ -60,6 +60,8 @@ class RBackup
60
60
  end
61
61
 
62
62
  def rsync(profile)
63
+ inc1ude = []
64
+ exclude = []
63
65
  destination = profile['destination']
64
66
  source = profile['source'].to_a
65
67
 
@@ -81,16 +83,22 @@ class RBackup
81
83
  # -E, --extended-attributes copy extended attributes, resource forks
82
84
  FileUtils.mkdir_p destination
83
85
  end
86
+
87
+ if profile['include']
88
+ exclude = %w(*) unless profile['exclude']
89
+ inc1ude = profile['include'].to_a
90
+ end
84
91
 
85
92
  if profile['exclude']
86
- exclude = profile['exclude'].to_a
87
- exclude = exclude.collect { |e| "--exclude='#{e}'" }.join(' ')
88
- # --exclude=PATTERN use one of these for each file you want to exclude
89
- else
90
- exclude = nil
93
+ exclude += profile['exclude'].to_a
91
94
  end
95
+
96
+ inc1ude = inc1ude.collect { |i| "--include='#{i}'" }.join(' ')
97
+ exclude = exclude.collect { |e| "--exclude='#{e}'" }.join(' ')
98
+ # --exclude=PATTERN use one of these for each file you want to exclude
99
+ # --include-from=FILE don't exclude patterns listed in FILE
92
100
 
93
- cmd = "rsync #{options} #{exclude} #{esc(source)} #{esc(destination)}"
101
+ cmd = "rsync #{options} #{inc1ude} #{exclude} #{esc(source)} #{esc(destination)}"
94
102
  if $TESTING
95
103
  `#{cmd}`
96
104
  else
@@ -18,4 +18,10 @@ profile_3:
18
18
  destination: SPEC/fixtures/destination
19
19
  exclude:
20
20
  - 1.txt
21
+ - 3.txt
22
+ profile_6:
23
+ source: SPEC/fixtures/source/*
24
+ destination: SPEC/fixtures/destination
25
+ include:
26
+ - 2.txt
21
27
  - 3.txt
@@ -43,4 +43,13 @@ describe RBackup do
43
43
  File.read(SPEC + '/fixtures/destination/2.txt').should == '2'
44
44
  File.read(SPEC + '/fixtures/destination/3.txt').should == '3'
45
45
  end
46
+
47
+ it "should backup profile_6" do
48
+ RBackup.new('profile_6').run
49
+ File.exists?(SPEC + '/fixtures/destination/1.txt').should == false
50
+ File.exists?(SPEC + '/fixtures/destination/2.txt').should == true
51
+ File.exists?(SPEC + '/fixtures/destination/3.txt').should == true
52
+ File.read(SPEC + '/fixtures/destination/2.txt').should == '2'
53
+ File.read(SPEC + '/fixtures/destination/3.txt').should == '3'
54
+ end
46
55
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbackup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Winton Welsh
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-06 00:00:00 -08:00
12
+ date: 2009-11-27 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15