rbackup 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,4 +3,4 @@
3
3
  $:.push File.expand_path("#{File.dirname(__FILE__)}/../lib")
4
4
  require 'rbackup'
5
5
 
6
- RBackup.new(*ARGV).run
6
+ RBackup.new(ARGV.delete('--reverse'), *ARGV).run
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.8"
19
+ s.version = "0.1.9"
20
20
  end
@@ -15,7 +15,8 @@ class RBackup
15
15
 
16
16
  attr_accessor :profiles, :yaml
17
17
 
18
- def initialize(*args)
18
+ def initialize(reverse, *args)
19
+ @reverse = reverse
19
20
  get_yaml
20
21
  get_profiles(args, @yaml)
21
22
  end
@@ -38,8 +39,8 @@ class RBackup
38
39
  end
39
40
 
40
41
  def get_yaml
41
- if $TESTING
42
- config = SPEC + '/fixtures/rbackup.yml'
42
+ if $rbackup_config
43
+ config = $rbackup_config
43
44
  else
44
45
  config = File.expand_path("~/.rbackup.yml")
45
46
  end
@@ -66,7 +67,14 @@ class RBackup
66
67
  inc1ude = []
67
68
  exclude = []
68
69
  destination = profile['destination']
69
- source = [ profile['source'] ].flatten
70
+ source = profile['source']
71
+
72
+ if @reverse
73
+ last = source.split('/').last
74
+ source = source.split('/')[0..-2].join('/')
75
+ destination = [ destination, '/', last ].join('/')
76
+ destination, source = source, destination
77
+ end
70
78
 
71
79
  options = "--numeric-ids --safe-links -axzSvL"
72
80
  # --numeric-ids don't map uid/gid values by user/group name
@@ -0,0 +1,27 @@
1
+ profile_1:
2
+ source: SPEC/fixtures/destination/*
3
+ destination: SPEC/fixtures/source
4
+ exclude: 1.txt
5
+ profile_2:
6
+ source: SPEC/fixtures/destination/*
7
+ destination: SPEC/fixtures/source
8
+ exclude: 2.txt
9
+ profile_3:
10
+ profile_4:
11
+ source: SPEC/fixtures/destination/*
12
+ destination: SPEC/fixtures/source
13
+ exclude:
14
+ - 1.txt
15
+ - 2.txt
16
+ profile_5:
17
+ source: SPEC/fixtures/destination/*
18
+ destination: SPEC/fixtures/source
19
+ exclude:
20
+ - 1.txt
21
+ - 3.txt
22
+ profile_6:
23
+ source: SPEC/fixtures/destination/*
24
+ destination: SPEC/fixtures/source
25
+ include:
26
+ - 2.txt
27
+ - 3.txt
@@ -1,55 +1,64 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
2
2
 
3
3
  describe RBackup do
4
- before(:each) do
5
- Dir[SPEC + '/fixtures/destination/*'].each do |path|
6
- FileUtils.rm_rf(path)
4
+ [ :normal, :reverse ].each do |type|
5
+ before(:each) do
6
+ if type == :normal
7
+ $rbackup_config = SPEC + '/fixtures/rbackup.yml'
8
+ @reverse = false
9
+ else
10
+ $rbackup_config = SPEC + '/fixtures/rbackup_reverse.yml'
11
+ @reverse = true
12
+ end
13
+ Dir[SPEC + '/fixtures/destination/*'].each do |path|
14
+ FileUtils.rm_rf(path)
15
+ end
7
16
  end
8
- end
9
17
 
10
- it "should backup all profiles" do
11
- RBackup.new.run
12
- File.exists?(SPEC + '/fixtures/destination/1.txt').should == true
13
- File.exists?(SPEC + '/fixtures/destination/2.txt').should == true
14
- File.exists?(SPEC + '/fixtures/destination/3.txt').should == true
15
- File.read(SPEC + '/fixtures/destination/1.txt').should == '1'
16
- File.read(SPEC + '/fixtures/destination/2.txt').should == '2'
17
- File.read(SPEC + '/fixtures/destination/3.txt').should == '3'
18
- end
18
+ it "should backup all profiles" do
19
+ RBackup.new(@reverse).run
20
+ File.exists?(SPEC + '/fixtures/destination/1.txt').should == true
21
+ File.exists?(SPEC + '/fixtures/destination/2.txt').should == true
22
+ File.exists?(SPEC + '/fixtures/destination/3.txt').should == true
23
+ File.read(SPEC + '/fixtures/destination/1.txt').should == '1'
24
+ File.read(SPEC + '/fixtures/destination/2.txt').should == '2'
25
+ File.read(SPEC + '/fixtures/destination/3.txt').should == '3'
26
+ end
19
27
 
20
- it "should backup profile_1" do
21
- RBackup.new('profile_1').run
22
- File.exists?(SPEC + '/fixtures/destination/1.txt').should == false
23
- File.exists?(SPEC + '/fixtures/destination/2.txt').should == true
24
- File.exists?(SPEC + '/fixtures/destination/3.txt').should == true
25
- File.read(SPEC + '/fixtures/destination/2.txt').should == '2'
26
- File.read(SPEC + '/fixtures/destination/3.txt').should == '3'
27
- end
28
+ it "should backup profile_1" do
29
+ RBackup.new(@reverse, 'profile_1').run
30
+ File.exists?(SPEC + '/fixtures/destination/1.txt').should == false
31
+ File.exists?(SPEC + '/fixtures/destination/2.txt').should == true
32
+ File.exists?(SPEC + '/fixtures/destination/3.txt').should == true
33
+ File.read(SPEC + '/fixtures/destination/2.txt').should == '2'
34
+ File.read(SPEC + '/fixtures/destination/3.txt').should == '3'
35
+ end
28
36
 
29
- it "should backup profile_2" do
30
- RBackup.new('profile_2').run
31
- File.exists?(SPEC + '/fixtures/destination/1.txt').should == true
32
- File.exists?(SPEC + '/fixtures/destination/2.txt').should == false
33
- File.exists?(SPEC + '/fixtures/destination/3.txt').should == true
34
- File.read(SPEC + '/fixtures/destination/1.txt').should == '1'
35
- File.read(SPEC + '/fixtures/destination/3.txt').should == '3'
36
- end
37
+ it "should backup profile_2" do
38
+ RBackup.new(@reverse, 'profile_2').run
39
+ File.exists?(SPEC + '/fixtures/destination/1.txt').should == true
40
+ File.exists?(SPEC + '/fixtures/destination/2.txt').should == false
41
+ File.exists?(SPEC + '/fixtures/destination/3.txt').should == true
42
+ File.read(SPEC + '/fixtures/destination/1.txt').should == '1'
43
+ File.read(SPEC + '/fixtures/destination/3.txt').should == '3'
44
+ end
37
45
 
38
- it "should backup profile_3" do
39
- RBackup.new('profile_3').run
40
- File.exists?(SPEC + '/fixtures/destination/1.txt').should == false
41
- File.exists?(SPEC + '/fixtures/destination/2.txt').should == true
42
- File.exists?(SPEC + '/fixtures/destination/3.txt').should == true
43
- File.read(SPEC + '/fixtures/destination/2.txt').should == '2'
44
- File.read(SPEC + '/fixtures/destination/3.txt').should == '3'
45
- end
46
+ it "should backup profile_3" do
47
+ RBackup.new(@reverse, 'profile_3').run
48
+ File.exists?(SPEC + '/fixtures/destination/1.txt').should == false
49
+ File.exists?(SPEC + '/fixtures/destination/2.txt').should == true
50
+ File.exists?(SPEC + '/fixtures/destination/3.txt').should == true
51
+ File.read(SPEC + '/fixtures/destination/2.txt').should == '2'
52
+ File.read(SPEC + '/fixtures/destination/3.txt').should == '3'
53
+ end
46
54
 
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'
55
+ it "should backup profile_6" do
56
+ RBackup.new(@reverse, 'profile_6').run
57
+ File.exists?(SPEC + '/fixtures/destination/1.txt').should == false
58
+ File.exists?(SPEC + '/fixtures/destination/2.txt').should == true
59
+ File.exists?(SPEC + '/fixtures/destination/3.txt').should == true
60
+ File.read(SPEC + '/fixtures/destination/2.txt').should == '2'
61
+ File.read(SPEC + '/fixtures/destination/3.txt').should == '3'
62
+ end
54
63
  end
55
64
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 8
9
- version: 0.1.8
8
+ - 9
9
+ version: 0.1.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Winton Welsh
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-26 00:00:00 -08:00
17
+ date: 2011-02-03 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -35,6 +35,7 @@ files:
35
35
  - rbackup.gemspec
36
36
  - README.markdown
37
37
  - spec/fixtures/rbackup.yml
38
+ - spec/fixtures/rbackup_reverse.yml
38
39
  - spec/fixtures/source/1.txt
39
40
  - spec/fixtures/source/2.txt
40
41
  - spec/fixtures/source/3.txt