astrails-safe 0.1.8 → 0.1.9
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.
- data/VERSION.yml +1 -1
- data/examples/unit/gpg_example.rb +8 -8
- data/examples/unit/s3_example.rb +58 -4
- data/lib/astrails/safe/s3.rb +1 -1
- metadata +2 -2
data/VERSION.yml
CHANGED
|
@@ -12,8 +12,8 @@ describe Astrails::Safe::Gpg do
|
|
|
12
12
|
|
|
13
13
|
def gpg(config = {}, backup = def_backup)
|
|
14
14
|
Astrails::Safe::Gpg.new(
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
Astrails::Safe::Config::Node.new(nil, config),
|
|
16
|
+
Astrails::Safe::Backup.new(backup)
|
|
17
17
|
)
|
|
18
18
|
end
|
|
19
19
|
|
|
@@ -33,17 +33,17 @@ describe Astrails::Safe::Gpg do
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
it "should add .gpg extension" do
|
|
36
|
-
mock(@backup.extension) << '.gpg'
|
|
36
|
+
mock(@gpg.backup.extension) << '.gpg'
|
|
37
37
|
@gpg.process
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it "should add command pipe" do
|
|
41
|
-
mock(@backup.command) << (/\|gpg -BLAH/)
|
|
41
|
+
mock(@gpg.backup.command) << (/\|gpg -BLAH/)
|
|
42
42
|
@gpg.process
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it "should set compressed" do
|
|
46
|
-
mock(@backup).compressed = true
|
|
46
|
+
mock(@gpg.backup).compressed = true
|
|
47
47
|
@gpg.process
|
|
48
48
|
end
|
|
49
49
|
end
|
|
@@ -54,17 +54,17 @@ describe Astrails::Safe::Gpg do
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
it "should not touch extension" do
|
|
57
|
-
dont_allow(@backup.extension) << anything
|
|
57
|
+
dont_allow(@gpg.backup.extension) << anything
|
|
58
58
|
@gpg.process
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
it "should not touch command" do
|
|
62
|
-
dont_allow(@backup.command) << anything
|
|
62
|
+
dont_allow(@gpg.backup.command) << anything
|
|
63
63
|
@gpg.process
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
it "should not touch compressed" do
|
|
67
|
-
dont_allow(@backup).compressed = anything
|
|
67
|
+
dont_allow(@gpg.backup).compressed = anything
|
|
68
68
|
@gpg.process
|
|
69
69
|
end
|
|
70
70
|
end
|
data/examples/unit/s3_example.rb
CHANGED
|
@@ -2,6 +2,64 @@ require File.expand_path(File.dirname(__FILE__) + '/../example_helper')
|
|
|
2
2
|
|
|
3
3
|
describe Astrails::Safe::S3 do
|
|
4
4
|
|
|
5
|
+
def def_config
|
|
6
|
+
{
|
|
7
|
+
:s3 => {
|
|
8
|
+
:bucket => "_bucket",
|
|
9
|
+
:key => "_key",
|
|
10
|
+
:secret => "_secret",
|
|
11
|
+
:path => "s3_path"
|
|
12
|
+
},
|
|
13
|
+
:keep => {
|
|
14
|
+
:s3 => 2
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def def_backup
|
|
20
|
+
{
|
|
21
|
+
:kind => "_kind",
|
|
22
|
+
:filename => "/backup/somewhere/_kind-_id.NOW.bar",
|
|
23
|
+
:extension => ".bar",
|
|
24
|
+
:id => "_id",
|
|
25
|
+
:timestamp => "NOW"
|
|
26
|
+
}
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def s3(config = def_config, backup = def_backup)
|
|
30
|
+
Astrails::Safe::S3.new(
|
|
31
|
+
Astrails::Safe::Config::Node.new(nil, config),
|
|
32
|
+
Astrails::Safe::Backup.new(backup)
|
|
33
|
+
)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe :cleanup do
|
|
37
|
+
|
|
38
|
+
before(:each) do
|
|
39
|
+
@s3 = s3
|
|
40
|
+
|
|
41
|
+
@files = [4,1,3,2].to_a.map { |i| stub(o = {}).key {"aaaaa#{i}"}; o }
|
|
42
|
+
|
|
43
|
+
stub(AWS::S3::Bucket).objects("_bucket", :prefix => "s3_path/_kind-_id", :max_keys => 4) {@files}
|
|
44
|
+
stub(AWS::S3::Bucket).find("_bucket").stub![anything].stub!.delete
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "should check [:keep, :s3]" do
|
|
48
|
+
mock(@s3.config).[](:keep, :s3) {nil}
|
|
49
|
+
dont_allow(@s3.backup).filename
|
|
50
|
+
@s3.send :cleanup
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "should delete extra files" do
|
|
54
|
+
mock(AWS::S3::Bucket).find("_bucket").mock!["aaaaa1"].mock!.delete
|
|
55
|
+
mock(AWS::S3::Bucket).find("_bucket").mock!["aaaaa2"].mock!.delete
|
|
56
|
+
@s3.send :cleanup
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "should have more tests"
|
|
60
|
+
|
|
61
|
+
end
|
|
62
|
+
|
|
5
63
|
describe :active do
|
|
6
64
|
it "should be true when all params are set"
|
|
7
65
|
it "should be false if bucket is missing"
|
|
@@ -21,8 +79,4 @@ describe Astrails::Safe::S3 do
|
|
|
21
79
|
it "should open local file"
|
|
22
80
|
it "should upload file"
|
|
23
81
|
end
|
|
24
|
-
|
|
25
|
-
describe :cleanup do
|
|
26
|
-
it "should have some tests"
|
|
27
|
-
end
|
|
28
82
|
end
|
data/lib/astrails/safe/s3.rb
CHANGED
|
@@ -33,7 +33,7 @@ module Astrails
|
|
|
33
33
|
|
|
34
34
|
return unless keep = @config[:keep, :s3]
|
|
35
35
|
|
|
36
|
-
base = File.basename(filename).split(".").first
|
|
36
|
+
base = File.basename(@backup.filename).split(".").first
|
|
37
37
|
|
|
38
38
|
puts "listing files in #{bucket}:#{prefix}/#{base}"
|
|
39
39
|
files = AWS::S3::Bucket.objects(bucket, :prefix => "#{prefix}/#{base}", :max_keys => keep * 2)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: astrails-safe
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Astrails Ltd.
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date: 2009-05-
|
|
13
|
+
date: 2009-05-22 00:00:00 -07:00
|
|
14
14
|
default_executable: astrails-safe
|
|
15
15
|
dependencies:
|
|
16
16
|
- !ruby/object:Gem::Dependency
|