siba 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. data/.gitignore +7 -0
  2. data/Gemfile +4 -0
  3. data/Guardfile +18 -0
  4. data/LICENSE +22 -0
  5. data/README.md +47 -0
  6. data/Rakefile +27 -0
  7. data/bin/siba +5 -0
  8. data/lib/siba.rb +27 -0
  9. data/lib/siba/backup.rb +31 -0
  10. data/lib/siba/console.rb +196 -0
  11. data/lib/siba/errors.rb +8 -0
  12. data/lib/siba/generator.rb +115 -0
  13. data/lib/siba/globals.rb +19 -0
  14. data/lib/siba/helpers/encoding_helper.rb +38 -0
  15. data/lib/siba/helpers/file_helper.rb +89 -0
  16. data/lib/siba/helpers/gem_helper.rb +22 -0
  17. data/lib/siba/helpers/password_strength.rb +94 -0
  18. data/lib/siba/helpers/security_helper.rb +30 -0
  19. data/lib/siba/helpers/string_helper.rb +32 -0
  20. data/lib/siba/helpers/test/extend_test.rb +114 -0
  21. data/lib/siba/helpers/test/file_mock.rb +38 -0
  22. data/lib/siba/helpers/test/helper.rb +55 -0
  23. data/lib/siba/helpers/test/kernel_mock.rb +44 -0
  24. data/lib/siba/helpers/test/removable_constants.rb +18 -0
  25. data/lib/siba/helpers/test/require.rb +12 -0
  26. data/lib/siba/logger_plug.rb +36 -0
  27. data/lib/siba/options_backup.rb +37 -0
  28. data/lib/siba/options_loader.rb +38 -0
  29. data/lib/siba/plugins/archive/tar/archive.rb +117 -0
  30. data/lib/siba/plugins/archive/tar/init.rb +38 -0
  31. data/lib/siba/plugins/archive/tar/options.yml +1 -0
  32. data/lib/siba/plugins/destination/dir/dest_dir.rb +77 -0
  33. data/lib/siba/plugins/destination/dir/init.rb +31 -0
  34. data/lib/siba/plugins/destination/dir/options.yml +2 -0
  35. data/lib/siba/plugins/encryption/gpg/encryption.rb +140 -0
  36. data/lib/siba/plugins/encryption/gpg/init.rb +45 -0
  37. data/lib/siba/plugins/encryption/gpg/options.yml +2 -0
  38. data/lib/siba/plugins/installed_plugins.rb +77 -0
  39. data/lib/siba/plugins/plugin_loader.rb +100 -0
  40. data/lib/siba/plugins/plugins.rb +57 -0
  41. data/lib/siba/plugins/plugins.yml +9 -0
  42. data/lib/siba/plugins/source/files/files.rb +166 -0
  43. data/lib/siba/plugins/source/files/init.rb +33 -0
  44. data/lib/siba/plugins/source/files/options.yml +11 -0
  45. data/lib/siba/restore.rb +113 -0
  46. data/lib/siba/scaffold.rb +166 -0
  47. data/lib/siba/siba_check.rb +75 -0
  48. data/lib/siba/siba_file.rb +89 -0
  49. data/lib/siba/siba_kernel.rb +37 -0
  50. data/lib/siba/siba_logger.rb +172 -0
  51. data/lib/siba/tasks/siba_task.rb +42 -0
  52. data/lib/siba/tasks/siba_tasks.rb +120 -0
  53. data/lib/siba/test_files.rb +76 -0
  54. data/lib/siba/test_files/a_file +1 -0
  55. data/lib/siba/test_files/files_and_dirs/.hidden +1 -0
  56. data/lib/siba/test_files/files_and_dirs/.hidden_dir/file10 +1 -0
  57. data/lib/siba/test_files/files_and_dirs/File With Spaces +1 -0
  58. data/lib/siba/test_files/files_and_dirs/dir1/file10 +1 -0
  59. data/lib/siba/test_files/files_and_dirs/dir1/sub-dir/file111.txt +1 -0
  60. data/lib/siba/test_files/files_and_dirs/file1 +1 -0
  61. data/lib/siba/test_files/files_and_dirs/file2.txt +1 -0
  62. data/lib/siba/tmp_dir.rb +94 -0
  63. data/lib/siba/version.rb +5 -0
  64. data/scaffolds/archive.rb +26 -0
  65. data/scaffolds/destination.rb +20 -0
  66. data/scaffolds/encryption.rb +26 -0
  67. data/scaffolds/project/.gitignore +5 -0
  68. data/scaffolds/project/Gemfile +4 -0
  69. data/scaffolds/project/Guardfile +9 -0
  70. data/scaffolds/project/LICENSE +22 -0
  71. data/scaffolds/project/README.md +33 -0
  72. data/scaffolds/project/Rakefile +28 -0
  73. data/scaffolds/project/lib/siba-c6y-demo.rb +11 -0
  74. data/scaffolds/project/lib/siba-c6y-demo/options.yml +2 -0
  75. data/scaffolds/project/lib/siba-c6y-demo/version.rb +9 -0
  76. data/scaffolds/project/siba-c6y-demo.gemspec +26 -0
  77. data/scaffolds/project/test/helper/require_integration.rb +5 -0
  78. data/scaffolds/project/test/helper/require_unit.rb +4 -0
  79. data/scaffolds/project/test/integration/i9n_init.rb +35 -0
  80. data/scaffolds/project/test/unit/test_init.rb +43 -0
  81. data/scaffolds/project/test/unit/yml/valid.yml +8 -0
  82. data/scaffolds/shared/examples.rb +47 -0
  83. data/scaffolds/shared/init_example.rb +13 -0
  84. data/scaffolds/source.rb +25 -0
  85. data/siba.gemspec +30 -0
  86. data/test/helper/require_integration.rb +4 -0
  87. data/test/helper/require_unit.rb +4 -0
  88. data/test/integration/helpers/i9n_file_helper.rb +50 -0
  89. data/test/integration/i9n_backup.rb +53 -0
  90. data/test/integration/i9n_console.rb +16 -0
  91. data/test/integration/i9n_generator.rb +29 -0
  92. data/test/integration/i9n_options_backup.rb +22 -0
  93. data/test/integration/i9n_scaffold.rb +27 -0
  94. data/test/integration/i9n_siba_file.rb +30 -0
  95. data/test/integration/i9n_test_unicode_files.rb +40 -0
  96. data/test/integration/i9n_tmp_dir.rb +44 -0
  97. data/test/integration/plugins/archive/tar/i9n_archive.rb +18 -0
  98. data/test/integration/plugins/destination/dir/i9n_dest_dir.rb +52 -0
  99. data/test/integration/plugins/encryption/gpg/i9n_encryption.rb +87 -0
  100. data/test/integration/plugins/i9n_installed_plugins.rb +13 -0
  101. data/test/integration/plugins/source/files/i9n_files.rb +146 -0
  102. data/test/integration/tasks/i9n_siba_tasks.rb +30 -0
  103. data/test/integration/yml/valid.yml +16 -0
  104. data/test/unit/helpers/test_encoding_helper.rb +17 -0
  105. data/test/unit/helpers/test_gem_helper.rb +17 -0
  106. data/test/unit/helpers/test_security_helper.rb +21 -0
  107. data/test/unit/helpers/test_string_helper.rb +35 -0
  108. data/test/unit/plugins/archive/tar/test_archive.rb +41 -0
  109. data/test/unit/plugins/archive/tar/test_init.rb +36 -0
  110. data/test/unit/plugins/archive/tar/yml/archive/check_installed.yml +2 -0
  111. data/test/unit/plugins/archive/tar/yml/init/default_compression.yml +1 -0
  112. data/test/unit/plugins/archive/tar/yml/init/invalid_compression.yml +2 -0
  113. data/test/unit/plugins/archive/tar/yml/init/valid.yml +2 -0
  114. data/test/unit/plugins/destination/dir/test_dest_dir.rb +41 -0
  115. data/test/unit/plugins/destination/dir/test_init.rb +36 -0
  116. data/test/unit/plugins/destination/dir/yml/init/valid.yml +2 -0
  117. data/test/unit/plugins/encryption/gpg/test_encryption.rb +70 -0
  118. data/test/unit/plugins/encryption/gpg/test_init.rb +47 -0
  119. data/test/unit/plugins/source/files/test_files.rb +44 -0
  120. data/test/unit/plugins/source/files/test_init.rb +48 -0
  121. data/test/unit/plugins/source/files/test_path_match.rb +140 -0
  122. data/test/unit/plugins/source/files/yml/ignore_list.yml +8 -0
  123. data/test/unit/plugins/source/files/yml/ignore_not_array.yml +5 -0
  124. data/test/unit/plugins/source/files/yml/include_not_array.yml +3 -0
  125. data/test/unit/plugins/source/files/yml/include_subdirs_false.yml +6 -0
  126. data/test/unit/plugins/source/files/yml/include_subdirs_missing.yml +5 -0
  127. data/test/unit/plugins/source/files/yml/no_ignore.yml +4 -0
  128. data/test/unit/plugins/source/files/yml/no_include.yml +1 -0
  129. data/test/unit/plugins/source/files/yml/valid.yml +9 -0
  130. data/test/unit/plugins/test_installed_plugins.rb +32 -0
  131. data/test/unit/plugins/test_plugin_loader.rb +27 -0
  132. data/test/unit/plugins/test_plugins.rb +44 -0
  133. data/test/unit/tasks/test_siba_task.rb +30 -0
  134. data/test/unit/tasks/test_siba_tasks.rb +84 -0
  135. data/test/unit/tasks/yml/task/invalid.yml +4 -0
  136. data/test/unit/tasks/yml/task/valid.yml +7 -0
  137. data/test/unit/test_backup.rb +18 -0
  138. data/test/unit/test_console.rb +166 -0
  139. data/test/unit/test_generator.rb +21 -0
  140. data/test/unit/test_globals.rb +34 -0
  141. data/test/unit/test_log_message.rb +26 -0
  142. data/test/unit/test_logger_plug.rb +49 -0
  143. data/test/unit/test_options_backup.rb +21 -0
  144. data/test/unit/test_options_loader.rb +72 -0
  145. data/test/unit/test_password_strength.rb +76 -0
  146. data/test/unit/test_restore.rb +18 -0
  147. data/test/unit/test_scaffold.rb +26 -0
  148. data/test/unit/test_siba_check.rb +118 -0
  149. data/test/unit/test_siba_logger.rb +174 -0
  150. data/test/unit/test_tmp_dir.rb +21 -0
  151. data/test/unit/yml/options_loader/array.yml +2 -0
  152. data/test/unit/yml/options_loader/empty.yml +0 -0
  153. data/test/unit/yml/options_loader/invalid.yml +4 -0
  154. data/test/unit/yml/options_loader/string.yml +1 -0
  155. data/test/unit/yml/options_loader/utf8_with_bom.yml +2 -0
  156. data/test/unit/yml/options_loader/valid.yml +12 -0
  157. data/test/unit/yml/siba_options_backup.yml +20 -0
  158. data/test/unit/yml/valid.yml +18 -0
  159. metadata +240 -0
@@ -0,0 +1,18 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'helper/require_unit'
4
+
5
+ describe Siba::Restore do
6
+ before do
7
+ @yml_path = File.expand_path('../yml', __FILE__)
8
+ end
9
+
10
+ it "should call restore" do
11
+ Siba::LoggerPlug.close
12
+ Siba::SibaLogger.quiet = true
13
+ path_to_options_file = File.join @yml_path, "valid.yml"
14
+ Siba::Restore.new.restore path_to_options_file
15
+ wont_log_from "warn"
16
+ Siba.tmp_dir_clean?.must_equal true
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'helper/require_unit'
4
+
5
+ describe Siba::Scaffold do
6
+ before do
7
+ @obj = Siba::Scaffold.new "source", "gem___Name*%@#"
8
+ end
9
+
10
+ it "should init category and name" do
11
+ @obj.category.must_equal "source"
12
+ @obj.name.must_equal "gem-name"
13
+ end
14
+
15
+ it "should fail to init if first name character is number" do
16
+ ->{Siba::Scaffold.new "source", "2gem___Name*%@#"}.must_raise Siba::Error
17
+ end
18
+
19
+ it "should fail to init if invalid category" do
20
+ ->{Siba::Scaffold.new "invalid", "name"}.must_raise Siba::Error
21
+ end
22
+
23
+ it "should call scaffold" do
24
+ @obj.scaffold "/dest-dir"
25
+ end
26
+ end
@@ -0,0 +1,118 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'helper/require_unit'
4
+
5
+ describe Siba::SibaCheck do
6
+ before do
7
+ @cls = Siba::SibaCheck
8
+ end
9
+
10
+ it "should call options_string_array" do
11
+ obj = {"name"=>["1","2"]}
12
+ @cls.options_string_array(obj, "name", false).must_equal obj["name"]
13
+ end
14
+
15
+ it "options_string_array should raise if option is not defined" do
16
+ ->{@cls.options_string_array({"name"=>["1","2"]}, "not exist")}.must_raise Siba::CheckError
17
+ end
18
+
19
+ it "options_string_array should return detaul value" do
20
+ default = ["default"]
21
+ @cls.options_string_array({"name"=>["1","2"]}, "not exist", true, default).must_equal default
22
+ end
23
+
24
+ it "options_string_array should accept a string" do
25
+ obj = {"name"=>"just a string"}
26
+ @cls.options_string_array(obj, "name", false).must_equal [obj["name"]]
27
+ @cls.options_string_array({"name"=>123}, "name", false).must_equal ["123"]
28
+ end
29
+
30
+ it "options_string_array should accept an array and convert values to strings" do
31
+ @cls.options_string_array({"name"=>[1, 5.5, "hello"]}, "name", false)
32
+ .must_equal ["1", "5.5", "hello"]
33
+ end
34
+
35
+ it "options_string_array should fail if contains a hash" do
36
+ ->{@cls.options_string_array({"name"=>{}}, "name", false)}.must_raise Siba::CheckError
37
+ end
38
+
39
+ it "options_string_array should fail if it contains empty or nil values" do
40
+ ->{@cls.options_string_array({"name"=>" "}, "name", false)}.must_raise Siba::CheckError
41
+ ->{@cls.options_string_array({"name"=>nil}, "name", false)}.must_raise Siba::CheckError
42
+ ->{@cls.options_string_array({"name"=>["1", " "]}, "name", false)}.must_raise Siba::CheckError
43
+ ->{@cls.options_string_array({"name"=>["1", nil]}, "name", false)}.must_raise Siba::CheckError
44
+ end
45
+
46
+ it "should call options_bool" do
47
+ @cls.options_bool({"name"=>true},"name").must_equal true
48
+ @cls.options_bool({"name"=>false},"name").must_equal false
49
+ end
50
+
51
+ it "options_bool should raise error" do
52
+ ->{@cls.options_bool({"name"=>true},"missing")}.must_raise Siba::CheckError
53
+ ->{@cls.options_bool({"name"=>"non bool"},"name")}.must_raise Siba::CheckError
54
+ end
55
+
56
+ it "options_bool should return default_value if missing" do
57
+ @cls.options_bool({"name"=>true},"missing", true).must_equal false
58
+ @cls.options_bool({"name"=>true},"missing", true, true).must_equal true
59
+ @cls.options_bool({"name"=>true},"missing", true, false).must_equal false
60
+ end
61
+
62
+ it "should call options_hash" do
63
+ hash = {"key"=>"value"}
64
+ options = {"name" =>hash}
65
+ @cls.options_hash(options,"name").must_equal hash
66
+ @cls.options_hash(options,"missing", true).must_be_nil
67
+ def_hash = {"one"=>"two"}
68
+ @cls.options_hash(options,"missing", true, def_hash).must_equal def_hash
69
+ end
70
+
71
+ it "options_hash should raise error" do
72
+ ->{@cls.options_hash({"name"=>true},"missing")}.must_raise Siba::CheckError
73
+ ->{@cls.options_hash({"name"=>"non hash"},"name")}.must_raise Siba::CheckError
74
+ end
75
+
76
+ it "should call hash" do
77
+ hash = {"key"=>"value"}
78
+ @cls.hash(hash, "name").must_equal hash
79
+ @cls.hash(nil, "name", true).must_be_nil
80
+ end
81
+
82
+ it "hash should raise errors" do
83
+ ->{@cls.hash("non hash","name")}.must_raise Siba::CheckError
84
+ end
85
+
86
+ it "should call options_string" do
87
+ @cls.options_string({"name"=>"value"},"name").must_equal "value"
88
+ @cls.options_string({"name"=>123},"name").must_equal "123"
89
+ @cls.options_string({"name"=>1000000000000000000000000000000},"name").must_equal "1000000000000000000000000000000"
90
+ @cls.options_string({"name"=>123.12},"name").must_equal "123.12"
91
+ @cls.options_string({"name"=>"value"},"missing", true, "default").must_equal "default"
92
+ @cls.options_string({"name"=>"value"},"missing", true, nil).must_be_nil
93
+ end
94
+
95
+ it "options_string should fail if value is array or hash" do
96
+ ->{@cls.options_string({"name"=>[1,2,3]},"name")}.must_raise Siba::CheckError
97
+ ->{@cls.options_string({"name"=>{:name=>:value}},"name")}.must_raise Siba::CheckError
98
+ end
99
+
100
+ it "options_string should fail if value missing" do
101
+ ->{@cls.options_string({"name"=>"value"},"missing")}.must_raise Siba::CheckError
102
+ ->{@cls.options_string({"name"=>nil},"name")}.must_raise Siba::CheckError
103
+ ->{@cls.options_string({"name"=>""},"name")}.must_raise Siba::CheckError
104
+ ->{@cls.options_string({"name"=>" "},"name")}.must_raise Siba::CheckError
105
+ end
106
+
107
+ it "should call try_to_s" do
108
+ @cls.try_to_s("str", "name").must_equal "str"
109
+ @cls.try_to_s(22, "name").must_equal "22"
110
+ @cls.try_to_s(11.12, "name").must_equal "11.12"
111
+ @cls.try_to_s(10000000000000000000000000000000000, "name").must_equal "10000000000000000000000000000000000"
112
+ end
113
+
114
+ it "try_to_s should fail" do
115
+ ->{@cls.try_to_s([1], "name")}.must_raise Siba::CheckError
116
+ ->{@cls.try_to_s(" ", "name")}.must_raise Siba::CheckError
117
+ end
118
+ end
@@ -0,0 +1,174 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'helper/require_unit'
4
+
5
+ describe Siba::SibaLogger do
6
+ before do
7
+ @logger = Siba::SibaLogger.new "Test", nil
8
+ end
9
+
10
+ describe "when access class" do
11
+ it "must access quiet" do
12
+ Siba::SibaLogger.quiet = true
13
+ Siba::SibaLogger.quiet.must_equal true
14
+ end
15
+
16
+ it "must access verbose" do
17
+ Siba::SibaLogger.verbose = true
18
+ Siba::SibaLogger.verbose.must_equal true
19
+ end
20
+
21
+ it "must access no_log" do
22
+ Siba::SibaLogger.no_log = true
23
+ Siba::SibaLogger.no_log.must_equal true
24
+ end
25
+
26
+ it "must contain LogLevels" do
27
+ Siba::SibaLogger::LogLevels.must_include "debug"
28
+ Siba::SibaLogger::LogLevels.must_include "info"
29
+ Siba::SibaLogger::LogLevels.must_include "warn"
30
+ Siba::SibaLogger::LogLevels.must_include "error"
31
+ Siba::SibaLogger::LogLevels.must_include "fatal"
32
+ Siba::SibaLogger::LogLevels.must_include "unknown"
33
+ end
34
+
35
+ it "must check given log level" do
36
+ Siba::SibaLogger.log_level?("info").must_equal true
37
+ Siba::SibaLogger.log_level?("chelyabinsk").must_equal false
38
+ end
39
+
40
+ it "must have check_log_level method" do
41
+ Siba::SibaLogger::check_log_level "info"
42
+ end
43
+
44
+ it "check_log_level must raise for unsupported level" do
45
+ -> { Siba::SibaLogger::check_log_level("weird") }.must_raise RuntimeError
46
+ end
47
+
48
+ it "must return log level integer" do
49
+ Siba::SibaLogger.level_to_i("debug").must_equal 0
50
+ Siba::SibaLogger.level_to_i("info").must_equal 1
51
+ Siba::SibaLogger.level_to_i("warn").must_equal 2
52
+ Siba::SibaLogger.level_to_i("error").must_equal 3
53
+ Siba::SibaLogger.level_to_i("fatal").must_equal 4
54
+ Siba::SibaLogger.level_to_i("unknown").must_equal 5
55
+ end
56
+
57
+ it "must call count" do
58
+ Siba::SibaLogger.count.must_equal 1
59
+ end
60
+
61
+ it "count should work when logger is closed" do
62
+ Siba::LoggerPlug.close
63
+ Siba::SibaLogger.messages = nil
64
+ Siba::SibaLogger.count("warn").must_equal 0
65
+ end
66
+ end
67
+
68
+ describe "when access logger" do
69
+ it "must initialize SibaLogger" do
70
+ @logger.wont_be_nil
71
+ Siba::SibaLogger.count("info").must_equal 1, "Must contain 'log start' message"
72
+ end
73
+
74
+ it "must initialize variables" do
75
+ Siba::SibaLogger.messages.must_be_instance_of Array
76
+ Siba::SibaLogger.count.must_equal 1
77
+ end
78
+
79
+ it "should call log methods" do
80
+ @logger.debug "msg"
81
+ @logger.info "msg"
82
+ @logger.warn "msg"
83
+ @logger.error "msg"
84
+ @logger.fatal "msg"
85
+ @logger.unknown "msg"
86
+ end
87
+
88
+ it "should contains messages" do
89
+ @logger.debug "msg1"
90
+ @logger.info "msg2"
91
+ @logger.warn "msg3"
92
+
93
+ Siba::SibaLogger.messages.size.must_equal 4
94
+ Siba::SibaLogger.messages[1].must_be_instance_of Siba::LogMessage
95
+ Siba::SibaLogger.messages[1].msg.must_equal "msg1"
96
+ Siba::SibaLogger.messages[1].level.must_equal Siba::SibaLogger.level_to_i("debug")
97
+ Siba::SibaLogger.messages[1].time.must_be_instance_of Time
98
+ Siba::SibaLogger.messages[3].msg.must_equal "msg3"
99
+ Siba::SibaLogger.messages[3].level.must_equal Siba::SibaLogger.level_to_i("warn")
100
+ end
101
+
102
+ it "should raise when called missing method" do
103
+ ->{ @logger.this_is_a_missing_method("msg") }.must_raise NoMethodError
104
+ end
105
+
106
+ it "should log on different levels" do
107
+ Siba::SibaLogger::LogLevels.each do |level|
108
+ Siba::SibaLogger.count(level, true).must_equal (level == "info" ? 1 : 0)
109
+ end
110
+
111
+ Siba::SibaLogger::LogLevels.each do |level|
112
+ @logger.send(level,"#{level} message")
113
+ end
114
+
115
+ Siba::SibaLogger::LogLevels.each do |level|
116
+ Siba::SibaLogger.count(level, true).must_equal (level == "info" ? 2 : 1)
117
+ end
118
+ end
119
+
120
+ it "count must return correct number of message for severity lever" do
121
+ @logger.debug "msg1"
122
+ @logger.info "msg2"
123
+ @logger.info "msg3"
124
+ @logger.warn "msg4"
125
+ @logger.error "msg5"
126
+ @logger.error "msg6"
127
+ @logger.error "msg7"
128
+ @logger.fatal "msg8"
129
+ @logger.fatal "msg9"
130
+ @logger.unknown "msg10"
131
+
132
+ Siba::SibaLogger.count.must_equal 11
133
+ Siba::SibaLogger.count("debug", false).must_equal 11
134
+ Siba::SibaLogger.count("debug").must_equal 1
135
+ Siba::SibaLogger.count("info", false).must_equal 10
136
+ Siba::SibaLogger.count("info").must_equal 3
137
+ Siba::SibaLogger.count("warn", false).must_equal 7
138
+ Siba::SibaLogger.count("error", false).must_equal 6
139
+ Siba::SibaLogger.count("error").must_equal 3
140
+ Siba::SibaLogger.count("fatal", false).must_equal 3
141
+ Siba::SibaLogger.count("fatal", true).must_equal 2
142
+ end
143
+
144
+ it "must call log_exception" do
145
+ @logger.log_exception Exception.new "hello"
146
+ Siba::SibaLogger.count("debug",true).must_equal 1
147
+ end
148
+
149
+ it "must call log backtrace with_exception" do
150
+ ex = Exception.new "hello"
151
+ ex.set_backtrace ["one","two","tree"]
152
+ @logger.log_exception ex
153
+ Siba::SibaLogger.count("debug",true).must_equal 2
154
+ end
155
+
156
+ it "must close logger" do
157
+ @logger.close
158
+ Siba::SibaLogger.count.must_equal 2
159
+ ->{@logger.info "hi"}.must_raise Siba::Error, "Error if trying to use closed log"
160
+ end
161
+
162
+ it "to_s should show logs string" do
163
+ test_message = "this is a test message"
164
+ @logger.info test_message
165
+ @logger.to_s.must_match /#{test_message}$/
166
+ end
167
+
168
+ it "should access :show_finish_message" do
169
+ @logger.show_finish_message = false
170
+ @logger.close
171
+ Siba::SibaLogger.messages.size.must_equal 1
172
+ end
173
+ end
174
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'helper/require_unit'
4
+
5
+ describe Siba::TmpDir do
6
+ before do
7
+ @tmp_dir_obj = Siba::TmpDir.new
8
+ end
9
+
10
+ it "should call get" do
11
+ @tmp_dir_obj.get
12
+ end
13
+
14
+ it "should call test_access" do
15
+ Siba::TmpDir.test_access
16
+ end
17
+
18
+ it "should call cleanup" do
19
+ @tmp_dir_obj.cleanup
20
+ end
21
+ end
@@ -0,0 +1,2 @@
1
+ - one
2
+ - two
File without changes
@@ -0,0 +1,4 @@
1
+ invalid: invalid: invalid
2
+
3
+
4
+
@@ -0,0 +1 @@
1
+ this is text
@@ -0,0 +1,2 @@
1
+ key: value
2
+ another: дорога
@@ -0,0 +1,12 @@
1
+ source:
2
+ type: files
3
+ include:
4
+ - dir1/
5
+ - dir2/subdir2/
6
+ - file1
7
+ destination:
8
+ type: dir
9
+ dir: somedir/
10
+ erb: <%= 2*2 %>
11
+ settings:
12
+ key: value
@@ -0,0 +1,20 @@
1
+ source:
2
+ type: files
3
+ include:
4
+ - dir1
5
+ - dir2/subdir2
6
+ - file1
7
+ - /folder
8
+
9
+ archive:
10
+ type: tar
11
+
12
+ encryption:
13
+ type: gpg
14
+ passphrase: "this is a passphrase"
15
+
16
+ destination:
17
+ type: dir
18
+ dir: /dest-dir
19
+
20
+ current_dir: /tmp/dir
@@ -0,0 +1,18 @@
1
+ source:
2
+ type: files
3
+ include:
4
+ - dir1
5
+ - dir2/subdir2
6
+ - file1
7
+ - /папка/файл
8
+
9
+ archive:
10
+ type: tar
11
+
12
+ encryption:
13
+ type: gpg
14
+ passphrase: "this is a passphrase"
15
+
16
+ destination:
17
+ type: dir
18
+ dir: /dest-dir
metadata ADDED
@@ -0,0 +1,240 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: siba
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Evgeny Neumerzhitskiy
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: minitest
16
+ requirement: &70797610 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2.10'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70797610
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &70797180 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '0.9'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70797180
36
+ - !ruby/object:Gem::Dependency
37
+ name: guard-minitest
38
+ requirement: &70796680 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '0.4'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70796680
47
+ description: ! 'This is a backup and restore utility. SIBA implements backup rotation
48
+ scheme. It retains a one year history of backups by keeping up to 23 files: 6 daily,
49
+ 5 weekly and 12 monthly backups. Backups are compressed and encrypted. Various backup
50
+ sources and destinations can be added through extension gems.'
51
+ email:
52
+ - sausageskin@gmail.com
53
+ executables:
54
+ - siba
55
+ extensions: []
56
+ extra_rdoc_files: []
57
+ files:
58
+ - .gitignore
59
+ - Gemfile
60
+ - Guardfile
61
+ - LICENSE
62
+ - README.md
63
+ - Rakefile
64
+ - bin/siba
65
+ - lib/siba.rb
66
+ - lib/siba/backup.rb
67
+ - lib/siba/console.rb
68
+ - lib/siba/errors.rb
69
+ - lib/siba/generator.rb
70
+ - lib/siba/globals.rb
71
+ - lib/siba/helpers/encoding_helper.rb
72
+ - lib/siba/helpers/file_helper.rb
73
+ - lib/siba/helpers/gem_helper.rb
74
+ - lib/siba/helpers/password_strength.rb
75
+ - lib/siba/helpers/security_helper.rb
76
+ - lib/siba/helpers/string_helper.rb
77
+ - lib/siba/helpers/test/extend_test.rb
78
+ - lib/siba/helpers/test/file_mock.rb
79
+ - lib/siba/helpers/test/helper.rb
80
+ - lib/siba/helpers/test/kernel_mock.rb
81
+ - lib/siba/helpers/test/removable_constants.rb
82
+ - lib/siba/helpers/test/require.rb
83
+ - lib/siba/logger_plug.rb
84
+ - lib/siba/options_backup.rb
85
+ - lib/siba/options_loader.rb
86
+ - lib/siba/plugins/archive/tar/archive.rb
87
+ - lib/siba/plugins/archive/tar/init.rb
88
+ - lib/siba/plugins/archive/tar/options.yml
89
+ - lib/siba/plugins/destination/dir/dest_dir.rb
90
+ - lib/siba/plugins/destination/dir/init.rb
91
+ - lib/siba/plugins/destination/dir/options.yml
92
+ - lib/siba/plugins/encryption/gpg/encryption.rb
93
+ - lib/siba/plugins/encryption/gpg/init.rb
94
+ - lib/siba/plugins/encryption/gpg/options.yml
95
+ - lib/siba/plugins/installed_plugins.rb
96
+ - lib/siba/plugins/plugin_loader.rb
97
+ - lib/siba/plugins/plugins.rb
98
+ - lib/siba/plugins/plugins.yml
99
+ - lib/siba/plugins/source/files/files.rb
100
+ - lib/siba/plugins/source/files/init.rb
101
+ - lib/siba/plugins/source/files/options.yml
102
+ - lib/siba/restore.rb
103
+ - lib/siba/scaffold.rb
104
+ - lib/siba/siba_check.rb
105
+ - lib/siba/siba_file.rb
106
+ - lib/siba/siba_kernel.rb
107
+ - lib/siba/siba_logger.rb
108
+ - lib/siba/tasks/siba_task.rb
109
+ - lib/siba/tasks/siba_tasks.rb
110
+ - lib/siba/test_files.rb
111
+ - lib/siba/test_files/a_file
112
+ - lib/siba/test_files/files_and_dirs/.hidden
113
+ - lib/siba/test_files/files_and_dirs/.hidden_dir/file10
114
+ - lib/siba/test_files/files_and_dirs/File With Spaces
115
+ - lib/siba/test_files/files_and_dirs/dir1/file10
116
+ - lib/siba/test_files/files_and_dirs/dir1/sub-dir/file111.txt
117
+ - lib/siba/test_files/files_and_dirs/file1
118
+ - lib/siba/test_files/files_and_dirs/file2.txt
119
+ - lib/siba/tmp_dir.rb
120
+ - lib/siba/version.rb
121
+ - scaffolds/archive.rb
122
+ - scaffolds/destination.rb
123
+ - scaffolds/encryption.rb
124
+ - scaffolds/project/.gitignore
125
+ - scaffolds/project/Gemfile
126
+ - scaffolds/project/Guardfile
127
+ - scaffolds/project/LICENSE
128
+ - scaffolds/project/README.md
129
+ - scaffolds/project/Rakefile
130
+ - scaffolds/project/lib/siba-c6y-demo.rb
131
+ - scaffolds/project/lib/siba-c6y-demo/options.yml
132
+ - scaffolds/project/lib/siba-c6y-demo/version.rb
133
+ - scaffolds/project/siba-c6y-demo.gemspec
134
+ - scaffolds/project/test/helper/require_integration.rb
135
+ - scaffolds/project/test/helper/require_unit.rb
136
+ - scaffolds/project/test/integration/i9n_init.rb
137
+ - scaffolds/project/test/unit/test_init.rb
138
+ - scaffolds/project/test/unit/yml/valid.yml
139
+ - scaffolds/shared/examples.rb
140
+ - scaffolds/shared/init_example.rb
141
+ - scaffolds/source.rb
142
+ - siba.gemspec
143
+ - test/helper/require_integration.rb
144
+ - test/helper/require_unit.rb
145
+ - test/integration/helpers/i9n_file_helper.rb
146
+ - test/integration/i9n_backup.rb
147
+ - test/integration/i9n_console.rb
148
+ - test/integration/i9n_generator.rb
149
+ - test/integration/i9n_options_backup.rb
150
+ - test/integration/i9n_scaffold.rb
151
+ - test/integration/i9n_siba_file.rb
152
+ - test/integration/i9n_test_unicode_files.rb
153
+ - test/integration/i9n_tmp_dir.rb
154
+ - test/integration/plugins/archive/tar/i9n_archive.rb
155
+ - test/integration/plugins/destination/dir/i9n_dest_dir.rb
156
+ - test/integration/plugins/encryption/gpg/i9n_encryption.rb
157
+ - test/integration/plugins/i9n_installed_plugins.rb
158
+ - test/integration/plugins/source/files/i9n_files.rb
159
+ - test/integration/tasks/i9n_siba_tasks.rb
160
+ - test/integration/yml/valid.yml
161
+ - test/unit/helpers/test_encoding_helper.rb
162
+ - test/unit/helpers/test_gem_helper.rb
163
+ - test/unit/helpers/test_security_helper.rb
164
+ - test/unit/helpers/test_string_helper.rb
165
+ - test/unit/plugins/archive/tar/test_archive.rb
166
+ - test/unit/plugins/archive/tar/test_init.rb
167
+ - test/unit/plugins/archive/tar/yml/archive/check_installed.yml
168
+ - test/unit/plugins/archive/tar/yml/init/default_compression.yml
169
+ - test/unit/plugins/archive/tar/yml/init/invalid_compression.yml
170
+ - test/unit/plugins/archive/tar/yml/init/valid.yml
171
+ - test/unit/plugins/destination/dir/test_dest_dir.rb
172
+ - test/unit/plugins/destination/dir/test_init.rb
173
+ - test/unit/plugins/destination/dir/yml/init/valid.yml
174
+ - test/unit/plugins/encryption/gpg/test_encryption.rb
175
+ - test/unit/plugins/encryption/gpg/test_init.rb
176
+ - test/unit/plugins/source/files/test_files.rb
177
+ - test/unit/plugins/source/files/test_init.rb
178
+ - test/unit/plugins/source/files/test_path_match.rb
179
+ - test/unit/plugins/source/files/yml/ignore_list.yml
180
+ - test/unit/plugins/source/files/yml/ignore_not_array.yml
181
+ - test/unit/plugins/source/files/yml/include_not_array.yml
182
+ - test/unit/plugins/source/files/yml/include_subdirs_false.yml
183
+ - test/unit/plugins/source/files/yml/include_subdirs_missing.yml
184
+ - test/unit/plugins/source/files/yml/no_ignore.yml
185
+ - test/unit/plugins/source/files/yml/no_include.yml
186
+ - test/unit/plugins/source/files/yml/valid.yml
187
+ - test/unit/plugins/test_installed_plugins.rb
188
+ - test/unit/plugins/test_plugin_loader.rb
189
+ - test/unit/plugins/test_plugins.rb
190
+ - test/unit/tasks/test_siba_task.rb
191
+ - test/unit/tasks/test_siba_tasks.rb
192
+ - test/unit/tasks/yml/task/invalid.yml
193
+ - test/unit/tasks/yml/task/valid.yml
194
+ - test/unit/test_backup.rb
195
+ - test/unit/test_console.rb
196
+ - test/unit/test_generator.rb
197
+ - test/unit/test_globals.rb
198
+ - test/unit/test_log_message.rb
199
+ - test/unit/test_logger_plug.rb
200
+ - test/unit/test_options_backup.rb
201
+ - test/unit/test_options_loader.rb
202
+ - test/unit/test_password_strength.rb
203
+ - test/unit/test_restore.rb
204
+ - test/unit/test_scaffold.rb
205
+ - test/unit/test_siba_check.rb
206
+ - test/unit/test_siba_logger.rb
207
+ - test/unit/test_tmp_dir.rb
208
+ - test/unit/yml/options_loader/array.yml
209
+ - test/unit/yml/options_loader/empty.yml
210
+ - test/unit/yml/options_loader/invalid.yml
211
+ - test/unit/yml/options_loader/string.yml
212
+ - test/unit/yml/options_loader/utf8_with_bom.yml
213
+ - test/unit/yml/options_loader/valid.yml
214
+ - test/unit/yml/siba_options_backup.yml
215
+ - test/unit/yml/valid.yml
216
+ homepage: ''
217
+ licenses: []
218
+ post_install_message:
219
+ rdoc_options: []
220
+ require_paths:
221
+ - lib
222
+ required_ruby_version: !ruby/object:Gem::Requirement
223
+ none: false
224
+ requirements:
225
+ - - ! '>='
226
+ - !ruby/object:Gem::Version
227
+ version: '0'
228
+ required_rubygems_version: !ruby/object:Gem::Requirement
229
+ none: false
230
+ requirements:
231
+ - - ~>
232
+ - !ruby/object:Gem::Version
233
+ version: '1.8'
234
+ requirements: []
235
+ rubyforge_project: siba
236
+ rubygems_version: 1.8.11
237
+ signing_key:
238
+ specification_version: 3
239
+ summary: Simple backup and restore utility.
240
+ test_files: []