siba 0.4.3
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/.gitignore +7 -0
- data/Gemfile +4 -0
- data/Guardfile +18 -0
- data/LICENSE +22 -0
- data/README.md +47 -0
- data/Rakefile +27 -0
- data/bin/siba +5 -0
- data/lib/siba.rb +27 -0
- data/lib/siba/backup.rb +31 -0
- data/lib/siba/console.rb +196 -0
- data/lib/siba/errors.rb +8 -0
- data/lib/siba/generator.rb +115 -0
- data/lib/siba/globals.rb +19 -0
- data/lib/siba/helpers/encoding_helper.rb +38 -0
- data/lib/siba/helpers/file_helper.rb +89 -0
- data/lib/siba/helpers/gem_helper.rb +22 -0
- data/lib/siba/helpers/password_strength.rb +94 -0
- data/lib/siba/helpers/security_helper.rb +30 -0
- data/lib/siba/helpers/string_helper.rb +32 -0
- data/lib/siba/helpers/test/extend_test.rb +114 -0
- data/lib/siba/helpers/test/file_mock.rb +38 -0
- data/lib/siba/helpers/test/helper.rb +55 -0
- data/lib/siba/helpers/test/kernel_mock.rb +44 -0
- data/lib/siba/helpers/test/removable_constants.rb +18 -0
- data/lib/siba/helpers/test/require.rb +12 -0
- data/lib/siba/logger_plug.rb +36 -0
- data/lib/siba/options_backup.rb +37 -0
- data/lib/siba/options_loader.rb +38 -0
- data/lib/siba/plugins/archive/tar/archive.rb +117 -0
- data/lib/siba/plugins/archive/tar/init.rb +38 -0
- data/lib/siba/plugins/archive/tar/options.yml +1 -0
- data/lib/siba/plugins/destination/dir/dest_dir.rb +77 -0
- data/lib/siba/plugins/destination/dir/init.rb +31 -0
- data/lib/siba/plugins/destination/dir/options.yml +2 -0
- data/lib/siba/plugins/encryption/gpg/encryption.rb +140 -0
- data/lib/siba/plugins/encryption/gpg/init.rb +45 -0
- data/lib/siba/plugins/encryption/gpg/options.yml +2 -0
- data/lib/siba/plugins/installed_plugins.rb +77 -0
- data/lib/siba/plugins/plugin_loader.rb +100 -0
- data/lib/siba/plugins/plugins.rb +57 -0
- data/lib/siba/plugins/plugins.yml +9 -0
- data/lib/siba/plugins/source/files/files.rb +166 -0
- data/lib/siba/plugins/source/files/init.rb +33 -0
- data/lib/siba/plugins/source/files/options.yml +11 -0
- data/lib/siba/restore.rb +113 -0
- data/lib/siba/scaffold.rb +166 -0
- data/lib/siba/siba_check.rb +75 -0
- data/lib/siba/siba_file.rb +89 -0
- data/lib/siba/siba_kernel.rb +37 -0
- data/lib/siba/siba_logger.rb +172 -0
- data/lib/siba/tasks/siba_task.rb +42 -0
- data/lib/siba/tasks/siba_tasks.rb +120 -0
- data/lib/siba/test_files.rb +76 -0
- data/lib/siba/test_files/a_file +1 -0
- data/lib/siba/test_files/files_and_dirs/.hidden +1 -0
- data/lib/siba/test_files/files_and_dirs/.hidden_dir/file10 +1 -0
- data/lib/siba/test_files/files_and_dirs/File With Spaces +1 -0
- data/lib/siba/test_files/files_and_dirs/dir1/file10 +1 -0
- data/lib/siba/test_files/files_and_dirs/dir1/sub-dir/file111.txt +1 -0
- data/lib/siba/test_files/files_and_dirs/file1 +1 -0
- data/lib/siba/test_files/files_and_dirs/file2.txt +1 -0
- data/lib/siba/tmp_dir.rb +94 -0
- data/lib/siba/version.rb +5 -0
- data/scaffolds/archive.rb +26 -0
- data/scaffolds/destination.rb +20 -0
- data/scaffolds/encryption.rb +26 -0
- data/scaffolds/project/.gitignore +5 -0
- data/scaffolds/project/Gemfile +4 -0
- data/scaffolds/project/Guardfile +9 -0
- data/scaffolds/project/LICENSE +22 -0
- data/scaffolds/project/README.md +33 -0
- data/scaffolds/project/Rakefile +28 -0
- data/scaffolds/project/lib/siba-c6y-demo.rb +11 -0
- data/scaffolds/project/lib/siba-c6y-demo/options.yml +2 -0
- data/scaffolds/project/lib/siba-c6y-demo/version.rb +9 -0
- data/scaffolds/project/siba-c6y-demo.gemspec +26 -0
- data/scaffolds/project/test/helper/require_integration.rb +5 -0
- data/scaffolds/project/test/helper/require_unit.rb +4 -0
- data/scaffolds/project/test/integration/i9n_init.rb +35 -0
- data/scaffolds/project/test/unit/test_init.rb +43 -0
- data/scaffolds/project/test/unit/yml/valid.yml +8 -0
- data/scaffolds/shared/examples.rb +47 -0
- data/scaffolds/shared/init_example.rb +13 -0
- data/scaffolds/source.rb +25 -0
- data/siba.gemspec +30 -0
- data/test/helper/require_integration.rb +4 -0
- data/test/helper/require_unit.rb +4 -0
- data/test/integration/helpers/i9n_file_helper.rb +50 -0
- data/test/integration/i9n_backup.rb +53 -0
- data/test/integration/i9n_console.rb +16 -0
- data/test/integration/i9n_generator.rb +29 -0
- data/test/integration/i9n_options_backup.rb +22 -0
- data/test/integration/i9n_scaffold.rb +27 -0
- data/test/integration/i9n_siba_file.rb +30 -0
- data/test/integration/i9n_test_unicode_files.rb +40 -0
- data/test/integration/i9n_tmp_dir.rb +44 -0
- data/test/integration/plugins/archive/tar/i9n_archive.rb +18 -0
- data/test/integration/plugins/destination/dir/i9n_dest_dir.rb +52 -0
- data/test/integration/plugins/encryption/gpg/i9n_encryption.rb +87 -0
- data/test/integration/plugins/i9n_installed_plugins.rb +13 -0
- data/test/integration/plugins/source/files/i9n_files.rb +146 -0
- data/test/integration/tasks/i9n_siba_tasks.rb +30 -0
- data/test/integration/yml/valid.yml +16 -0
- data/test/unit/helpers/test_encoding_helper.rb +17 -0
- data/test/unit/helpers/test_gem_helper.rb +17 -0
- data/test/unit/helpers/test_security_helper.rb +21 -0
- data/test/unit/helpers/test_string_helper.rb +35 -0
- data/test/unit/plugins/archive/tar/test_archive.rb +41 -0
- data/test/unit/plugins/archive/tar/test_init.rb +36 -0
- data/test/unit/plugins/archive/tar/yml/archive/check_installed.yml +2 -0
- data/test/unit/plugins/archive/tar/yml/init/default_compression.yml +1 -0
- data/test/unit/plugins/archive/tar/yml/init/invalid_compression.yml +2 -0
- data/test/unit/plugins/archive/tar/yml/init/valid.yml +2 -0
- data/test/unit/plugins/destination/dir/test_dest_dir.rb +41 -0
- data/test/unit/plugins/destination/dir/test_init.rb +36 -0
- data/test/unit/plugins/destination/dir/yml/init/valid.yml +2 -0
- data/test/unit/plugins/encryption/gpg/test_encryption.rb +70 -0
- data/test/unit/plugins/encryption/gpg/test_init.rb +47 -0
- data/test/unit/plugins/source/files/test_files.rb +44 -0
- data/test/unit/plugins/source/files/test_init.rb +48 -0
- data/test/unit/plugins/source/files/test_path_match.rb +140 -0
- data/test/unit/plugins/source/files/yml/ignore_list.yml +8 -0
- data/test/unit/plugins/source/files/yml/ignore_not_array.yml +5 -0
- data/test/unit/plugins/source/files/yml/include_not_array.yml +3 -0
- data/test/unit/plugins/source/files/yml/include_subdirs_false.yml +6 -0
- data/test/unit/plugins/source/files/yml/include_subdirs_missing.yml +5 -0
- data/test/unit/plugins/source/files/yml/no_ignore.yml +4 -0
- data/test/unit/plugins/source/files/yml/no_include.yml +1 -0
- data/test/unit/plugins/source/files/yml/valid.yml +9 -0
- data/test/unit/plugins/test_installed_plugins.rb +32 -0
- data/test/unit/plugins/test_plugin_loader.rb +27 -0
- data/test/unit/plugins/test_plugins.rb +44 -0
- data/test/unit/tasks/test_siba_task.rb +30 -0
- data/test/unit/tasks/test_siba_tasks.rb +84 -0
- data/test/unit/tasks/yml/task/invalid.yml +4 -0
- data/test/unit/tasks/yml/task/valid.yml +7 -0
- data/test/unit/test_backup.rb +18 -0
- data/test/unit/test_console.rb +166 -0
- data/test/unit/test_generator.rb +21 -0
- data/test/unit/test_globals.rb +34 -0
- data/test/unit/test_log_message.rb +26 -0
- data/test/unit/test_logger_plug.rb +49 -0
- data/test/unit/test_options_backup.rb +21 -0
- data/test/unit/test_options_loader.rb +72 -0
- data/test/unit/test_password_strength.rb +76 -0
- data/test/unit/test_restore.rb +18 -0
- data/test/unit/test_scaffold.rb +26 -0
- data/test/unit/test_siba_check.rb +118 -0
- data/test/unit/test_siba_logger.rb +174 -0
- data/test/unit/test_tmp_dir.rb +21 -0
- data/test/unit/yml/options_loader/array.yml +2 -0
- data/test/unit/yml/options_loader/empty.yml +0 -0
- data/test/unit/yml/options_loader/invalid.yml +4 -0
- data/test/unit/yml/options_loader/string.yml +1 -0
- data/test/unit/yml/options_loader/utf8_with_bom.yml +2 -0
- data/test/unit/yml/options_loader/valid.yml +12 -0
- data/test/unit/yml/siba_options_backup.yml +20 -0
- data/test/unit/yml/valid.yml +18 -0
- metadata +240 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
module Siba::TestFiles
|
|
4
|
+
class << self
|
|
5
|
+
include Siba::FilePlug
|
|
6
|
+
def test_files_dir
|
|
7
|
+
siba_file.file_expand_path("../test_files/", __FILE__)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_file
|
|
11
|
+
File.join test_files_dir, "a_file"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_dir
|
|
15
|
+
File.join test_files_dir, "files_and_dirs"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def prepare_test_dir(dest_dir_name_part, tmp_dir=nil)
|
|
19
|
+
tmp_dir ||= Siba.tmp_dir
|
|
20
|
+
dest_dir = File.join(tmp_dir,"#{dest_dir_name_part}#{random_suffix}")
|
|
21
|
+
siba_file.file_utils_mkpath tmp_dir unless siba_file.file_directory? tmp_dir
|
|
22
|
+
siba_file.file_utils_cp_r test_dir, dest_dir
|
|
23
|
+
dest_dir
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def prepare_test_file(dest_file_name_part, tmp_dir=nil)
|
|
27
|
+
tmp_dir ||= Siba.tmp_dir
|
|
28
|
+
dest_file = File.join(tmp_dir,"#{dest_file_name_part}#{random_suffix}")
|
|
29
|
+
siba_file.file_utils_mkpath tmp_dir unless siba_file.file_directory? tmp_dir
|
|
30
|
+
siba_file.file_utils_cp test_file, dest_file
|
|
31
|
+
dest_file
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def generate_path(dest_file_name_part, tmp_dir=nil)
|
|
35
|
+
tmp_dir ||= Siba.tmp_dir
|
|
36
|
+
File.join(tmp_dir,"#{dest_file_name_part}#{random_suffix}")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def mkdir_in_tmp_dir(prefix, tmp_dir=nil)
|
|
40
|
+
tmp_dir ||= Siba.tmp_dir
|
|
41
|
+
dir = "#{prefix}#{random_suffix}"
|
|
42
|
+
dir_path = File.join(tmp_dir, dir)
|
|
43
|
+
siba_file.file_utils_mkpath dir_path
|
|
44
|
+
dir_path
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def prepare_options_text(src_yml_path, replace_data)
|
|
48
|
+
replace_prefix = "#_replace_"
|
|
49
|
+
options_text = Siba::FileHelper.read src_yml_path
|
|
50
|
+
replace_data.each_pair do |key, value|
|
|
51
|
+
str_to_replace = "#{replace_prefix}#{key.to_s}"
|
|
52
|
+
raise "YML does not contain #{str_to_replace} text" unless options_text.include? str_to_replace
|
|
53
|
+
options_text.gsub! str_to_replace, value
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
raise "Test YML still has unreplaced text" if options_text.include? "#{replace_prefix}"
|
|
57
|
+
options_text
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def prepare_options(src_yml_path, replace_data)
|
|
61
|
+
YAML.load prepare_options_text(src_yml_path, replace_data)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def prepare_yml(src_yml_path, replace_data, tmp_dir=nil)
|
|
65
|
+
tmp_dir ||= Siba.tmp_dir
|
|
66
|
+
options_text = prepare_options_text src_yml_path, replace_data
|
|
67
|
+
dest_file = File.join tmp_dir,"#{File.basename(src_yml_path,".yml")}#{random_suffix}.yml"
|
|
68
|
+
siba_file.file_open(dest_file, "w") { |f| f.write options_text }
|
|
69
|
+
dest_file
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def random_suffix
|
|
73
|
+
"-#{Siba::SecurityHelper.alphanumeric_password(8,true)}"
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This is a standalone file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This is a hidden file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This is a file in a hidden dir
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This file name has spaces and capital characters
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This is file in a dir
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This is a file in a sub dir
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This is file 1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This is file 2
|
data/lib/siba/tmp_dir.rb
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
module Siba
|
|
4
|
+
class TmpDir
|
|
5
|
+
include Siba::FilePlug
|
|
6
|
+
include Siba::LoggerPlug
|
|
7
|
+
TmpDirPrefix = "siba-"
|
|
8
|
+
|
|
9
|
+
def initialize
|
|
10
|
+
@tmp_dir = nil
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def get
|
|
14
|
+
@tmp_dir ||= create
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def cleanup
|
|
18
|
+
siba_file.file_utils_remove_entry_secure @tmp_dir unless @tmp_dir.nil?
|
|
19
|
+
@tmp_dir = nil
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class << self
|
|
23
|
+
include Siba::FilePlug
|
|
24
|
+
include Siba::LoggerPlug
|
|
25
|
+
def test_access
|
|
26
|
+
siba_file.run_this "test access" do
|
|
27
|
+
begin
|
|
28
|
+
tmp_dir_obj = TmpDir.new
|
|
29
|
+
test_dir = tmp_dir_obj.get
|
|
30
|
+
raise unless siba_file.file_directory? test_dir
|
|
31
|
+
tmp_dir_obj.cleanup
|
|
32
|
+
rescue Exception
|
|
33
|
+
logger.error %q{Can not create temporary directory.
|
|
34
|
+
Please make sure you have write permissions to the system temporary folder.
|
|
35
|
+
You can also specify the alternative location for temporary folder in options:
|
|
36
|
+
|
|
37
|
+
settings:
|
|
38
|
+
tmp_dir: ~/your_tmp_dir
|
|
39
|
+
}
|
|
40
|
+
raise
|
|
41
|
+
end
|
|
42
|
+
logger.debug "Access to temporary directory verified"
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
protected
|
|
48
|
+
|
|
49
|
+
def create
|
|
50
|
+
siba_file.run_this "create tmp dir" do
|
|
51
|
+
tmp_dir_from_settings = Siba.settings && Siba.settings["tmp_dir"]
|
|
52
|
+
tmp_path = nil
|
|
53
|
+
if tmp_dir_from_settings.nil?
|
|
54
|
+
tmp_path = siba_file.dir_mktmpdir TmpDirPrefix
|
|
55
|
+
else
|
|
56
|
+
tmp_path = File.join(siba_file.file_expand_path(tmp_dir_from_settings),
|
|
57
|
+
"#{TmpDirPrefix}#{Siba::TestFiles.random_suffix}")
|
|
58
|
+
siba_file.file_utils_mkpath tmp_path
|
|
59
|
+
end
|
|
60
|
+
tmp_path
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
module TmpDirPlug
|
|
66
|
+
include Siba::FilePlug
|
|
67
|
+
include Siba::LoggerPlug
|
|
68
|
+
|
|
69
|
+
def tmp_dir
|
|
70
|
+
if tmp_dir_clean?
|
|
71
|
+
@tmp_dir_obj = TmpDir.new
|
|
72
|
+
@tmp_dir = @tmp_dir_obj.get
|
|
73
|
+
end
|
|
74
|
+
@tmp_dir
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def cleanup_tmp_dir
|
|
78
|
+
unless @tmp_dir_obj.nil?
|
|
79
|
+
logger.debug "Removing temporary files" if Siba::LoggerPlug.opened?
|
|
80
|
+
siba_file.file_utils_cd Siba.current_dir
|
|
81
|
+
@tmp_dir_obj.cleanup
|
|
82
|
+
@tmp_dir_obj = nil
|
|
83
|
+
end
|
|
84
|
+
@tmp_dir = nil unless @tmp_dir.nil?
|
|
85
|
+
rescue Exception => ex
|
|
86
|
+
logger.fatal "Failed to remove temporary files" if Siba::LoggerPlug.opened?
|
|
87
|
+
raise
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def tmp_dir_clean?
|
|
91
|
+
@tmp_dir.nil?
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
data/lib/siba/version.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
module Siba::C6y
|
|
4
|
+
module Demo
|
|
5
|
+
class Init
|
|
6
|
+
include Siba::FilePlug
|
|
7
|
+
include Siba::LoggerPlug
|
|
8
|
+
|
|
9
|
+
def initialize(options)
|
|
10
|
+
## init_example.rb ##
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Archive the contents of sources_dir and put it to dest_dir.
|
|
14
|
+
# Return the archive file name. It must start with dest_file_name
|
|
15
|
+
# and its ending must not vary with time.
|
|
16
|
+
def backup(sources_dir, dest_dir, dest_file_name)
|
|
17
|
+
## examples.rb ##
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Extract contents of archive file (path_to_archive) to_dir
|
|
21
|
+
# No return value is expected.
|
|
22
|
+
def restore(path_to_archive, to_dir)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
module Siba::C6y
|
|
4
|
+
module Demo
|
|
5
|
+
class Init
|
|
6
|
+
include Siba::FilePlug
|
|
7
|
+
include Siba::LoggerPlug
|
|
8
|
+
|
|
9
|
+
def initialize(options)
|
|
10
|
+
## init_example.rb ##
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Put backup file (path_to_backup_file) to destination
|
|
14
|
+
# No return value is expected
|
|
15
|
+
def backup(path_to_backup_file)
|
|
16
|
+
## examples.rb ##
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
module Siba::C6y
|
|
4
|
+
module Demo
|
|
5
|
+
class Init
|
|
6
|
+
include Siba::FilePlug
|
|
7
|
+
include Siba::LoggerPlug
|
|
8
|
+
|
|
9
|
+
def initialize(options)
|
|
10
|
+
## init_example.rb ##
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Encrypt backup archive file (path_to_archive) and put it to dest_dir.
|
|
14
|
+
# Return the name of encrypted file. It must begin with archive name
|
|
15
|
+
# and its ending must always be the same.
|
|
16
|
+
def backup(path_to_archive, dest_dir)
|
|
17
|
+
## examples.rb ##
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Decrypt backup file (path_to_backup) to_dir.
|
|
21
|
+
# Return the name of decrypted file.
|
|
22
|
+
def restore(path_to_backup, to_dir)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# A sample Guardfile
|
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
|
3
|
+
|
|
4
|
+
guard 'minitest', :notify=>false do
|
|
5
|
+
watch(%r|^test/unit/(.*\/)*test_(.*)\.rb|)
|
|
6
|
+
watch(%r|^lib/siba-c6y-demo/(.*\/)*([^/]+)\.rb|) do |m|
|
|
7
|
+
"test/unit/#{m[1]}test_#{m[2]}.rb" unless m[2][0] == '.'
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) <year> <name>
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Developing a SIBA plugin
|
|
2
|
+
|
|
3
|
+
Follow four simple steps to develop a SIBA extension plugin.
|
|
4
|
+
|
|
5
|
+
## 1. Generate project skeleton
|
|
6
|
+
|
|
7
|
+
Generate an empty project for a plugin gem:
|
|
8
|
+
|
|
9
|
+
$ siba scaffold CATEGORY plugin-name
|
|
10
|
+
|
|
11
|
+
where CATEGORY can be: source, archive, encryption or destination.
|
|
12
|
+
|
|
13
|
+
## 2. Change `init.rb` file
|
|
14
|
+
|
|
15
|
+
After the project is generated, add your code to init.rb file located in lib/your-plugin-dir. It already has all necessay methods with instructions and examples.
|
|
16
|
+
|
|
17
|
+
## 3. Change `options.yml`
|
|
18
|
+
|
|
19
|
+
Add your plugin options to `options.yml`. It is located in the same directory as `init.rb`. This file is used for `siba generate` command.
|
|
20
|
+
|
|
21
|
+
## 4. Publish
|
|
22
|
+
|
|
23
|
+
Publish your plugin gem. If you want your plugin to be shown to users by `siba list` and `siba generate` commands, please add its description to /lib/siba/plugins/plugins.yml file in SIBA project on github and issue a pull request.
|
|
24
|
+
|
|
25
|
+
## Testing
|
|
26
|
+
|
|
27
|
+
The project contains test files with examples. Two types of tests are used: unit and integration. In unit tests file system, shell and other time consuming operations are not performed.
|
|
28
|
+
|
|
29
|
+
To run unit tests:
|
|
30
|
+
rake
|
|
31
|
+
|
|
32
|
+
To run integration tests
|
|
33
|
+
rake test:i9n
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
|
2
|
+
require 'rake/testtask'
|
|
3
|
+
|
|
4
|
+
namespace "test" do
|
|
5
|
+
desc "Run all unit tests"
|
|
6
|
+
Rake::TestTask.new("unit") do |t|
|
|
7
|
+
t.pattern = "test/unit/**/test*.rb"
|
|
8
|
+
t.libs << 'test'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
desc "Run all integration tests"
|
|
12
|
+
Rake::TestTask.new("integration") do |t|
|
|
13
|
+
t.pattern = "test/integration/**/i9n_*.rb"
|
|
14
|
+
t.libs << 'test'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc "Run all integration tests"
|
|
18
|
+
task :i9n => ["test:integration"] do
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
desc "Run all unit tests"
|
|
23
|
+
task :test => ["test:unit"] do
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
desc "Run tests"
|
|
27
|
+
task :default => "test:unit"
|
|
28
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "siba-c6y-demo/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "siba-c6y-demo"
|
|
7
|
+
s.version = Siba::C6y::Demo::VERSION
|
|
8
|
+
s.authors = ["TODO: Write your name"]
|
|
9
|
+
s.email = ["TOD0: your@email.com"]
|
|
10
|
+
s.homepage = ""
|
|
11
|
+
s.summary = %q{TODO: Write a gem summary}
|
|
12
|
+
s.description = %q{TODO: Write a gem description}
|
|
13
|
+
|
|
14
|
+
s.rubyforge_project = "siba-c6y-demo"
|
|
15
|
+
|
|
16
|
+
s.files = `git ls-files`.split("\n")
|
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
19
|
+
s.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
s.add_runtime_dependency 'siba', '~>siba_version'
|
|
22
|
+
|
|
23
|
+
s.add_development_dependency 'minitest', '~>2.10'
|
|
24
|
+
s.add_development_dependency 'rake', '~>0.9'
|
|
25
|
+
s.add_development_dependency 'guard-minitest', '~>0.4'
|
|
26
|
+
end
|