backup 3.0.27 → 3.1.0

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 (166) hide show
  1. data/LICENSE.md +1 -1
  2. data/README.md +139 -386
  3. data/bin/backup +1 -7
  4. data/lib/backup.rb +3 -9
  5. data/lib/backup/archive.rb +26 -20
  6. data/lib/backup/cleaner.rb +2 -2
  7. data/lib/backup/cli.rb +366 -0
  8. data/lib/backup/compressor/base.rb +2 -2
  9. data/lib/backup/compressor/gzip.rb +35 -1
  10. data/lib/backup/config.rb +1 -2
  11. data/lib/backup/database/base.rb +2 -2
  12. data/lib/backup/database/mongodb.rb +3 -3
  13. data/lib/backup/database/mysql.rb +3 -2
  14. data/lib/backup/database/postgresql.rb +3 -2
  15. data/lib/backup/database/riak.rb +18 -5
  16. data/lib/backup/dependency.rb +144 -93
  17. data/lib/backup/encryptor/base.rb +2 -2
  18. data/lib/backup/logger.rb +108 -110
  19. data/lib/backup/logger/console.rb +51 -0
  20. data/lib/backup/logger/logfile.rb +113 -0
  21. data/lib/backup/logger/syslog.rb +116 -0
  22. data/lib/backup/model.rb +67 -65
  23. data/lib/backup/notifier/base.rb +1 -1
  24. data/lib/backup/notifier/hipchat.rb +1 -1
  25. data/lib/backup/notifier/mail.rb +1 -1
  26. data/lib/backup/notifier/pushover.rb +6 -3
  27. data/lib/backup/packager.rb +4 -4
  28. data/lib/backup/pipeline.rb +17 -3
  29. data/lib/backup/splitter.rb +2 -2
  30. data/lib/backup/storage/base.rb +2 -2
  31. data/lib/backup/storage/cloudfiles.rb +2 -2
  32. data/lib/backup/storage/dropbox.rb +4 -4
  33. data/lib/backup/storage/ftp.rb +2 -2
  34. data/lib/backup/storage/local.rb +2 -2
  35. data/lib/backup/storage/ninefold.rb +2 -2
  36. data/lib/backup/storage/rsync.rb +3 -3
  37. data/lib/backup/storage/s3.rb +2 -2
  38. data/lib/backup/storage/scp.rb +2 -6
  39. data/lib/backup/storage/sftp.rb +2 -5
  40. data/lib/backup/syncer/base.rb +1 -1
  41. data/lib/backup/syncer/cloud/base.rb +15 -8
  42. data/lib/backup/syncer/rsync/local.rb +1 -1
  43. data/lib/backup/syncer/rsync/pull.rb +1 -1
  44. data/lib/backup/syncer/rsync/push.rb +1 -1
  45. data/lib/backup/utilities.rb +211 -0
  46. data/lib/backup/version.rb +1 -1
  47. data/templates/cli/{utility/archive → archive} +4 -8
  48. data/templates/cli/{utility/compressor → compressor}/bzip2 +0 -0
  49. data/templates/cli/{utility/compressor → compressor}/custom +0 -0
  50. data/templates/cli/{utility/compressor → compressor}/gzip +0 -0
  51. data/templates/cli/{utility/compressor → compressor}/lzma +0 -0
  52. data/templates/cli/{utility/compressor → compressor}/pbzip2 +0 -0
  53. data/templates/cli/config +68 -0
  54. data/templates/cli/{utility/database → database}/mongodb +1 -1
  55. data/templates/cli/{utility/database → database}/mysql +1 -1
  56. data/templates/cli/{utility/database → database}/postgresql +1 -1
  57. data/templates/cli/{utility/database → database}/redis +0 -0
  58. data/templates/cli/database/riak +20 -0
  59. data/templates/cli/{utility/encryptor → encryptor}/gpg +0 -0
  60. data/templates/cli/{utility/encryptor → encryptor}/openssl +0 -0
  61. data/templates/cli/{utility/model.erb → model.erb} +4 -4
  62. data/templates/cli/{utility/notifier → notifier}/campfire +0 -0
  63. data/templates/cli/{utility/notifier → notifier}/hipchat +0 -0
  64. data/templates/cli/{utility/notifier → notifier}/mail +0 -0
  65. data/templates/cli/{utility/notifier → notifier}/prowl +0 -0
  66. data/templates/cli/{utility/notifier → notifier}/pushover +0 -0
  67. data/templates/cli/{utility/notifier → notifier}/twitter +0 -0
  68. data/templates/cli/{utility/splitter → splitter} +0 -0
  69. data/templates/cli/{utility/storage → storage}/cloud_files +0 -0
  70. data/templates/cli/{utility/storage → storage}/dropbox +0 -0
  71. data/templates/cli/{utility/storage → storage}/ftp +0 -0
  72. data/templates/cli/{utility/storage → storage}/local +0 -0
  73. data/templates/cli/{utility/storage → storage}/ninefold +0 -0
  74. data/templates/cli/{utility/storage → storage}/rsync +0 -0
  75. data/templates/cli/{utility/storage → storage}/s3 +0 -0
  76. data/templates/cli/{utility/storage → storage}/scp +0 -0
  77. data/templates/cli/{utility/storage → storage}/sftp +0 -0
  78. data/templates/cli/{utility/syncer → syncer}/cloud_files +0 -0
  79. data/templates/cli/{utility/syncer → syncer}/rsync_local +0 -0
  80. data/templates/cli/{utility/syncer → syncer}/rsync_pull +0 -0
  81. data/templates/cli/{utility/syncer → syncer}/rsync_push +0 -0
  82. data/templates/cli/{utility/syncer → syncer}/s3 +0 -0
  83. metadata +55 -131
  84. data/.gitignore +0 -8
  85. data/.travis.yml +0 -10
  86. data/Gemfile +0 -28
  87. data/Guardfile +0 -23
  88. data/backup.gemspec +0 -32
  89. data/lib/backup/cli/helpers.rb +0 -93
  90. data/lib/backup/cli/utility.rb +0 -255
  91. data/spec-live/.gitignore +0 -6
  92. data/spec-live/README +0 -7
  93. data/spec-live/backups/config.rb +0 -83
  94. data/spec-live/backups/config.yml.template +0 -46
  95. data/spec-live/backups/models.rb +0 -184
  96. data/spec-live/compressor/custom_spec.rb +0 -30
  97. data/spec-live/compressor/gzip_spec.rb +0 -30
  98. data/spec-live/encryptor/gpg_keys.rb +0 -239
  99. data/spec-live/encryptor/gpg_spec.rb +0 -287
  100. data/spec-live/notifier/mail_spec.rb +0 -121
  101. data/spec-live/spec_helper.rb +0 -151
  102. data/spec-live/storage/dropbox_spec.rb +0 -151
  103. data/spec-live/storage/local_spec.rb +0 -83
  104. data/spec-live/storage/scp_spec.rb +0 -193
  105. data/spec-live/syncer/cloud/s3_spec.rb +0 -124
  106. data/spec/archive_spec.rb +0 -335
  107. data/spec/cleaner_spec.rb +0 -312
  108. data/spec/cli/helpers_spec.rb +0 -301
  109. data/spec/cli/utility_spec.rb +0 -411
  110. data/spec/compressor/base_spec.rb +0 -52
  111. data/spec/compressor/bzip2_spec.rb +0 -217
  112. data/spec/compressor/custom_spec.rb +0 -106
  113. data/spec/compressor/gzip_spec.rb +0 -217
  114. data/spec/compressor/lzma_spec.rb +0 -123
  115. data/spec/compressor/pbzip2_spec.rb +0 -165
  116. data/spec/config_spec.rb +0 -321
  117. data/spec/configuration/helpers_spec.rb +0 -247
  118. data/spec/configuration/store_spec.rb +0 -39
  119. data/spec/configuration_spec.rb +0 -62
  120. data/spec/database/base_spec.rb +0 -63
  121. data/spec/database/mongodb_spec.rb +0 -510
  122. data/spec/database/mysql_spec.rb +0 -411
  123. data/spec/database/postgresql_spec.rb +0 -353
  124. data/spec/database/redis_spec.rb +0 -334
  125. data/spec/database/riak_spec.rb +0 -176
  126. data/spec/dependency_spec.rb +0 -51
  127. data/spec/encryptor/base_spec.rb +0 -40
  128. data/spec/encryptor/gpg_spec.rb +0 -909
  129. data/spec/encryptor/open_ssl_spec.rb +0 -148
  130. data/spec/errors_spec.rb +0 -306
  131. data/spec/logger_spec.rb +0 -367
  132. data/spec/model_spec.rb +0 -666
  133. data/spec/notifier/base_spec.rb +0 -104
  134. data/spec/notifier/campfire_spec.rb +0 -217
  135. data/spec/notifier/hipchat_spec.rb +0 -211
  136. data/spec/notifier/mail_spec.rb +0 -316
  137. data/spec/notifier/prowl_spec.rb +0 -138
  138. data/spec/notifier/pushover_spec.rb +0 -123
  139. data/spec/notifier/twitter_spec.rb +0 -153
  140. data/spec/package_spec.rb +0 -61
  141. data/spec/packager_spec.rb +0 -213
  142. data/spec/pipeline_spec.rb +0 -259
  143. data/spec/spec_helper.rb +0 -60
  144. data/spec/splitter_spec.rb +0 -120
  145. data/spec/storage/base_spec.rb +0 -166
  146. data/spec/storage/cloudfiles_spec.rb +0 -254
  147. data/spec/storage/cycler_spec.rb +0 -247
  148. data/spec/storage/dropbox_spec.rb +0 -480
  149. data/spec/storage/ftp_spec.rb +0 -271
  150. data/spec/storage/local_spec.rb +0 -259
  151. data/spec/storage/ninefold_spec.rb +0 -343
  152. data/spec/storage/rsync_spec.rb +0 -362
  153. data/spec/storage/s3_spec.rb +0 -245
  154. data/spec/storage/scp_spec.rb +0 -233
  155. data/spec/storage/sftp_spec.rb +0 -244
  156. data/spec/syncer/base_spec.rb +0 -109
  157. data/spec/syncer/cloud/base_spec.rb +0 -515
  158. data/spec/syncer/cloud/cloud_files_spec.rb +0 -181
  159. data/spec/syncer/cloud/s3_spec.rb +0 -174
  160. data/spec/syncer/rsync/base_spec.rb +0 -98
  161. data/spec/syncer/rsync/local_spec.rb +0 -149
  162. data/spec/syncer/rsync/pull_spec.rb +0 -98
  163. data/spec/syncer/rsync/push_spec.rb +0 -333
  164. data/spec/version_spec.rb +0 -21
  165. data/templates/cli/utility/config +0 -32
  166. data/templates/cli/utility/database/riak +0 -11
@@ -1,181 +0,0 @@
1
- # encoding: utf-8
2
- require File.expand_path('../../../spec_helper.rb', __FILE__)
3
-
4
- describe 'Backup::Syncer::Cloud::CloudFiles' do
5
- let(:syncer) do
6
- Backup::Syncer::Cloud::CloudFiles.new do |cf|
7
- cf.api_key = 'my_api_key'
8
- cf.username = 'my_username'
9
- cf.container = 'my_container'
10
- cf.auth_url = 'my_auth_url'
11
- cf.servicenet = true
12
- end
13
- end
14
-
15
- it 'should be a subclass of Syncer::Cloud::Base' do
16
- Backup::Syncer::Cloud::CloudFiles.
17
- superclass.should == Backup::Syncer::Cloud::Base
18
- end
19
-
20
- describe '#initialize' do
21
- after { Backup::Syncer::Cloud::CloudFiles.clear_defaults! }
22
-
23
- it 'should load pre-configured defaults through Syncer::Cloud::Base' do
24
- Backup::Syncer::Cloud::CloudFiles.any_instance.expects(:load_defaults!)
25
- syncer
26
- end
27
-
28
- it 'should strip any leading slash in path' do
29
- syncer = Backup::Syncer::Cloud::CloudFiles.new do |cloud|
30
- cloud.path = '/cleaned/path'
31
- end
32
- syncer.path.should == 'cleaned/path'
33
- end
34
-
35
- context 'when no pre-configured defaults have been set' do
36
- it 'should use the values given' do
37
- syncer.api_key.should == 'my_api_key'
38
- syncer.username.should == 'my_username'
39
- syncer.container.should == 'my_container'
40
- syncer.auth_url.should == 'my_auth_url'
41
- syncer.servicenet.should == true
42
- end
43
-
44
- it 'should use default values if none are given' do
45
- syncer = Backup::Syncer::Cloud::CloudFiles.new
46
-
47
- # from Syncer::Base
48
- syncer.path.should == 'backups'
49
- syncer.mirror.should == false
50
- syncer.directories.should == []
51
-
52
- # from Syncer::Cloud::Base
53
- syncer.concurrency_type.should == false
54
- syncer.concurrency_level.should == 2
55
-
56
- syncer.api_key.should == nil
57
- syncer.username.should == nil
58
- syncer.container.should == nil
59
- syncer.auth_url.should == nil
60
- syncer.servicenet.should == nil
61
- end
62
- end # context 'when no pre-configured defaults have been set'
63
-
64
- context 'when pre-configured defaults have been set' do
65
- before do
66
- Backup::Syncer::Cloud::CloudFiles.defaults do |cloud|
67
- cloud.api_key = 'default_api_key'
68
- cloud.username = 'default_username'
69
- cloud.container = 'default_container'
70
- cloud.auth_url = 'default_auth_url'
71
- cloud.servicenet = 'default_servicenet'
72
- end
73
- end
74
-
75
- it 'should use pre-configured defaults' do
76
- syncer = Backup::Syncer::Cloud::CloudFiles.new
77
-
78
- # from Syncer::Base
79
- syncer.path.should == 'backups'
80
- syncer.mirror.should == false
81
- syncer.directories.should == []
82
-
83
- # from Syncer::Cloud::Base
84
- syncer.concurrency_type.should == false
85
- syncer.concurrency_level.should == 2
86
-
87
- syncer.api_key.should == 'default_api_key'
88
- syncer.username.should == 'default_username'
89
- syncer.container.should == 'default_container'
90
- syncer.auth_url.should == 'default_auth_url'
91
- syncer.servicenet.should == 'default_servicenet'
92
- end
93
-
94
- it 'should override pre-configured defaults' do
95
- syncer = Backup::Syncer::Cloud::CloudFiles.new do |cloud|
96
- cloud.path = 'new_path'
97
- cloud.mirror = 'new_mirror'
98
- cloud.concurrency_type = 'new_concurrency_type'
99
- cloud.concurrency_level = 'new_concurrency_level'
100
-
101
- cloud.api_key = 'new_api_key'
102
- cloud.username = 'new_username'
103
- cloud.container = 'new_container'
104
- cloud.auth_url = 'new_auth_url'
105
- cloud.servicenet = 'new_servicenet'
106
- end
107
-
108
- syncer.path.should == 'new_path'
109
- syncer.mirror.should == 'new_mirror'
110
- syncer.directories.should == []
111
- syncer.concurrency_type.should == 'new_concurrency_type'
112
- syncer.concurrency_level.should == 'new_concurrency_level'
113
-
114
- syncer.api_key.should == 'new_api_key'
115
- syncer.username.should == 'new_username'
116
- syncer.container.should == 'new_container'
117
- syncer.auth_url.should == 'new_auth_url'
118
- syncer.servicenet.should == 'new_servicenet'
119
- end
120
- end # context 'when pre-configured defaults have been set'
121
- end # describe '#initialize'
122
-
123
- describe '#connection' do
124
- let(:connection) { mock }
125
-
126
- before do
127
- Fog::Storage.expects(:new).once.with(
128
- :provider => 'Rackspace',
129
- :rackspace_username => 'my_username',
130
- :rackspace_api_key => 'my_api_key',
131
- :rackspace_auth_url => 'my_auth_url',
132
- :rackspace_servicenet => true
133
- ).returns(connection)
134
- end
135
-
136
- it 'should establish and re-use the connection' do
137
- syncer.send(:connection).should == connection
138
- syncer.instance_variable_get(:@connection).should == connection
139
- syncer.send(:connection).should == connection
140
- end
141
- end
142
-
143
- describe '#repository_object' do
144
- let(:connection) { mock }
145
- let(:directories) { mock }
146
- let(:container) { mock }
147
-
148
- before do
149
- syncer.stubs(:connection).returns(connection)
150
- connection.stubs(:directories).returns(directories)
151
- end
152
-
153
- context 'when the @container does not exist' do
154
- before do
155
- directories.expects(:get).once.with('my_container').returns(nil)
156
- directories.expects(:create).once.with(
157
- :key => 'my_container'
158
- ).returns(container)
159
- end
160
-
161
- it 'should create and re-use the container' do
162
- syncer.send(:repository_object).should == container
163
- syncer.instance_variable_get(:@repository_object).should == container
164
- syncer.send(:repository_object).should == container
165
- end
166
- end
167
-
168
- context 'when the @container does exist' do
169
- before do
170
- directories.expects(:get).once.with('my_container').returns(container)
171
- directories.expects(:create).never
172
- end
173
-
174
- it 'should retrieve and re-use the container' do
175
- syncer.send(:repository_object).should == container
176
- syncer.instance_variable_get(:@repository_object).should == container
177
- syncer.send(:repository_object).should == container
178
- end
179
- end
180
- end
181
- end
@@ -1,174 +0,0 @@
1
- # encoding: utf-8
2
- require File.expand_path('../../../spec_helper.rb', __FILE__)
3
-
4
- describe 'Backup::Syncer::Cloud::S3' do
5
- let(:syncer) do
6
- Backup::Syncer::Cloud::S3.new do |s3|
7
- s3.access_key_id = 'my_access_key_id'
8
- s3.secret_access_key = 'my_secret_access_key'
9
- s3.bucket = 'my_bucket'
10
- s3.region = 'my_region'
11
- end
12
- end
13
-
14
- it 'should be a subclass of Syncer::Cloud::Base' do
15
- Backup::Syncer::Cloud::S3.
16
- superclass.should == Backup::Syncer::Cloud::Base
17
- end
18
-
19
- describe '#initialize' do
20
- after { Backup::Syncer::Cloud::S3.clear_defaults! }
21
-
22
- it 'should load pre-configured defaults through Syncer::Cloud::Base' do
23
- Backup::Syncer::Cloud::S3.any_instance.expects(:load_defaults!)
24
- syncer
25
- end
26
-
27
- it 'should strip any leading slash in path' do
28
- syncer = Backup::Syncer::Cloud::S3.new do |cloud|
29
- cloud.path = '/cleaned/path'
30
- end
31
- syncer.path.should == 'cleaned/path'
32
- end
33
-
34
- context 'when no pre-configured defaults have been set' do
35
- it 'should use the values given' do
36
- syncer.access_key_id.should == 'my_access_key_id'
37
- syncer.secret_access_key.should == 'my_secret_access_key'
38
- syncer.bucket.should == 'my_bucket'
39
- syncer.region.should == 'my_region'
40
- end
41
-
42
- it 'should use default values if none are given' do
43
- syncer = Backup::Syncer::Cloud::S3.new
44
-
45
- # from Syncer::Base
46
- syncer.path.should == 'backups'
47
- syncer.mirror.should == false
48
- syncer.directories.should == []
49
-
50
- # from Syncer::Cloud::Base
51
- syncer.concurrency_type.should == false
52
- syncer.concurrency_level.should == 2
53
-
54
- syncer.access_key_id.should be_nil
55
- syncer.secret_access_key.should be_nil
56
- syncer.bucket.should be_nil
57
- syncer.region.should be_nil
58
- end
59
- end # context 'when no pre-configured defaults have been set'
60
-
61
- context 'when pre-configured defaults have been set' do
62
- before do
63
- Backup::Syncer::Cloud::S3.defaults do |cloud|
64
- cloud.access_key_id = 'default_access_key_id'
65
- cloud.secret_access_key = 'default_secret_access_key'
66
- cloud.bucket = 'default_bucket'
67
- cloud.region = 'default_region'
68
- end
69
- end
70
-
71
- it 'should use pre-configured defaults' do
72
- syncer = Backup::Syncer::Cloud::S3.new
73
-
74
- # from Syncer::Base
75
- syncer.path.should == 'backups'
76
- syncer.mirror.should == false
77
- syncer.directories.should == []
78
-
79
- # from Syncer::Cloud::Base
80
- syncer.concurrency_type.should == false
81
- syncer.concurrency_level.should == 2
82
-
83
- syncer.access_key_id.should == 'default_access_key_id'
84
- syncer.secret_access_key.should == 'default_secret_access_key'
85
- syncer.bucket.should == 'default_bucket'
86
- syncer.region.should == 'default_region'
87
- end
88
-
89
- it 'should override pre-configured defaults' do
90
- syncer = Backup::Syncer::Cloud::S3.new do |cloud|
91
- cloud.path = 'new_path'
92
- cloud.mirror = 'new_mirror'
93
- cloud.concurrency_type = 'new_concurrency_type'
94
- cloud.concurrency_level = 'new_concurrency_level'
95
-
96
- cloud.access_key_id = 'new_access_key_id'
97
- cloud.secret_access_key = 'new_secret_access_key'
98
- cloud.bucket = 'new_bucket'
99
- cloud.region = 'new_region'
100
- end
101
-
102
- syncer.path.should == 'new_path'
103
- syncer.mirror.should == 'new_mirror'
104
- syncer.directories.should == []
105
- syncer.concurrency_type.should == 'new_concurrency_type'
106
- syncer.concurrency_level.should == 'new_concurrency_level'
107
-
108
- syncer.access_key_id.should == 'new_access_key_id'
109
- syncer.secret_access_key.should == 'new_secret_access_key'
110
- syncer.bucket.should == 'new_bucket'
111
- syncer.region.should == 'new_region'
112
- end
113
- end # context 'when pre-configured defaults have been set'
114
- end # describe '#initialize'
115
-
116
- describe '#connection' do
117
- let(:connection) { mock }
118
-
119
- before do
120
- Fog::Storage.expects(:new).once.with(
121
- :provider => 'AWS',
122
- :aws_access_key_id => 'my_access_key_id',
123
- :aws_secret_access_key => 'my_secret_access_key',
124
- :region => 'my_region'
125
- ).returns(connection)
126
- end
127
-
128
- it 'should establish and re-use the connection' do
129
- syncer.send(:connection).should == connection
130
- syncer.instance_variable_get(:@connection).should == connection
131
- syncer.send(:connection).should == connection
132
- end
133
- end
134
-
135
- describe '#repository_object' do
136
- let(:connection) { mock }
137
- let(:directories) { mock }
138
- let(:bucket) { mock }
139
-
140
- before do
141
- syncer.stubs(:connection).returns(connection)
142
- connection.stubs(:directories).returns(directories)
143
- end
144
-
145
- context 'when the @bucket does not exist' do
146
- before do
147
- directories.expects(:get).once.with('my_bucket').returns(nil)
148
- directories.expects(:create).once.with(
149
- :key => 'my_bucket',
150
- :location => 'my_region'
151
- ).returns(bucket)
152
- end
153
-
154
- it 'should create and re-use the bucket' do
155
- syncer.send(:repository_object).should == bucket
156
- syncer.instance_variable_get(:@repository_object).should == bucket
157
- syncer.send(:repository_object).should == bucket
158
- end
159
- end
160
-
161
- context 'when the @bucket does exist' do
162
- before do
163
- directories.expects(:get).once.with('my_bucket').returns(bucket)
164
- directories.expects(:create).never
165
- end
166
-
167
- it 'should retrieve and re-use the bucket' do
168
- syncer.send(:repository_object).should == bucket
169
- syncer.instance_variable_get(:@repository_object).should == bucket
170
- syncer.send(:repository_object).should == bucket
171
- end
172
- end
173
- end
174
- end
@@ -1,98 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path('../../../spec_helper.rb', __FILE__)
4
-
5
- describe 'Backup::Syncer::RSync::Base' do
6
- let(:syncer) { Backup::Syncer::RSync::Base.new }
7
-
8
- it 'should be a subclass of Syncer::Base' do
9
- Backup::Syncer::RSync::Base.
10
- superclass.should == Backup::Syncer::Base
11
- end
12
-
13
- describe '#initialize' do
14
- after { Backup::Syncer::RSync::Base.clear_defaults! }
15
-
16
- it 'should load pre-configured defaults through Syncer::Base' do
17
- Backup::Syncer::RSync::Base.any_instance.expects(:load_defaults!)
18
- syncer
19
- end
20
-
21
- context 'when no pre-configured defaults have been set' do
22
- it 'should use default values' do
23
- syncer.path.should == 'backups'
24
- syncer.mirror.should == false
25
- syncer.directories.should == []
26
- syncer.additional_options.should == []
27
- end
28
- end # context 'when no pre-configured defaults have been set'
29
-
30
- context 'when pre-configured defaults have been set' do
31
- before do
32
- Backup::Syncer::RSync::Base.defaults do |rsync|
33
- rsync.path = 'some_path'
34
- rsync.mirror = 'some_mirror'
35
- rsync.additional_options = 'some_additional_options'
36
- end
37
- end
38
-
39
- it 'should use pre-configured defaults' do
40
- syncer.path.should == 'some_path'
41
- syncer.mirror.should == 'some_mirror'
42
- syncer.directories.should == []
43
- syncer.additional_options.should == 'some_additional_options'
44
- end
45
- end # context 'when pre-configured defaults have been set'
46
- end # describe '#initialize'
47
-
48
- describe '#directory_options' do
49
- before do
50
- syncer.instance_variable_set(
51
- :@directories, ['/some/directory', '/another/directory']
52
- )
53
- end
54
-
55
- it 'should return the directories for use in the command line' do
56
- syncer.send(:directories_option).should ==
57
- "'/some/directory' '/another/directory'"
58
- end
59
-
60
- context 'when @directories have relative paths' do
61
- before do
62
- syncer.instance_variable_set(
63
- :@directories, ['/some/directory', '/another/directory',
64
- 'relative/path', '~/home/path']
65
- )
66
- end
67
- it 'should expand relative paths' do
68
- syncer.send(:directories_option).should ==
69
- "'/some/directory' '/another/directory' " +
70
- "'#{ File.expand_path('relative/path') }' " +
71
- "'#{ File.expand_path('~/home/path') }'"
72
- end
73
- end
74
- end
75
-
76
- describe '#mirror_option' do
77
- context 'when @mirror is true' do
78
- before { syncer.mirror = true }
79
- it 'should return the command line flag for mirroring' do
80
- syncer.send(:mirror_option).should == '--delete'
81
- end
82
- end
83
-
84
- context 'when @mirror is false' do
85
- before { syncer.mirror = false }
86
- it 'should return nil' do
87
- syncer.send(:mirror_option).should be_nil
88
- end
89
- end
90
- end
91
-
92
- describe '#archive_option' do
93
- it 'should return the command line flag for archiving' do
94
- syncer.send(:archive_option).should == '--archive'
95
- end
96
- end
97
-
98
- end