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 +1 -1
- data/lib/rbackup.rb +14 -6
- data/spec/fixtures/rbackup.yml +6 -0
- data/spec/rbackup_spec.rb +9 -0
- metadata +2 -2
data/gemspec.rb
CHANGED
data/lib/rbackup.rb
CHANGED
@@ -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
|
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
|
data/spec/fixtures/rbackup.yml
CHANGED
data/spec/rbackup_spec.rb
CHANGED
@@ -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
|
+
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-
|
12
|
+
date: 2009-11-27 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|