blanket 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/blanket/init.rb +2 -0
- data/lib/blanket/plugins/sources/remote_directory.rb +65 -0
- data/lib/blanket/plugins/sources/single_file.rb +51 -0
- data/spec/confluence_spec.rb +4 -4
- data/spec/fixtures/s3-info.yml +1 -1
- data/spec/reader_spec.rb +9 -13
- data/spec/spec_helper.rb +1 -1
- data/spec/writer_spec.rb +6 -6
- metadata +3 -1
data/lib/blanket/init.rb
CHANGED
@@ -18,4 +18,6 @@ require File.dirname(__FILE__) + "/source.rb"
|
|
18
18
|
require File.dirname(__FILE__) + "/plugins/sources/confluence.rb"
|
19
19
|
require File.dirname(__FILE__) + "/plugins/sources/mysql.rb"
|
20
20
|
require File.dirname(__FILE__) + "/plugins/sources/subversion.rb"
|
21
|
+
require File.dirname(__FILE__) + "/plugins/sources/single_file.rb"
|
22
|
+
require File.dirname(__FILE__) + "/plugins/sources/remote_directory.rb"
|
21
23
|
require File.dirname(__FILE__) + "/plugins/sinks/s3.rb"
|
@@ -0,0 +1,65 @@
|
|
1
|
+
class RemoteDirectory < Source
|
2
|
+
|
3
|
+
def initialize(reader)
|
4
|
+
@reader = reader
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.attribute_symbols
|
8
|
+
[:source_type, :host, :user, :password, :remote_directory, :local_path ]
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.default_source_type
|
12
|
+
"Confluence"
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.default_host
|
16
|
+
"yourhost.com"
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.default_user
|
20
|
+
"username"
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.default_password
|
24
|
+
"password"
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.default_remote_directory
|
28
|
+
"/path/to/remote/target/directory"
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.default_local_path
|
32
|
+
"/path/to/local/blanket"
|
33
|
+
end
|
34
|
+
|
35
|
+
def remote_backup_path
|
36
|
+
full_tarfile+".gz"
|
37
|
+
end
|
38
|
+
|
39
|
+
def local_backup_path
|
40
|
+
local_path
|
41
|
+
end
|
42
|
+
|
43
|
+
def tar_directory
|
44
|
+
rp = Pathname.new(remote_directory)
|
45
|
+
rp.dirname.to_s
|
46
|
+
end
|
47
|
+
|
48
|
+
def tarfile
|
49
|
+
rp = Pathname.new(remote_directory)
|
50
|
+
rp.basename.to_s+".tar"
|
51
|
+
end
|
52
|
+
|
53
|
+
def full_tarfile
|
54
|
+
[tar_directory, tarfile].join("/")
|
55
|
+
end
|
56
|
+
|
57
|
+
def prep_command
|
58
|
+
"tar cvf #{full_tarfile} #{remote_directory}; gzip -f #{full_tarfile}"
|
59
|
+
end
|
60
|
+
|
61
|
+
def cleanup_command
|
62
|
+
noop
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class SingleFile < Source
|
2
|
+
|
3
|
+
def initialize(reader)
|
4
|
+
@reader = reader
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.attribute_symbols
|
8
|
+
[:source_type, :host, :user, :password, :remote_path, :local_path ]
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.default_source_type
|
12
|
+
"Confluence"
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.default_host
|
16
|
+
"yourhost.com"
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.default_user
|
20
|
+
"username"
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.default_password
|
24
|
+
"password"
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.default_remote_path
|
28
|
+
"/path/to/remote/target/file"
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.default_local_path
|
32
|
+
"/path/to/local/blanket"
|
33
|
+
end
|
34
|
+
|
35
|
+
def remote_backup_path
|
36
|
+
remote_path
|
37
|
+
end
|
38
|
+
|
39
|
+
def local_backup_path
|
40
|
+
local_path
|
41
|
+
end
|
42
|
+
|
43
|
+
def prep_command
|
44
|
+
noop
|
45
|
+
end
|
46
|
+
|
47
|
+
def cleanup_command
|
48
|
+
noop
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
data/spec/confluence_spec.rb
CHANGED
@@ -4,7 +4,7 @@ describe "The Confluence source" do
|
|
4
4
|
|
5
5
|
before(:each) do
|
6
6
|
@file = File.dirname(__FILE__) + "/fixtures/confluence.yml"
|
7
|
-
@reader = Reader.new(@file)
|
7
|
+
@reader = Blanket::Reader.new(@file)
|
8
8
|
@instance = Confluence.new(@reader)
|
9
9
|
@date_string = Date.today.strftime("%Y_%m_%d")
|
10
10
|
end
|
@@ -16,15 +16,15 @@ describe "The Confluence source" do
|
|
16
16
|
|
17
17
|
it "should delegate methods to its configuration" do
|
18
18
|
@instance.source_type.should == "Confluence"
|
19
|
-
@instance.remote_directory.should == "/path/to/remote/backups"
|
19
|
+
@instance.remote_directory.should == "/path/to/remote/confluence/backups"
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should assemble the remote backup path properly" do
|
23
|
-
@instance.remote_backup_path.should == "/path/to/remote/backups/daily-backup-#{@date_string}.zip"
|
23
|
+
@instance.remote_backup_path.should == "/path/to/remote/confluence/backups/daily-backup-#{@date_string}.zip"
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should assemble the local backup path properly" do
|
27
|
-
@instance.local_backup_path.should == "/path/to/local/backups/daily-backup-#{@date_string}.zip"
|
27
|
+
@instance.local_backup_path.should == "/path/to/local/confluence/backups/daily-backup-#{@date_string}.zip"
|
28
28
|
end
|
29
29
|
|
30
30
|
end
|
data/spec/fixtures/s3-info.yml
CHANGED
data/spec/reader_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe "The YAML config file" do
|
|
5
5
|
describe "for S3" do
|
6
6
|
before do
|
7
7
|
file = File.dirname(__FILE__) + "/fixtures/s3-info.yml"
|
8
|
-
@reader = Reader.new(file)
|
8
|
+
@reader = Blanket::Reader.new(file)
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should instantiate a reader from a file" do
|
@@ -18,11 +18,11 @@ describe "The YAML config file" do
|
|
18
18
|
|
19
19
|
|
20
20
|
it "should define the access key id" do
|
21
|
-
@reader.access_key_id.should == "
|
21
|
+
@reader.access_key_id.should == "your-id"
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should define the secret key id" do
|
25
|
-
@reader.secret_access_key.should == "
|
25
|
+
@reader.secret_access_key.should == "your-secret-key"
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should report the S3 keys as its own" do
|
@@ -35,7 +35,7 @@ describe "The YAML config file" do
|
|
35
35
|
describe "for Confluence" do
|
36
36
|
before do
|
37
37
|
file = File.dirname(__FILE__) + "/fixtures/confluence.yml"
|
38
|
-
@reader = Reader.new(file)
|
38
|
+
@reader = Blanket::Reader.new(file)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should define the blanket type as Confluence" do
|
@@ -43,25 +43,21 @@ describe "The YAML config file" do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should define the host" do
|
46
|
-
@reader.host.should == "
|
46
|
+
@reader.host.should == "yourhost.com"
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should define the user" do
|
50
|
-
@reader.user.should == "
|
50
|
+
@reader.user.should == "username"
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should define the password" do
|
54
|
-
@reader.password.should == "
|
54
|
+
@reader.password.should == "password"
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should define the backup directory" do
|
58
|
-
@reader.
|
58
|
+
@reader.remote_directory.should == "/path/to/remote/confluence/backups"
|
59
59
|
end
|
60
|
-
|
61
|
-
it "should define the bucket name" do
|
62
|
-
@reader.bucket.should == "com.foobar.confluence"
|
63
|
-
end
|
64
|
-
|
60
|
+
|
65
61
|
it "should report the Confluence keys as its own" do
|
66
62
|
@reader.keys.should == Confluence.attribute_symbols
|
67
63
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../lib/init.rb"
|
1
|
+
require File.dirname(__FILE__) + "/../lib/blanket/init.rb"
|
2
2
|
gem 'rspec'
|
data/spec/writer_spec.rb
CHANGED
@@ -5,21 +5,21 @@ describe "The Blanket config writer" do
|
|
5
5
|
before do
|
6
6
|
@confluence_file = File.dirname(__FILE__) + "/fixtures/confluence.yml"
|
7
7
|
@atts = YAML.load_file(@confluence_file)
|
8
|
-
@writer = Writer.new(@atts)
|
8
|
+
@writer = Blanket::Writer.new(@atts)
|
9
9
|
@tempfile = File.dirname(__FILE__)+"/tmp/temp.yml"
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should write a config file that the reader can read" do
|
13
13
|
@writer.write(@tempfile)
|
14
|
-
reader = Reader.new(@tempfile)
|
15
|
-
|
14
|
+
reader = Blanket::Reader.new(@tempfile)
|
15
|
+
reader.source_type.should == "Confluence"
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should write a config file that matches the incoming parameters" do
|
19
19
|
@writer.write(@tempfile)
|
20
|
-
@reader = Reader.new(@confluence_file)
|
21
|
-
@write_reader = Reader.new(@tempfile)
|
22
|
-
[:
|
20
|
+
@reader = Blanket::Reader.new(@confluence_file)
|
21
|
+
@write_reader = Blanket::Reader.new(@tempfile)
|
22
|
+
[:source_type, :host, :user, :password, :remote_directory, :local_directory].each do |sym|
|
23
23
|
@write_reader.send(sym).should == @reader.send(sym)
|
24
24
|
end
|
25
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blanket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Van Fleet
|
@@ -61,6 +61,8 @@ files:
|
|
61
61
|
- lib/blanket/plugins/sources/confluence.rb
|
62
62
|
- lib/blanket/plugins/sources/mysql.rb
|
63
63
|
- lib/blanket/plugins/sources/subversion.rb
|
64
|
+
- lib/blanket/plugins/sources/single_file.rb
|
65
|
+
- lib/blanket/plugins/sources/remote_directory.rb
|
64
66
|
- lib/blanket/plugins/sinks/s3.rb
|
65
67
|
- spec/fixtures
|
66
68
|
- spec/confluence_spec.rb
|