siba 0.5.6 → 0.5.7
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/README.md +3 -3
- data/Rakefile +6 -6
- data/lib/siba/backup.rb +2 -2
- data/lib/siba/console.rb +13 -13
- data/lib/siba/generator.rb +4 -5
- data/lib/siba/helpers/file_helper.rb +6 -6
- data/lib/siba/helpers/password_strength.rb +5 -5
- data/lib/siba/helpers/security_helper.rb +9 -9
- data/lib/siba/helpers/test/extend_test.rb +7 -7
- data/lib/siba/helpers/test/helper.rb +3 -3
- data/lib/siba/logger_plug.rb +1 -1
- data/lib/siba/plugins/archive/tar/archive.rb +8 -8
- data/lib/siba/plugins/archive/tar/init.rb +3 -3
- data/lib/siba/plugins/destination/dir/dest_dir.rb +7 -7
- data/lib/siba/plugins/destination/dir/init.rb +2 -2
- data/lib/siba/plugins/encryption/gpg/encryption.rb +10 -10
- data/lib/siba/plugins/encryption/gpg/init.rb +1 -1
- data/lib/siba/plugins/installed_plugins.rb +10 -6
- data/lib/siba/plugins/plugin_loader.rb +6 -5
- data/lib/siba/plugins/source/files/files.rb +7 -7
- data/lib/siba/plugins/source/files/init.rb +2 -2
- data/lib/siba/restore.rb +5 -5
- data/lib/siba/scaffold.rb +17 -17
- data/lib/siba/siba_check.rb +3 -3
- data/lib/siba/siba_file.rb +6 -6
- data/lib/siba/siba_logger.rb +11 -11
- data/lib/siba/tasks/siba_task.rb +1 -1
- data/lib/siba/tasks/siba_tasks.rb +7 -7
- data/lib/siba/test_files.rb +4 -4
- data/lib/siba/tmp_dir.rb +4 -4
- data/lib/siba/version.rb +1 -1
- data/scaffolds/archive.rb +3 -3
- data/scaffolds/destination.rb +4 -4
- data/scaffolds/encryption.rb +3 -3
- data/scaffolds/project/siba-c6y-demo.gemspec +2 -2
- data/scaffolds/project/test/helper/require_integration.rb +1 -1
- data/scaffolds/project/test/integration/i9n_init.rb +4 -4
- data/scaffolds/project/test/unit/test_init.rb +8 -8
- data/scaffolds/shared/examples.rb +4 -4
- data/scaffolds/source.rb +4 -4
- data/siba.gemspec +1 -1
- data/test/integration/helpers/i9n_file_helper.rb +1 -1
- data/test/integration/i9n_backup.rb +1 -1
- data/test/integration/i9n_scaffold.rb +1 -1
- data/test/integration/i9n_test_unicode_files.rb +1 -1
- data/test/integration/i9n_tmp_dir.rb +2 -2
- data/test/integration/plugins/destination/dir/i9n_dest_dir.rb +1 -1
- data/test/integration/plugins/encryption/gpg/i9n_encryption.rb +4 -4
- data/test/integration/plugins/source/files/i9n_files.rb +6 -6
- data/test/integration/tasks/i9n_siba_tasks.rb +2 -2
- data/test/unit/helpers/test_encoding_helper.rb +1 -1
- data/test/unit/helpers/test_gem_helper.rb +1 -1
- data/test/unit/helpers/test_security_helper.rb +1 -1
- data/test/unit/helpers/test_string_helper.rb +1 -1
- data/test/unit/plugins/archive/tar/test_archive.rb +2 -2
- data/test/unit/plugins/archive/tar/test_init.rb +2 -2
- data/test/unit/plugins/destination/dir/test_dest_dir.rb +1 -1
- data/test/unit/plugins/destination/dir/test_init.rb +1 -1
- data/test/unit/plugins/encryption/gpg/test_encryption.rb +2 -14
- data/test/unit/plugins/encryption/gpg/test_init.rb +3 -3
- data/test/unit/plugins/source/files/test_files.rb +2 -2
- data/test/unit/plugins/source/files/test_init.rb +3 -3
- data/test/unit/plugins/source/files/test_path_match.rb +6 -6
- data/test/unit/plugins/test_installed_plugins.rb +4 -0
- data/test/unit/plugins/test_plugin_loader.rb +6 -3
- data/test/unit/tasks/test_siba_task.rb +2 -2
- data/test/unit/tasks/test_siba_tasks.rb +3 -3
- data/test/unit/test_backup.rb +2 -2
- data/test/unit/test_console.rb +5 -5
- data/test/unit/test_generator.rb +1 -1
- data/test/unit/test_globals.rb +1 -1
- data/test/unit/test_log_message.rb +1 -1
- data/test/unit/test_logger_plug.rb +1 -1
- data/test/unit/test_options_backup.rb +1 -1
- data/test/unit/test_options_loader.rb +27 -39
- data/test/unit/test_password_strength.rb +14 -14
- data/test/unit/test_restore.rb +2 -2
- data/test/unit/test_siba_logger.rb +18 -18
- data/test/unit/test_tmp_dir.rb +1 -1
- metadata +5 -5
data/README.md
CHANGED
@@ -64,15 +64,15 @@ It is recommended to run `siba backup` command daily or hourly. Use your favouri
|
|
64
64
|
* **mysql**: backup and restore MySQL database ([homepage](https://github.com/evgenyneu/siba-source-mysql)).
|
65
65
|
|
66
66
|
### Archive
|
67
|
-
|
67
|
+
|
68
68
|
* **tar:** archive with optional gzip or bzip2 compression.
|
69
69
|
|
70
70
|
### Encryption
|
71
|
-
|
71
|
+
|
72
72
|
* **gpg:** encrypt with AES256, Blowfish, Twofish, 3DES and other ciphers.
|
73
73
|
|
74
74
|
### Destination
|
75
|
-
|
75
|
+
|
76
76
|
* **dir:** backup to local directory.
|
77
77
|
* **aws-s3:** upload backup to Amazon S3 storage ([homepage](https://github.com/evgenyneu/siba-destination-aws-s3)).
|
78
78
|
* **ftp:** store backups on FTP server ([homepage](https://github.com/evgenyneu/siba-destination-ftp)).
|
data/Rakefile
CHANGED
@@ -3,17 +3,17 @@ require 'rake/testtask'
|
|
3
3
|
|
4
4
|
namespace "test" do
|
5
5
|
desc "Run all unit tests"
|
6
|
-
Rake::TestTask.new("unit") do |t|
|
6
|
+
Rake::TestTask.new("unit") do |t|
|
7
7
|
t.pattern = "test/unit/**/test*.rb"
|
8
|
-
t.libs << 'test'
|
8
|
+
t.libs << 'test'
|
9
9
|
end
|
10
10
|
|
11
11
|
desc "Run all integration tests"
|
12
|
-
Rake::TestTask.new("integration") do |t|
|
12
|
+
Rake::TestTask.new("integration") do |t|
|
13
13
|
t.pattern = "test/integration/**/i9n_*.rb"
|
14
|
-
t.libs << 'test'
|
14
|
+
t.libs << 'test'
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
desc "Run all integration tests"
|
18
18
|
task :i9n => ["test:integration"] do
|
19
19
|
end
|
@@ -23,5 +23,5 @@ desc "Run all unit tests"
|
|
23
23
|
task :test => ["test:unit"] do
|
24
24
|
end
|
25
25
|
|
26
|
-
desc "Run tests"
|
26
|
+
desc "Run tests"
|
27
27
|
task :default => "test:unit"
|
data/lib/siba/backup.rb
CHANGED
@@ -20,10 +20,10 @@ private
|
|
20
20
|
Siba.settings = options["settings"] || {}
|
21
21
|
Siba.backup_name = File.basename path_to_options_yml, ".yml"
|
22
22
|
|
23
|
-
TmpDir.test_access
|
23
|
+
TmpDir.test_access
|
24
24
|
SibaTasks.new(options, path_to_options_yml, false).backup
|
25
25
|
Siba.cleanup_tmp_dir
|
26
|
-
rescue Exception => e
|
26
|
+
rescue Exception => e
|
27
27
|
logger.fatal e
|
28
28
|
logger.log_exception e, true
|
29
29
|
end
|
data/lib/siba/console.rb
CHANGED
@@ -6,7 +6,7 @@ require 'siba/generator'
|
|
6
6
|
|
7
7
|
module Siba
|
8
8
|
class Console
|
9
|
-
include Siba::FilePlug
|
9
|
+
include Siba::FilePlug
|
10
10
|
|
11
11
|
UNUSED_COMMAND = "unused" # unused command for testing command line options
|
12
12
|
attr_accessor :test_mode, :parser, :options
|
@@ -28,8 +28,8 @@ module Siba
|
|
28
28
|
parser = OptionParser.new do |o|
|
29
29
|
o.banner = "Usage: siba command ARGUMENTS [options...]
|
30
30
|
|
31
|
-
Examples:
|
32
|
-
siba generate mybak Generate mybak.yml options file
|
31
|
+
Examples:
|
32
|
+
siba generate mybak Generate mybak.yml options file
|
33
33
|
siba backup mybak Run backup, reading options from mybak.yml
|
34
34
|
siba restore mybak Restore the backup
|
35
35
|
siba list Show available plugins
|
@@ -43,12 +43,12 @@ Options:"
|
|
43
43
|
o.on("--log FILE", "Set path to log FILE") do |log|
|
44
44
|
options['log'] = log
|
45
45
|
end
|
46
|
-
|
47
|
-
o.on("--no-log", "Work without logging") do
|
46
|
+
|
47
|
+
o.on("--no-log", "Work without logging") do
|
48
48
|
SibaLogger.no_log = true
|
49
49
|
end
|
50
50
|
|
51
|
-
o.on("--current-source", "Used with 'restore' command. Restores into the source location which is specified in the CURRENT options file instead of the ORIGINAL source location") do
|
51
|
+
o.on("--current-source", "Used with 'restore' command. Restores into the source location which is specified in the CURRENT options file instead of the ORIGINAL source location") do
|
52
52
|
options['cur'] = true
|
53
53
|
end
|
54
54
|
|
@@ -74,12 +74,12 @@ Options:"
|
|
74
74
|
o.separator "Homepage: https://github.com/evgenyneu/siba"
|
75
75
|
end
|
76
76
|
|
77
|
-
if argv.empty?
|
77
|
+
if argv.empty?
|
78
78
|
show_message parser.to_s
|
79
79
|
return
|
80
80
|
end
|
81
|
-
|
82
|
-
begin
|
81
|
+
|
82
|
+
begin
|
83
83
|
parser.parse! argv
|
84
84
|
rescue Exception => e
|
85
85
|
@parser = parser
|
@@ -90,14 +90,14 @@ Options:"
|
|
90
90
|
show_error "ambiguous usage of both --log and --no-log switches"
|
91
91
|
return
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
parser
|
95
95
|
end
|
96
96
|
|
97
97
|
def parse_command(argv)
|
98
98
|
command = argv.shift
|
99
99
|
show_error "missing a command", true if command.nil?
|
100
|
-
|
100
|
+
|
101
101
|
case command.downcase
|
102
102
|
when "b", "backup"
|
103
103
|
backup argv
|
@@ -173,7 +173,7 @@ Options:"
|
|
173
173
|
|
174
174
|
def list
|
175
175
|
show_message "Available SIBA plugins:
|
176
|
-
|
176
|
+
|
177
177
|
#{Siba::Plugins.get_list} * Currently installed"
|
178
178
|
end
|
179
179
|
|
@@ -181,7 +181,7 @@ Options:"
|
|
181
181
|
file = argv.shift
|
182
182
|
if file.nil?
|
183
183
|
show_error "missing file name"
|
184
|
-
end
|
184
|
+
end
|
185
185
|
begin
|
186
186
|
path_to_yaml = Siba::Generator.new(file).generate
|
187
187
|
show_message "Options file generated: #{path_to_yaml}
|
data/lib/siba/generator.rb
CHANGED
@@ -43,15 +43,14 @@ module Siba
|
|
43
43
|
end
|
44
44
|
|
45
45
|
unless Siba::InstalledPlugins.installed? category, type
|
46
|
-
siba_kernel.puts
|
47
|
-
siba_kernel.puts "Run 'gem install #{Siba::InstalledPlugins.gem_name(category, type)}' to install it and try again."
|
46
|
+
siba_kernel.puts Siba::InstalledPlugins.install_gem_message(category, type)
|
48
47
|
return
|
49
48
|
end
|
50
49
|
else
|
51
50
|
type = types.keys.first
|
52
51
|
end
|
53
52
|
|
54
|
-
options = Siba::Generator.load_plugin_yaml_content category, type
|
53
|
+
options = Siba::Generator.load_plugin_yaml_content category, type
|
55
54
|
unless options =~ /^\s*type:/
|
56
55
|
options = "type: #{type}\n" + options
|
57
56
|
end
|
@@ -83,7 +82,7 @@ module Siba
|
|
83
82
|
raise "Failed to load options for #{InstalledPlugins.plugin_category_and_type(category, type)} plugin from file: #{path}. Error: #{ex.message}"
|
84
83
|
end
|
85
84
|
end
|
86
|
-
end
|
85
|
+
end
|
87
86
|
|
88
87
|
def get_plugin_yaml_path(category, type)
|
89
88
|
siba_file.run_this do
|
@@ -107,7 +106,7 @@ module Siba
|
|
107
106
|
return types[number-1]
|
108
107
|
else
|
109
108
|
siba_kernel.printf msg
|
110
|
-
end
|
109
|
+
end
|
111
110
|
end
|
112
111
|
end
|
113
112
|
end
|
@@ -46,21 +46,21 @@ module Siba
|
|
46
46
|
siba_file.dir_entries(dir) - %w{ . .. }
|
47
47
|
end
|
48
48
|
|
49
|
-
# Retuns an array containing names of sub-directories located in the dir
|
49
|
+
# Retuns an array containing names of sub-directories located in the dir
|
50
50
|
def dirs(dir)
|
51
51
|
entries(dir).select do |entry|
|
52
52
|
siba_file.file_directory?(File.join(dir,entry))
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
# Retuns an array containing names of files located in the dir
|
56
|
+
# Retuns an array containing names of files located in the dir
|
57
57
|
def files(dir)
|
58
58
|
entries(dir).select do |entry|
|
59
59
|
siba_file.file_file?(File.join(dir,entry))
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
# Raises error if dirs are not identical
|
63
|
+
# Raises error if dirs are not identical
|
64
64
|
def dirs_same?(dir1, dir2)
|
65
65
|
dir1_entries = siba_file.dir_entries dir1
|
66
66
|
dir2_entries = siba_file.dir_entries dir2
|
@@ -80,13 +80,13 @@ module Siba
|
|
80
80
|
if siba_file.file_file? sub_dir1_entry
|
81
81
|
raise "#{msg}'#{sub_dir2_entry}' is not a file" unless siba_file.file_file? sub_dir2_entry
|
82
82
|
unless siba_file.file_utils_compare_file sub_dir1_entry, sub_dir2_entry
|
83
|
-
raise Siba::Error, "#{msg}'#{sub_dir1_entry}' and '#{sub_dir2_entry}' files are different."
|
83
|
+
raise Siba::Error, "#{msg}'#{sub_dir1_entry}' and '#{sub_dir2_entry}' files are different."
|
84
84
|
end
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
# compare permissions
|
88
88
|
if (siba_file.file_stat(sub_dir1_entry).mode % 01000) != (siba_file.file_stat(sub_dir2_entry).mode % 01000)
|
89
|
-
raise Siba::Error, "#{msg}'#{sub_dir1_entry}' and '#{sub_dir2_entry}' entries have different permissions."
|
89
|
+
raise Siba::Error, "#{msg}'#{sub_dir1_entry}' and '#{sub_dir2_entry}' entries have different permissions."
|
90
90
|
end
|
91
91
|
|
92
92
|
# compare sub-dirs
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
module Siba
|
4
|
-
# Password strength calculator based on:
|
4
|
+
# Password strength calculator based on:
|
5
5
|
# http://snippets.dzone.com/posts/show/4698
|
6
6
|
# https://www.grc.com/haystack.htm
|
7
|
-
class PasswordStrength
|
7
|
+
class PasswordStrength
|
8
8
|
PASSWORD_SETS = {
|
9
9
|
/[a-z]/ => 26,
|
10
10
|
/[A-Z]/ => 26,
|
@@ -48,7 +48,7 @@ module Siba
|
|
48
48
|
end
|
49
49
|
|
50
50
|
# Convert the number of seconds human-friendly timespan string
|
51
|
-
# Example:
|
51
|
+
# Example:
|
52
52
|
# 130: 2 minutes
|
53
53
|
# 12345: 3 hours
|
54
54
|
def seconds_to_timespan(seconds)
|
@@ -82,8 +82,8 @@ module Siba
|
|
82
82
|
illion_unit = ""
|
83
83
|
Illions.each_pair do |a,b|
|
84
84
|
ticks_next = ticks.to_f / b
|
85
|
-
break if ticks_next < 1
|
86
|
-
illion_unit = a
|
85
|
+
break if ticks_next < 1
|
86
|
+
illion_unit = a
|
87
87
|
ticks = ticks_next
|
88
88
|
end
|
89
89
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
|
2
|
+
|
3
3
|
require 'securerandom'
|
4
4
|
|
5
5
|
module Siba
|
@@ -8,23 +8,23 @@ module Siba
|
|
8
8
|
def generate_password_for_yaml(length = 16)
|
9
9
|
characters = (32..126).to_a - "\\\"".bytes.to_a - "`".bytes.to_a
|
10
10
|
|
11
|
-
(0...length).map{
|
11
|
+
(0...length).map{
|
12
12
|
characters[SecureRandom.random_number(characters.size)].chr
|
13
|
-
}.join
|
13
|
+
}.join
|
14
14
|
end
|
15
15
|
|
16
16
|
def alphanumeric_password(length = 16, lowercase_only=false, non_ambiguous = false)
|
17
17
|
characters = ('a'..'z').to_a + ('0'..'9').to_a
|
18
18
|
characters += ('A'..'Z').to_a unless lowercase_only
|
19
19
|
|
20
|
-
%w{I O l 0 1}.each{ |ambiguous_character|
|
21
|
-
characters.delete ambiguous_character
|
22
|
-
} if non_ambiguous
|
20
|
+
%w{I O l 0 1}.each{ |ambiguous_character|
|
21
|
+
characters.delete ambiguous_character
|
22
|
+
} if non_ambiguous
|
23
23
|
|
24
|
-
(0...length).map{
|
24
|
+
(0...length).map{
|
25
25
|
characters[SecureRandom.random_number(characters.size)]
|
26
|
-
}.join
|
26
|
+
}.join
|
27
27
|
end
|
28
|
-
end
|
28
|
+
end
|
29
29
|
end
|
30
30
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
class MiniTest::Unit::TestCase
|
4
|
-
include Siba::FilePlug
|
4
|
+
include Siba::FilePlug
|
5
5
|
def must_log(level)
|
6
6
|
verify_log true, level, true
|
7
7
|
end
|
@@ -32,12 +32,12 @@ class MiniTest::Unit::TestCase
|
|
32
32
|
|
33
33
|
def mock_file(name, retval, args=[])
|
34
34
|
mock = new_mock_file
|
35
|
-
mock.expect name, retval, args
|
35
|
+
mock.expect name, retval, args
|
36
36
|
mock
|
37
37
|
end
|
38
38
|
|
39
39
|
def new_mock_file
|
40
|
-
Siba::FilePlug.siba_file = MiniTest::Mock.new
|
40
|
+
Siba::FilePlug.siba_file = MiniTest::Mock.new
|
41
41
|
end
|
42
42
|
|
43
43
|
def create_plugin(yml_file_name_or_options_hash)
|
@@ -46,7 +46,7 @@ class MiniTest::Unit::TestCase
|
|
46
46
|
else
|
47
47
|
@options = yml_file_name_or_options_hash
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
unless @plugin_category
|
51
51
|
raise Siba::Error, "Initialize '@plugin_category' variable (#{Siba::Plugins.categories_str})"
|
52
52
|
end
|
@@ -70,7 +70,7 @@ class MiniTest::Unit::TestCase
|
|
70
70
|
tmp_dir ||= SibaTest.tmp_dir
|
71
71
|
Siba::TestFiles::prepare_test_dir dir_name_part, tmp_dir
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
def prepare_test_file(file_name_part, tmp_dir = nil)
|
75
75
|
tmp_dir ||= SibaTest.tmp_dir
|
76
76
|
Siba::TestFiles::prepare_test_file file_name_part, tmp_dir
|
@@ -93,13 +93,13 @@ class MiniTest::Unit::TestCase
|
|
93
93
|
def prepare_options(src_yml_path, replace_data)
|
94
94
|
Siba::TestFiles::prepare_options(src_yml_path, replace_data)
|
95
95
|
end
|
96
|
-
|
96
|
+
|
97
97
|
def prepare_yml(src_yml_path, replace_data, tmp_dir=nil)
|
98
98
|
tmp_dir ||= SibaTest.tmp_dir
|
99
99
|
Siba::TestFiles::prepare_yml src_yml_path, replace_data, tmp_dir
|
100
100
|
end
|
101
101
|
|
102
|
-
private
|
102
|
+
private
|
103
103
|
|
104
104
|
def verify_log(must_change, log_level, exact_level = true)
|
105
105
|
log_count = Siba::SibaLogger.count log_level, exact_level
|
@@ -20,7 +20,7 @@ module SibaTest
|
|
20
20
|
Siba::LoggerPlug.create "Test", nil
|
21
21
|
Siba::SibaLogger.messages = []
|
22
22
|
Siba.settings = {}
|
23
|
-
Siba.current_dir = @current_dir
|
23
|
+
Siba.current_dir = @current_dir
|
24
24
|
Siba.backup_name = "siba"
|
25
25
|
SibaTest::KernelMock.mock_all_methods # prevents tests from accessing Kernel methods
|
26
26
|
end
|
@@ -33,7 +33,7 @@ module SibaTest
|
|
33
33
|
def init_unit
|
34
34
|
init
|
35
35
|
MiniTest::Unit::TestCase.add_setup_hook do
|
36
|
-
SibaTest::FileMock.mock_all_methods # prevents tests from doing file operations
|
36
|
+
SibaTest::FileMock.mock_all_methods # prevents tests from doing file operations
|
37
37
|
Siba.class_eval {@tmp_dir = SibaTest::TmpDirMocked}
|
38
38
|
end
|
39
39
|
end
|
@@ -42,7 +42,7 @@ module SibaTest
|
|
42
42
|
init
|
43
43
|
MiniTest::Unit::TestCase.add_teardown_hook do
|
44
44
|
# cleanup after each integration test
|
45
|
-
Siba.current_dir = @current_dir
|
45
|
+
Siba.current_dir = @current_dir
|
46
46
|
Siba.cleanup_tmp_dir
|
47
47
|
SibaTest.cleanup_tmp_dir
|
48
48
|
end
|
data/lib/siba/logger_plug.rb
CHANGED
@@ -5,7 +5,7 @@ module Siba::Archive
|
|
5
5
|
class Archive
|
6
6
|
include Siba::FilePlug
|
7
7
|
include Siba::LoggerPlug
|
8
|
-
attr_accessor :compression
|
8
|
+
attr_accessor :compression
|
9
9
|
|
10
10
|
def initialize(compression)
|
11
11
|
@compression = compression
|
@@ -22,7 +22,7 @@ module Siba::Archive
|
|
22
22
|
archive_name = "#{dest_file_name}.tar#{extension}"
|
23
23
|
archive_path = File.join(dest_dir, archive_name)
|
24
24
|
siba_file.run_this do
|
25
|
-
raise Siba::Error, "Archive file already exists: #{archive_path}" if siba_file.file_file?(archive_path) || siba_file.file_directory?(archive_path)
|
25
|
+
raise Siba::Error, "Archive file already exists: #{archive_path}" if siba_file.file_file?(archive_path) || siba_file.file_directory?(archive_path)
|
26
26
|
|
27
27
|
siba_file.file_utils_cd dest_dir
|
28
28
|
command_text = %(tar c#{options}f #{archive_name} -C "#{sources_dir}" .)
|
@@ -38,7 +38,7 @@ module Siba::Archive
|
|
38
38
|
options = get_tar_option
|
39
39
|
archive_name = File.basename archive_path
|
40
40
|
archive_dir = File.dirname archive_path
|
41
|
-
siba_file.file_utils_cd archive_dir
|
41
|
+
siba_file.file_utils_cd archive_dir
|
42
42
|
command_text = %(tar x#{options}f #{archive_name} -C "#{destination_dir}")
|
43
43
|
# Using -C 'change directory' option to make it work on Windows
|
44
44
|
# because Windows will not understand absolute path to tar: "tar xf c:\dir\file.tar"
|
@@ -65,7 +65,7 @@ module Siba::Archive
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
def test_archive_and_extract
|
68
|
+
def test_archive_and_extract
|
69
69
|
# archive
|
70
70
|
src_dir = Siba::TestFiles.prepare_test_dir "tar-archive-src"
|
71
71
|
dest_dir = Siba::TestFiles.mkdir_in_tmp_dir "tar-archive-dest"
|
@@ -89,27 +89,27 @@ module Siba::Archive
|
|
89
89
|
protected
|
90
90
|
def self.get_tar_extension(compression)
|
91
91
|
case compression
|
92
|
-
when "none"
|
92
|
+
when "none"
|
93
93
|
""
|
94
94
|
when "gzip"
|
95
95
|
".gz"
|
96
96
|
when "bzip2"
|
97
97
|
".bz2"
|
98
98
|
else
|
99
|
-
raise
|
99
|
+
raise
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
103
|
def get_tar_option
|
104
104
|
case compression
|
105
|
-
when "none"
|
105
|
+
when "none"
|
106
106
|
""
|
107
107
|
when "gzip"
|
108
108
|
"z"
|
109
109
|
when "bzip2"
|
110
110
|
"j"
|
111
111
|
else
|
112
|
-
raise
|
112
|
+
raise
|
113
113
|
end
|
114
114
|
end
|
115
115
|
end
|