backup 3.0.27 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.md +1 -1
- data/README.md +139 -386
- data/bin/backup +1 -7
- data/lib/backup.rb +3 -9
- data/lib/backup/archive.rb +26 -20
- data/lib/backup/cleaner.rb +2 -2
- data/lib/backup/cli.rb +366 -0
- data/lib/backup/compressor/base.rb +2 -2
- data/lib/backup/compressor/gzip.rb +35 -1
- data/lib/backup/config.rb +1 -2
- data/lib/backup/database/base.rb +2 -2
- data/lib/backup/database/mongodb.rb +3 -3
- data/lib/backup/database/mysql.rb +3 -2
- data/lib/backup/database/postgresql.rb +3 -2
- data/lib/backup/database/riak.rb +18 -5
- data/lib/backup/dependency.rb +144 -93
- data/lib/backup/encryptor/base.rb +2 -2
- data/lib/backup/logger.rb +108 -110
- data/lib/backup/logger/console.rb +51 -0
- data/lib/backup/logger/logfile.rb +113 -0
- data/lib/backup/logger/syslog.rb +116 -0
- data/lib/backup/model.rb +67 -65
- data/lib/backup/notifier/base.rb +1 -1
- data/lib/backup/notifier/hipchat.rb +1 -1
- data/lib/backup/notifier/mail.rb +1 -1
- data/lib/backup/notifier/pushover.rb +6 -3
- data/lib/backup/packager.rb +4 -4
- data/lib/backup/pipeline.rb +17 -3
- data/lib/backup/splitter.rb +2 -2
- data/lib/backup/storage/base.rb +2 -2
- data/lib/backup/storage/cloudfiles.rb +2 -2
- data/lib/backup/storage/dropbox.rb +4 -4
- data/lib/backup/storage/ftp.rb +2 -2
- data/lib/backup/storage/local.rb +2 -2
- data/lib/backup/storage/ninefold.rb +2 -2
- data/lib/backup/storage/rsync.rb +3 -3
- data/lib/backup/storage/s3.rb +2 -2
- data/lib/backup/storage/scp.rb +2 -6
- data/lib/backup/storage/sftp.rb +2 -5
- data/lib/backup/syncer/base.rb +1 -1
- data/lib/backup/syncer/cloud/base.rb +15 -8
- data/lib/backup/syncer/rsync/local.rb +1 -1
- data/lib/backup/syncer/rsync/pull.rb +1 -1
- data/lib/backup/syncer/rsync/push.rb +1 -1
- data/lib/backup/utilities.rb +211 -0
- data/lib/backup/version.rb +1 -1
- data/templates/cli/{utility/archive → archive} +4 -8
- data/templates/cli/{utility/compressor → compressor}/bzip2 +0 -0
- data/templates/cli/{utility/compressor → compressor}/custom +0 -0
- data/templates/cli/{utility/compressor → compressor}/gzip +0 -0
- data/templates/cli/{utility/compressor → compressor}/lzma +0 -0
- data/templates/cli/{utility/compressor → compressor}/pbzip2 +0 -0
- data/templates/cli/config +68 -0
- data/templates/cli/{utility/database → database}/mongodb +1 -1
- data/templates/cli/{utility/database → database}/mysql +1 -1
- data/templates/cli/{utility/database → database}/postgresql +1 -1
- data/templates/cli/{utility/database → database}/redis +0 -0
- data/templates/cli/database/riak +20 -0
- data/templates/cli/{utility/encryptor → encryptor}/gpg +0 -0
- data/templates/cli/{utility/encryptor → encryptor}/openssl +0 -0
- data/templates/cli/{utility/model.erb → model.erb} +4 -4
- data/templates/cli/{utility/notifier → notifier}/campfire +0 -0
- data/templates/cli/{utility/notifier → notifier}/hipchat +0 -0
- data/templates/cli/{utility/notifier → notifier}/mail +0 -0
- data/templates/cli/{utility/notifier → notifier}/prowl +0 -0
- data/templates/cli/{utility/notifier → notifier}/pushover +0 -0
- data/templates/cli/{utility/notifier → notifier}/twitter +0 -0
- data/templates/cli/{utility/splitter → splitter} +0 -0
- data/templates/cli/{utility/storage → storage}/cloud_files +0 -0
- data/templates/cli/{utility/storage → storage}/dropbox +0 -0
- data/templates/cli/{utility/storage → storage}/ftp +0 -0
- data/templates/cli/{utility/storage → storage}/local +0 -0
- data/templates/cli/{utility/storage → storage}/ninefold +0 -0
- data/templates/cli/{utility/storage → storage}/rsync +0 -0
- data/templates/cli/{utility/storage → storage}/s3 +0 -0
- data/templates/cli/{utility/storage → storage}/scp +0 -0
- data/templates/cli/{utility/storage → storage}/sftp +0 -0
- data/templates/cli/{utility/syncer → syncer}/cloud_files +0 -0
- data/templates/cli/{utility/syncer → syncer}/rsync_local +0 -0
- data/templates/cli/{utility/syncer → syncer}/rsync_pull +0 -0
- data/templates/cli/{utility/syncer → syncer}/rsync_push +0 -0
- data/templates/cli/{utility/syncer → syncer}/s3 +0 -0
- metadata +55 -131
- data/.gitignore +0 -8
- data/.travis.yml +0 -10
- data/Gemfile +0 -28
- data/Guardfile +0 -23
- data/backup.gemspec +0 -32
- data/lib/backup/cli/helpers.rb +0 -93
- data/lib/backup/cli/utility.rb +0 -255
- data/spec-live/.gitignore +0 -6
- data/spec-live/README +0 -7
- data/spec-live/backups/config.rb +0 -83
- data/spec-live/backups/config.yml.template +0 -46
- data/spec-live/backups/models.rb +0 -184
- data/spec-live/compressor/custom_spec.rb +0 -30
- data/spec-live/compressor/gzip_spec.rb +0 -30
- data/spec-live/encryptor/gpg_keys.rb +0 -239
- data/spec-live/encryptor/gpg_spec.rb +0 -287
- data/spec-live/notifier/mail_spec.rb +0 -121
- data/spec-live/spec_helper.rb +0 -151
- data/spec-live/storage/dropbox_spec.rb +0 -151
- data/spec-live/storage/local_spec.rb +0 -83
- data/spec-live/storage/scp_spec.rb +0 -193
- data/spec-live/syncer/cloud/s3_spec.rb +0 -124
- data/spec/archive_spec.rb +0 -335
- data/spec/cleaner_spec.rb +0 -312
- data/spec/cli/helpers_spec.rb +0 -301
- data/spec/cli/utility_spec.rb +0 -411
- data/spec/compressor/base_spec.rb +0 -52
- data/spec/compressor/bzip2_spec.rb +0 -217
- data/spec/compressor/custom_spec.rb +0 -106
- data/spec/compressor/gzip_spec.rb +0 -217
- data/spec/compressor/lzma_spec.rb +0 -123
- data/spec/compressor/pbzip2_spec.rb +0 -165
- data/spec/config_spec.rb +0 -321
- data/spec/configuration/helpers_spec.rb +0 -247
- data/spec/configuration/store_spec.rb +0 -39
- data/spec/configuration_spec.rb +0 -62
- data/spec/database/base_spec.rb +0 -63
- data/spec/database/mongodb_spec.rb +0 -510
- data/spec/database/mysql_spec.rb +0 -411
- data/spec/database/postgresql_spec.rb +0 -353
- data/spec/database/redis_spec.rb +0 -334
- data/spec/database/riak_spec.rb +0 -176
- data/spec/dependency_spec.rb +0 -51
- data/spec/encryptor/base_spec.rb +0 -40
- data/spec/encryptor/gpg_spec.rb +0 -909
- data/spec/encryptor/open_ssl_spec.rb +0 -148
- data/spec/errors_spec.rb +0 -306
- data/spec/logger_spec.rb +0 -367
- data/spec/model_spec.rb +0 -666
- data/spec/notifier/base_spec.rb +0 -104
- data/spec/notifier/campfire_spec.rb +0 -217
- data/spec/notifier/hipchat_spec.rb +0 -211
- data/spec/notifier/mail_spec.rb +0 -316
- data/spec/notifier/prowl_spec.rb +0 -138
- data/spec/notifier/pushover_spec.rb +0 -123
- data/spec/notifier/twitter_spec.rb +0 -153
- data/spec/package_spec.rb +0 -61
- data/spec/packager_spec.rb +0 -213
- data/spec/pipeline_spec.rb +0 -259
- data/spec/spec_helper.rb +0 -60
- data/spec/splitter_spec.rb +0 -120
- data/spec/storage/base_spec.rb +0 -166
- data/spec/storage/cloudfiles_spec.rb +0 -254
- data/spec/storage/cycler_spec.rb +0 -247
- data/spec/storage/dropbox_spec.rb +0 -480
- data/spec/storage/ftp_spec.rb +0 -271
- data/spec/storage/local_spec.rb +0 -259
- data/spec/storage/ninefold_spec.rb +0 -343
- data/spec/storage/rsync_spec.rb +0 -362
- data/spec/storage/s3_spec.rb +0 -245
- data/spec/storage/scp_spec.rb +0 -233
- data/spec/storage/sftp_spec.rb +0 -244
- data/spec/syncer/base_spec.rb +0 -109
- data/spec/syncer/cloud/base_spec.rb +0 -515
- data/spec/syncer/cloud/cloud_files_spec.rb +0 -181
- data/spec/syncer/cloud/s3_spec.rb +0 -174
- data/spec/syncer/rsync/base_spec.rb +0 -98
- data/spec/syncer/rsync/local_spec.rb +0 -149
- data/spec/syncer/rsync/pull_spec.rb +0 -98
- data/spec/syncer/rsync/push_spec.rb +0 -333
- data/spec/version_spec.rb +0 -21
- data/templates/cli/utility/config +0 -32
- data/templates/cli/utility/database/riak +0 -11
@@ -1,52 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.expand_path('../../spec_helper.rb', __FILE__)
|
4
|
-
|
5
|
-
describe Backup::Compressor::Base do
|
6
|
-
let(:compressor) { Backup::Compressor::Base.new }
|
7
|
-
|
8
|
-
it 'should include CLI::Helpers' do
|
9
|
-
Backup::Compressor::Base.
|
10
|
-
include?(Backup::CLI::Helpers).should be_true
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should include Configuration::Helpers' do
|
14
|
-
Backup::Compressor::Base.
|
15
|
-
include?(Backup::Configuration::Helpers).should be_true
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '#compress_with' do
|
19
|
-
it 'should yield the compressor command and extension' do
|
20
|
-
compressor.instance_variable_set(:@cmd, 'compressor command')
|
21
|
-
compressor.instance_variable_set(:@ext, 'compressor extension')
|
22
|
-
|
23
|
-
compressor.expects(:log!)
|
24
|
-
|
25
|
-
compressor.compress_with do |cmd, ext|
|
26
|
-
cmd.should == 'compressor command'
|
27
|
-
ext.should == 'compressor extension'
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe '#compressor_name' do
|
33
|
-
it 'should return class name with Backup namespace removed' do
|
34
|
-
compressor.send(:compressor_name).should == 'Compressor::Base'
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe '#log!' do
|
39
|
-
it 'should log a message' do
|
40
|
-
compressor.instance_variable_set(:@cmd, 'compressor command')
|
41
|
-
compressor.instance_variable_set(:@ext, 'compressor extension')
|
42
|
-
compressor.expects(:compressor_name).returns('Compressor Name')
|
43
|
-
|
44
|
-
Backup::Logger.expects(:message).with(
|
45
|
-
"Using Compressor Name for compression.\n" +
|
46
|
-
" Command: 'compressor command'\n" +
|
47
|
-
" Ext: 'compressor extension'"
|
48
|
-
)
|
49
|
-
compressor.send(:log!)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,217 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.expand_path('../../spec_helper.rb', __FILE__)
|
4
|
-
|
5
|
-
describe Backup::Compressor::Bzip2 do
|
6
|
-
before do
|
7
|
-
Backup::Compressor::Bzip2.any_instance.stubs(:utility).returns('bzip2')
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'should be a subclass of Compressor::Base' do
|
11
|
-
Backup::Compressor::Bzip2.
|
12
|
-
superclass.should == Backup::Compressor::Base
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '#initialize' do
|
16
|
-
let(:compressor) { Backup::Compressor::Bzip2.new }
|
17
|
-
|
18
|
-
after { Backup::Compressor::Bzip2.clear_defaults! }
|
19
|
-
|
20
|
-
it 'should load pre-configured defaults' do
|
21
|
-
Backup::Compressor::Bzip2.any_instance.expects(:load_defaults!)
|
22
|
-
compressor
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'when no pre-configured defaults have been set' do
|
26
|
-
it 'should use default values' do
|
27
|
-
compressor.level.should be_false
|
28
|
-
|
29
|
-
compressor.instance_variable_get(:@cmd).should == 'bzip2'
|
30
|
-
compressor.instance_variable_get(:@ext).should == '.bz2'
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should use the values given' do
|
34
|
-
compressor = Backup::Compressor::Bzip2.new do |c|
|
35
|
-
c.level = 5
|
36
|
-
end
|
37
|
-
compressor.level.should == 5
|
38
|
-
|
39
|
-
compressor.instance_variable_get(:@cmd).should == 'bzip2 -5'
|
40
|
-
compressor.instance_variable_get(:@ext).should == '.bz2'
|
41
|
-
end
|
42
|
-
end # context 'when no pre-configured defaults have been set'
|
43
|
-
|
44
|
-
context 'when pre-configured defaults have been set' do
|
45
|
-
before do
|
46
|
-
Backup::Compressor::Bzip2.defaults do |c|
|
47
|
-
c.level = 7
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'should use pre-configured defaults' do
|
52
|
-
compressor.level.should == 7
|
53
|
-
|
54
|
-
compressor.instance_variable_get(:@cmd).should == 'bzip2 -7'
|
55
|
-
compressor.instance_variable_get(:@ext).should == '.bz2'
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'should override pre-configured defaults' do
|
59
|
-
compressor = Backup::Compressor::Bzip2.new do |c|
|
60
|
-
c.level = 6
|
61
|
-
end
|
62
|
-
compressor.level.should == 6
|
63
|
-
|
64
|
-
compressor.instance_variable_get(:@cmd).should == 'bzip2 -6'
|
65
|
-
compressor.instance_variable_get(:@ext).should == '.bz2'
|
66
|
-
end
|
67
|
-
end # context 'when pre-configured defaults have been set'
|
68
|
-
end # describe '#initialize'
|
69
|
-
|
70
|
-
describe 'deprecations' do
|
71
|
-
describe 'fast and best options' do
|
72
|
-
context 'when only the fast option is used' do
|
73
|
-
before do
|
74
|
-
Backup::Logger.expects(:warn).with {|err|
|
75
|
-
err.should be_an_instance_of Backup::Errors::ConfigurationError
|
76
|
-
err.message.should match(
|
77
|
-
/Use Bzip2#level instead/
|
78
|
-
)
|
79
|
-
}
|
80
|
-
end
|
81
|
-
|
82
|
-
context 'when set to true' do
|
83
|
-
it 'should log a warning and set `level` to 1' do
|
84
|
-
compressor = Backup::Compressor::Bzip2.new do |c|
|
85
|
-
c.fast = true
|
86
|
-
end
|
87
|
-
compressor.level.should == 1
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
context 'when set to false' do
|
92
|
-
it 'should only log a warning' do
|
93
|
-
compressor = Backup::Compressor::Bzip2.new do |c|
|
94
|
-
c.fast = false
|
95
|
-
end
|
96
|
-
compressor.level.should be_false
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
context 'when only the best option is used' do
|
102
|
-
before do
|
103
|
-
Backup::Logger.expects(:warn).with {|err|
|
104
|
-
err.should be_an_instance_of Backup::Errors::ConfigurationError
|
105
|
-
err.message.should match(
|
106
|
-
/Use Bzip2#level instead/
|
107
|
-
)
|
108
|
-
}
|
109
|
-
end
|
110
|
-
|
111
|
-
context 'when set to true' do
|
112
|
-
it 'should log a warning and set `level` to 1' do
|
113
|
-
compressor = Backup::Compressor::Bzip2.new do |c|
|
114
|
-
c.best = true
|
115
|
-
end
|
116
|
-
compressor.level.should == 9
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
context 'when set to false' do
|
121
|
-
it 'should only log a warning' do
|
122
|
-
compressor = Backup::Compressor::Bzip2.new do |c|
|
123
|
-
c.best = false
|
124
|
-
end
|
125
|
-
compressor.level.should be_false
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
|
-
context 'when both fast and best options are used' do
|
132
|
-
before do
|
133
|
-
Backup::Logger.expects(:warn).twice.with {|err|
|
134
|
-
err.should be_an_instance_of Backup::Errors::ConfigurationError
|
135
|
-
err.message.should match(
|
136
|
-
/Use Bzip2#level instead/
|
137
|
-
)
|
138
|
-
}
|
139
|
-
end
|
140
|
-
|
141
|
-
context 'when both are set true' do
|
142
|
-
context 'when fast is set first' do
|
143
|
-
it 'should cause the best option to be set' do
|
144
|
-
compressor = Backup::Compressor::Bzip2.new do |c|
|
145
|
-
c.fast = true
|
146
|
-
c.best = true
|
147
|
-
end
|
148
|
-
compressor.level.should == 9
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
context 'when best is set first' do
|
153
|
-
it 'should cause the fast option to be set' do
|
154
|
-
compressor = Backup::Compressor::Bzip2.new do |c|
|
155
|
-
c.best = true
|
156
|
-
c.fast = true
|
157
|
-
end
|
158
|
-
compressor.level.should == 1
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
context 'when only one is set true' do
|
164
|
-
context 'when fast is set true before best' do
|
165
|
-
it 'should cause the fast option to be set' do
|
166
|
-
compressor = Backup::Compressor::Bzip2.new do |c|
|
167
|
-
c.fast = true
|
168
|
-
c.best = false
|
169
|
-
end
|
170
|
-
compressor.level.should == 1
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
context 'when fast is set true after best' do
|
175
|
-
it 'should cause the fast option to be set' do
|
176
|
-
compressor = Backup::Compressor::Bzip2.new do |c|
|
177
|
-
c.best = false
|
178
|
-
c.fast = true
|
179
|
-
end
|
180
|
-
compressor.level.should == 1
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
context 'when best is set true before fast' do
|
185
|
-
it 'should cause the best option to be set' do
|
186
|
-
compressor = Backup::Compressor::Bzip2.new do |c|
|
187
|
-
c.best = true
|
188
|
-
c.fast = false
|
189
|
-
end
|
190
|
-
compressor.level.should == 9
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
context 'when best is set true after fast' do
|
195
|
-
it 'should cause the best option to be set' do
|
196
|
-
compressor = Backup::Compressor::Bzip2.new do |c|
|
197
|
-
c.fast = false
|
198
|
-
c.best = true
|
199
|
-
end
|
200
|
-
compressor.level.should == 9
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
context 'when both are set false' do
|
206
|
-
it 'should only issue the two warnings' do
|
207
|
-
compressor = Backup::Compressor::Bzip2.new do |c|
|
208
|
-
c.fast = false
|
209
|
-
c.best = false
|
210
|
-
end
|
211
|
-
compressor.level.should be_false
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
215
|
-
end # describe 'fast and best options'
|
216
|
-
end # describe 'deprecations'
|
217
|
-
end
|
@@ -1,106 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.expand_path('../../spec_helper.rb', __FILE__)
|
4
|
-
|
5
|
-
describe Backup::Compressor::Custom do
|
6
|
-
let(:compressor) { Backup::Compressor::Custom.new }
|
7
|
-
|
8
|
-
before(:all) do
|
9
|
-
# CLI::Helpers#utility will raise an error
|
10
|
-
# if the command is invalid or not set
|
11
|
-
Backup::Compressor::Custom.send(
|
12
|
-
:define_method, :utility,
|
13
|
-
lambda {|arg| arg.to_s.empty? ? 'error' : "/path/to/#{ arg }" }
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should be a subclass of Compressor::Base' do
|
18
|
-
Backup::Compressor::Custom.
|
19
|
-
superclass.should == Backup::Compressor::Base
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#initialize' do
|
23
|
-
let(:compressor) { Backup::Compressor::Custom.new }
|
24
|
-
|
25
|
-
after { Backup::Compressor::Custom.clear_defaults! }
|
26
|
-
|
27
|
-
it 'should load pre-configured defaults' do
|
28
|
-
Backup::Compressor::Custom.any_instance.expects(:load_defaults!)
|
29
|
-
compressor
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should call CLI::Helpers#utility to validate command' do
|
33
|
-
Backup::Compressor::Custom.any_instance.expects(:utility)
|
34
|
-
compressor
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'should clean the command and extension for use with compress_with' do
|
38
|
-
compressor = Backup::Compressor::Custom.new do |c|
|
39
|
-
c.command = ' my_command --option foo '
|
40
|
-
c.extension = ' my_extension '
|
41
|
-
end
|
42
|
-
|
43
|
-
compressor.command.should == ' my_command --option foo '
|
44
|
-
compressor.extension.should == ' my_extension '
|
45
|
-
|
46
|
-
compressor.expects(:log!)
|
47
|
-
compressor.compress_with do |cmd, ext|
|
48
|
-
cmd.should == '/path/to/my_command --option foo'
|
49
|
-
ext.should == 'my_extension'
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
context 'when no pre-configured defaults have been set' do
|
54
|
-
it 'should use default values' do
|
55
|
-
compressor.command.should be_nil
|
56
|
-
compressor.extension.should be_nil
|
57
|
-
|
58
|
-
compressor.instance_variable_get(:@cmd).should == 'error'
|
59
|
-
compressor.instance_variable_get(:@ext).should == ''
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'should use the values given' do
|
63
|
-
compressor = Backup::Compressor::Custom.new do |c|
|
64
|
-
c.command = 'my_command'
|
65
|
-
c.extension = 'my_extension'
|
66
|
-
end
|
67
|
-
|
68
|
-
compressor.command.should == 'my_command'
|
69
|
-
compressor.extension.should == 'my_extension'
|
70
|
-
|
71
|
-
compressor.instance_variable_get(:@cmd).should == '/path/to/my_command'
|
72
|
-
compressor.instance_variable_get(:@ext).should == 'my_extension'
|
73
|
-
end
|
74
|
-
end # context 'when no pre-configured defaults have been set'
|
75
|
-
|
76
|
-
context 'when pre-configured defaults have been set' do
|
77
|
-
before do
|
78
|
-
Backup::Compressor::Custom.defaults do |c|
|
79
|
-
c.command = 'default_command'
|
80
|
-
c.extension = 'default_extension'
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'should use pre-configured defaults' do
|
85
|
-
compressor.command.should == 'default_command'
|
86
|
-
compressor.extension.should == 'default_extension'
|
87
|
-
|
88
|
-
compressor.instance_variable_get(:@cmd).should == '/path/to/default_command'
|
89
|
-
compressor.instance_variable_get(:@ext).should == 'default_extension'
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'should override pre-configured defaults' do
|
93
|
-
compressor = Backup::Compressor::Custom.new do |c|
|
94
|
-
c.command = 'new_command'
|
95
|
-
c.extension = 'new_extension'
|
96
|
-
end
|
97
|
-
|
98
|
-
compressor.command.should == 'new_command'
|
99
|
-
compressor.extension.should == 'new_extension'
|
100
|
-
|
101
|
-
compressor.instance_variable_get(:@cmd).should == '/path/to/new_command'
|
102
|
-
compressor.instance_variable_get(:@ext).should == 'new_extension'
|
103
|
-
end
|
104
|
-
end # context 'when pre-configured defaults have been set'
|
105
|
-
end # describe '#initialize'
|
106
|
-
end
|
@@ -1,217 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require File.expand_path('../../spec_helper.rb', __FILE__)
|
4
|
-
|
5
|
-
describe Backup::Compressor::Gzip do
|
6
|
-
before do
|
7
|
-
Backup::Compressor::Gzip.any_instance.stubs(:utility).returns('gzip')
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'should be a subclass of Compressor::Base' do
|
11
|
-
Backup::Compressor::Gzip.
|
12
|
-
superclass.should == Backup::Compressor::Base
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '#initialize' do
|
16
|
-
let(:compressor) { Backup::Compressor::Gzip.new }
|
17
|
-
|
18
|
-
after { Backup::Compressor::Gzip.clear_defaults! }
|
19
|
-
|
20
|
-
it 'should load pre-configured defaults' do
|
21
|
-
Backup::Compressor::Gzip.any_instance.expects(:load_defaults!)
|
22
|
-
compressor
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'when no pre-configured defaults have been set' do
|
26
|
-
it 'should use default values' do
|
27
|
-
compressor.level.should be_false
|
28
|
-
|
29
|
-
compressor.instance_variable_get(:@cmd).should == 'gzip'
|
30
|
-
compressor.instance_variable_get(:@ext).should == '.gz'
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should use the values given' do
|
34
|
-
compressor = Backup::Compressor::Gzip.new do |c|
|
35
|
-
c.level = 5
|
36
|
-
end
|
37
|
-
compressor.level.should == 5
|
38
|
-
|
39
|
-
compressor.instance_variable_get(:@cmd).should == 'gzip -5'
|
40
|
-
compressor.instance_variable_get(:@ext).should == '.gz'
|
41
|
-
end
|
42
|
-
end # context 'when no pre-configured defaults have been set'
|
43
|
-
|
44
|
-
context 'when pre-configured defaults have been set' do
|
45
|
-
before do
|
46
|
-
Backup::Compressor::Gzip.defaults do |c|
|
47
|
-
c.level = 7
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'should use pre-configured defaults' do
|
52
|
-
compressor.level.should == 7
|
53
|
-
|
54
|
-
compressor.instance_variable_get(:@cmd).should == 'gzip -7'
|
55
|
-
compressor.instance_variable_get(:@ext).should == '.gz'
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'should override pre-configured defaults' do
|
59
|
-
compressor = Backup::Compressor::Gzip.new do |c|
|
60
|
-
c.level = 6
|
61
|
-
end
|
62
|
-
compressor.level.should == 6
|
63
|
-
|
64
|
-
compressor.instance_variable_get(:@cmd).should == 'gzip -6'
|
65
|
-
compressor.instance_variable_get(:@ext).should == '.gz'
|
66
|
-
end
|
67
|
-
end # context 'when pre-configured defaults have been set'
|
68
|
-
end # describe '#initialize'
|
69
|
-
|
70
|
-
describe 'deprecations' do
|
71
|
-
describe 'fast and best options' do
|
72
|
-
context 'when only the fast option is used' do
|
73
|
-
before do
|
74
|
-
Backup::Logger.expects(:warn).with {|err|
|
75
|
-
err.should be_an_instance_of Backup::Errors::ConfigurationError
|
76
|
-
err.message.should match(
|
77
|
-
/Use Gzip#level instead/
|
78
|
-
)
|
79
|
-
}
|
80
|
-
end
|
81
|
-
|
82
|
-
context 'when set to true' do
|
83
|
-
it 'should log a warning and set `level` to 1' do
|
84
|
-
compressor = Backup::Compressor::Gzip.new do |c|
|
85
|
-
c.fast = true
|
86
|
-
end
|
87
|
-
compressor.level.should == 1
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
context 'when set to false' do
|
92
|
-
it 'should only log a warning' do
|
93
|
-
compressor = Backup::Compressor::Gzip.new do |c|
|
94
|
-
c.fast = false
|
95
|
-
end
|
96
|
-
compressor.level.should be_false
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
context 'when only the best option is used' do
|
102
|
-
before do
|
103
|
-
Backup::Logger.expects(:warn).with {|err|
|
104
|
-
err.should be_an_instance_of Backup::Errors::ConfigurationError
|
105
|
-
err.message.should match(
|
106
|
-
/Use Gzip#level instead/
|
107
|
-
)
|
108
|
-
}
|
109
|
-
end
|
110
|
-
|
111
|
-
context 'when set to true' do
|
112
|
-
it 'should log a warning and set `level` to 1' do
|
113
|
-
compressor = Backup::Compressor::Gzip.new do |c|
|
114
|
-
c.best = true
|
115
|
-
end
|
116
|
-
compressor.level.should == 9
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
context 'when set to false' do
|
121
|
-
it 'should only log a warning' do
|
122
|
-
compressor = Backup::Compressor::Gzip.new do |c|
|
123
|
-
c.best = false
|
124
|
-
end
|
125
|
-
compressor.level.should be_false
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
|
-
context 'when both fast and best options are used' do
|
132
|
-
before do
|
133
|
-
Backup::Logger.expects(:warn).twice.with {|err|
|
134
|
-
err.should be_an_instance_of Backup::Errors::ConfigurationError
|
135
|
-
err.message.should match(
|
136
|
-
/Use Gzip#level instead/
|
137
|
-
)
|
138
|
-
}
|
139
|
-
end
|
140
|
-
|
141
|
-
context 'when both are set true' do
|
142
|
-
context 'when fast is set first' do
|
143
|
-
it 'should cause the best option to be set' do
|
144
|
-
compressor = Backup::Compressor::Gzip.new do |c|
|
145
|
-
c.fast = true
|
146
|
-
c.best = true
|
147
|
-
end
|
148
|
-
compressor.level.should == 9
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
context 'when best is set first' do
|
153
|
-
it 'should cause the fast option to be set' do
|
154
|
-
compressor = Backup::Compressor::Gzip.new do |c|
|
155
|
-
c.best = true
|
156
|
-
c.fast = true
|
157
|
-
end
|
158
|
-
compressor.level.should == 1
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
context 'when only one is set true' do
|
164
|
-
context 'when fast is set true before best' do
|
165
|
-
it 'should cause the fast option to be set' do
|
166
|
-
compressor = Backup::Compressor::Gzip.new do |c|
|
167
|
-
c.fast = true
|
168
|
-
c.best = false
|
169
|
-
end
|
170
|
-
compressor.level.should == 1
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
context 'when fast is set true after best' do
|
175
|
-
it 'should cause the fast option to be set' do
|
176
|
-
compressor = Backup::Compressor::Gzip.new do |c|
|
177
|
-
c.best = false
|
178
|
-
c.fast = true
|
179
|
-
end
|
180
|
-
compressor.level.should == 1
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
context 'when best is set true before fast' do
|
185
|
-
it 'should cause the best option to be set' do
|
186
|
-
compressor = Backup::Compressor::Gzip.new do |c|
|
187
|
-
c.best = true
|
188
|
-
c.fast = false
|
189
|
-
end
|
190
|
-
compressor.level.should == 9
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
context 'when best is set true after fast' do
|
195
|
-
it 'should cause the best option to be set' do
|
196
|
-
compressor = Backup::Compressor::Gzip.new do |c|
|
197
|
-
c.fast = false
|
198
|
-
c.best = true
|
199
|
-
end
|
200
|
-
compressor.level.should == 9
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
context 'when both are set false' do
|
206
|
-
it 'should only issue the two warnings' do
|
207
|
-
compressor = Backup::Compressor::Gzip.new do |c|
|
208
|
-
c.fast = false
|
209
|
-
c.best = false
|
210
|
-
end
|
211
|
-
compressor.level.should be_false
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
215
|
-
end # describe 'fast and best options'
|
216
|
-
end # describe 'deprecations'
|
217
|
-
end
|