sweety_backy 0.0.15 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +13 -5
- data/lib/sweety_backy.rb +2 -2
- data/lib/sweety_backy/s3.rb +14 -16
- data/lib/sweety_backy/version.rb +1 -1
- data/sweety_backy.gemspec +1 -1
- data/test/s3/commander_s3_test.rb +3 -4
- data/test/s3/runner_s3_test.rb +11 -12
- data/test/s3/s3_test.rb +6 -7
- metadata +5 -5
data/Gemfile.lock
CHANGED
@@ -1,20 +1,28 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sweety_backy (0.0.
|
5
|
-
|
4
|
+
sweety_backy (0.0.15)
|
5
|
+
aws-sdk
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
+
aws-sdk (1.1.1)
|
11
|
+
httparty (~> 0.7)
|
12
|
+
json (~> 1.4)
|
13
|
+
nokogiri (>= 1.4.4)
|
14
|
+
uuidtools (~> 2.1)
|
10
15
|
chronic (0.6.2)
|
16
|
+
crack (0.1.8)
|
11
17
|
delorean (1.1.0)
|
12
18
|
chronic
|
19
|
+
httparty (0.7.8)
|
20
|
+
crack (= 0.1.8)
|
21
|
+
json (1.5.3)
|
13
22
|
mocha (0.9.12)
|
14
|
-
|
23
|
+
nokogiri (1.5.0)
|
15
24
|
rake (0.9.2)
|
16
|
-
|
17
|
-
proxies (~> 0.2.0)
|
25
|
+
uuidtools (2.1.2)
|
18
26
|
|
19
27
|
PLATFORMS
|
20
28
|
ruby
|
data/lib/sweety_backy.rb
CHANGED
data/lib/sweety_backy/s3.rb
CHANGED
@@ -1,32 +1,30 @@
|
|
1
1
|
module SweetyBacky
|
2
2
|
class S3
|
3
|
-
def self.upload( path,
|
4
|
-
SweetyBacky::Utils.log( "S3 uploading: #{path} to #{opts[:bucket]}/#{
|
3
|
+
def self.upload( path, s3_path, opts )
|
4
|
+
SweetyBacky::Utils.log( "S3 uploading: #{path} to #{opts[:bucket]}/#{s3_path}" )
|
5
5
|
|
6
|
-
s3 = ::S3
|
7
|
-
bucket = s3.
|
6
|
+
s3 = AWS::S3.new( read_s3_password( opts[:passwd_file] ) )
|
7
|
+
bucket = s3.buckets[ opts[:bucket] ]
|
8
8
|
|
9
9
|
if !bucket.exists?
|
10
|
-
bucket = s3.buckets.
|
11
|
-
bucket.save
|
10
|
+
bucket = s3.buckets.create( opts[:bucket] )
|
12
11
|
end
|
13
12
|
|
14
|
-
object = bucket.objects.
|
15
|
-
object.
|
16
|
-
object.save
|
13
|
+
object = bucket.objects.create( s3_path )
|
14
|
+
object.write( :file => path )
|
17
15
|
end
|
18
16
|
|
19
17
|
def self.object( path, opts )
|
20
|
-
s3 = ::S3
|
21
|
-
bucket = s3.buckets
|
22
|
-
object = bucket.objects
|
18
|
+
s3 = AWS::S3.new( read_s3_password( opts[:passwd_file] ) )
|
19
|
+
bucket = s3.buckets[ opts[:bucket] ]
|
20
|
+
object = bucket.objects[ path ]
|
23
21
|
|
24
|
-
|
22
|
+
object
|
25
23
|
end
|
26
24
|
|
27
25
|
def self.paths_in( path, opts )
|
28
|
-
s3 = ::S3
|
29
|
-
bucket = s3.buckets
|
26
|
+
s3 = AWS::S3.new( read_s3_password( opts[:passwd_file] ) )
|
27
|
+
bucket = s3.buckets[ opts[:bucket] ]
|
30
28
|
|
31
29
|
regex = Regexp.escape( path ).gsub('\*', '.*').gsub('\?', '.')
|
32
30
|
|
@@ -49,7 +47,7 @@ module SweetyBacky
|
|
49
47
|
end
|
50
48
|
|
51
49
|
def self.delete( path, opts )
|
52
|
-
SweetyBacky::S3.object( path, opts ).
|
50
|
+
SweetyBacky::S3.object( path, opts ).delete
|
53
51
|
end
|
54
52
|
|
55
53
|
end
|
data/lib/sweety_backy/version.rb
CHANGED
data/sweety_backy.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.add_development_dependency "delorean"
|
19
19
|
s.add_development_dependency "rake"
|
20
20
|
|
21
|
-
s.add_dependency "
|
21
|
+
s.add_dependency "aws-sdk"
|
22
22
|
|
23
23
|
s.files = `git ls-files`.split("\n")
|
24
24
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -21,14 +21,13 @@ class CommanderS3Test < Test::Unit::TestCase
|
|
21
21
|
:working_path => @tmp_dir
|
22
22
|
}
|
23
23
|
|
24
|
-
s3 = ::S3
|
24
|
+
s3 = AWS::S3.new( SweetyBacky::S3.read_s3_password( @opts[:s3_opts][:passwd_file] ) )
|
25
25
|
|
26
|
-
@bucket = s3.buckets.
|
27
|
-
@bucket.save
|
26
|
+
@bucket = s3.buckets.create( @opts[:s3_opts][:bucket] )
|
28
27
|
end
|
29
28
|
|
30
29
|
def teardown
|
31
|
-
@bucket.
|
30
|
+
@bucket.delete!
|
32
31
|
end
|
33
32
|
|
34
33
|
def test_clean
|
data/test/s3/runner_s3_test.rb
CHANGED
@@ -26,13 +26,12 @@ class RunnerS3Test < Test::Unit::TestCase
|
|
26
26
|
@runner = SweetyBacky::Runner.new
|
27
27
|
@runner.config( @opts )
|
28
28
|
|
29
|
-
s3 = ::S3
|
30
|
-
@bucket = s3.buckets.
|
31
|
-
@bucket.save
|
29
|
+
s3 = AWS::S3.new( SweetyBacky::S3.read_s3_password( @opts[:s3_opts][:passwd_file] ) )
|
30
|
+
@bucket = s3.buckets.create( @opts[:s3_opts][:bucket] )
|
32
31
|
end
|
33
32
|
|
34
33
|
def teardown
|
35
|
-
@bucket.
|
34
|
+
@bucket.delete!
|
36
35
|
end
|
37
36
|
|
38
37
|
def test_do_backup_daily
|
@@ -42,30 +41,30 @@ class RunnerS3Test < Test::Unit::TestCase
|
|
42
41
|
|
43
42
|
assert(
|
44
43
|
@bucket.
|
45
|
-
|
44
|
+
objects[
|
46
45
|
"test/path/files/#{SweetyBacky::Utils.namerize( @opts[:paths][0] )}.#{Date.today.strftime('%Y%m%d')}.daily.tar.gz"
|
47
|
-
|
46
|
+
].exists?
|
48
47
|
)
|
49
48
|
|
50
49
|
assert(
|
51
50
|
@bucket.
|
52
|
-
|
51
|
+
objects[
|
53
52
|
"test/path/databases/test.#{Date.today.strftime('%Y%m%d')}.daily.sql.tar.gz"
|
54
|
-
|
53
|
+
].exists?
|
55
54
|
)
|
56
55
|
|
57
56
|
assert(
|
58
57
|
@bucket.
|
59
|
-
|
58
|
+
objects[
|
60
59
|
"test/path/files/#{SweetyBacky::Utils.namerize( @opts[:paths][0] )}.#{Date.today.strftime('%Y%m%d')}.daily.tar.gz.md5"
|
61
|
-
|
60
|
+
].exists?
|
62
61
|
)
|
63
62
|
|
64
63
|
assert(
|
65
64
|
@bucket.
|
66
|
-
|
65
|
+
objects[
|
67
66
|
"test/path/databases/test.#{Date.today.strftime('%Y%m%d')}.daily.sql.tar.gz.md5"
|
68
|
-
|
67
|
+
].exists?
|
69
68
|
)
|
70
69
|
end
|
71
70
|
|
data/test/s3/s3_test.rb
CHANGED
@@ -11,13 +11,12 @@ class S3Test < Test::Unit::TestCase
|
|
11
11
|
:passwd_file => '~/.s3.passwd'
|
12
12
|
}
|
13
13
|
|
14
|
-
s3 = ::S3
|
15
|
-
@bucket = s3.buckets.
|
16
|
-
@bucket.save
|
14
|
+
s3 = AWS::S3.new( SweetyBacky::S3.read_s3_password( @opts[:passwd_file] ) )
|
15
|
+
@bucket = s3.buckets.create( @opts[:bucket] )
|
17
16
|
end
|
18
17
|
|
19
18
|
def teardown
|
20
|
-
@bucket.
|
19
|
+
@bucket.delete!
|
21
20
|
end
|
22
21
|
|
23
22
|
def test_upload
|
@@ -29,7 +28,7 @@ class S3Test < Test::Unit::TestCase
|
|
29
28
|
|
30
29
|
assert_equal(
|
31
30
|
File.read( "#{FIXTURES_PATH}/file.txt" ),
|
32
|
-
SweetyBacky::S3.object( "test/path/file.txt", @opts ).
|
31
|
+
SweetyBacky::S3.object( "test/path/file.txt", @opts ).read
|
33
32
|
)
|
34
33
|
end
|
35
34
|
|
@@ -54,8 +53,8 @@ class S3Test < Test::Unit::TestCase
|
|
54
53
|
|
55
54
|
SweetyBacky::S3.delete( "test/path/file2.txt", @opts )
|
56
55
|
|
57
|
-
assert( @bucket.
|
58
|
-
assert( !@bucket.
|
56
|
+
assert( @bucket.objects[ "test/path/file1.txt" ].exists? )
|
57
|
+
assert( !@bucket.objects[ "test/path/file2.txt" ].exists? )
|
59
58
|
end
|
60
59
|
|
61
60
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sweety_backy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 61
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 17
|
10
|
+
version: 0.0.17
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Fernando Guillen
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-08-
|
18
|
+
date: 2011-08-23 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -79,7 +79,7 @@ dependencies:
|
|
79
79
|
type: :development
|
80
80
|
version_requirements: *id004
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
|
-
name:
|
82
|
+
name: aws-sdk
|
83
83
|
prerelease: false
|
84
84
|
requirement: &id005 !ruby/object:Gem::Requirement
|
85
85
|
none: false
|