rbatch 1.4.0 → 1.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/LICENSE +0 -0
- data/README.ja.md +1 -13
- data/README.md +2 -13
- data/Rakefile +1 -24
- metadata +12 -123
- data/CHANGELOG +0 -25
- data/VERSION +0 -1
- data/doc/rdoc/CHANGELOG.html +0 -160
- data/doc/rdoc/LICENSE.html +0 -94
- data/doc/rdoc/RBatch/Cmd.html +0 -329
- data/doc/rdoc/RBatch/CmdException.html +0 -154
- data/doc/rdoc/RBatch/CmdResult.html +0 -492
- data/doc/rdoc/RBatch/Log.html +0 -739
- data/doc/rdoc/RBatch.html +0 -476
- data/doc/rdoc/created.rid +0 -8
- data/doc/rdoc/images/brick.png +0 -0
- data/doc/rdoc/images/brick_link.png +0 -0
- data/doc/rdoc/images/bug.png +0 -0
- data/doc/rdoc/images/bullet_black.png +0 -0
- data/doc/rdoc/images/bullet_toggle_minus.png +0 -0
- data/doc/rdoc/images/bullet_toggle_plus.png +0 -0
- data/doc/rdoc/images/date.png +0 -0
- data/doc/rdoc/images/find.png +0 -0
- data/doc/rdoc/images/loadingAnimation.gif +0 -0
- data/doc/rdoc/images/macFFBgHack.png +0 -0
- data/doc/rdoc/images/package.png +0 -0
- data/doc/rdoc/images/page_green.png +0 -0
- data/doc/rdoc/images/page_white_text.png +0 -0
- data/doc/rdoc/images/page_white_width.png +0 -0
- data/doc/rdoc/images/plugin.png +0 -0
- data/doc/rdoc/images/ruby.png +0 -0
- data/doc/rdoc/images/tag_green.png +0 -0
- data/doc/rdoc/images/wrench.png +0 -0
- data/doc/rdoc/images/wrench_orange.png +0 -0
- data/doc/rdoc/images/zoom.png +0 -0
- data/doc/rdoc/index.html +0 -124
- data/doc/rdoc/js/darkfish.js +0 -116
- data/doc/rdoc/js/jquery.js +0 -32
- data/doc/rdoc/js/quicksearch.js +0 -114
- data/doc/rdoc/js/thickbox-compressed.js +0 -10
- data/doc/rdoc/lib/rbatch/cmd_rb.html +0 -56
- data/doc/rdoc/lib/rbatch/config_rb.html +0 -56
- data/doc/rdoc/lib/rbatch/log_rb.html +0 -58
- data/doc/rdoc/lib/rbatch_rb.html +0 -58
- data/doc/rdoc/rdoc.css +0 -706
- data/sample/bin/file_batch_copy.rb +0 -9
- data/sample/bin/openldap_backup.rb +0 -7
- data/sample/bin/test.rb +0 -12
- data/sample/config/file_batch_copy.yaml +0 -5
- data/sample/config/openldap_backup.yaml +0 -2
- data/sample/config/rbatch.yaml +0 -68
- data/sample/log/empty +0 -0
- data/test/cases/test_cmd.rb +0 -120
- data/test/cases/test_config.rb +0 -34
- data/test/cases/test_log.rb +0 -594
- data/test/config/rbatch.yaml +0 -0
- data/test/mocks/PrintArgs.exe +0 -0
- data/test/mocks/win_cmd.exe +0 -0
data/sample/config/rbatch.yaml
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
# RBatch config
|
2
|
-
#
|
3
|
-
# This file format is YAML
|
4
|
-
#
|
5
|
-
|
6
|
-
# -------------------
|
7
|
-
# Global setting
|
8
|
-
# -------------------
|
9
|
-
|
10
|
-
# Forbit Double Run
|
11
|
-
#
|
12
|
-
# Default : false
|
13
|
-
#
|
14
|
-
#forbid_double_run: true
|
15
|
-
|
16
|
-
# -------------------
|
17
|
-
# Cmd setting
|
18
|
-
# -------------------
|
19
|
-
|
20
|
-
# Raise Exception
|
21
|
-
#
|
22
|
-
# Default : false
|
23
|
-
#
|
24
|
-
# If command exit status is not 0, raise exception.
|
25
|
-
#
|
26
|
-
cmd_raise : true
|
27
|
-
|
28
|
-
|
29
|
-
# -------------------
|
30
|
-
# Log setting
|
31
|
-
# -------------------
|
32
|
-
|
33
|
-
# Log File Name
|
34
|
-
#
|
35
|
-
# Default : "<date>_<time>_<prog>.log"
|
36
|
-
#
|
37
|
-
# Reservation words
|
38
|
-
# <data> --> replace to YYYYMMDD date string
|
39
|
-
# <time> --> replace to hhmmss time string
|
40
|
-
# <prog> --> Program file base name (except extention)
|
41
|
-
#
|
42
|
-
#log_name : "<date>_<time>_<prog>.log"
|
43
|
-
log_name : "<date>_<prog>.log"
|
44
|
-
|
45
|
-
# Log Output Directory
|
46
|
-
#
|
47
|
-
# Default : "(Script path)/../log"
|
48
|
-
#
|
49
|
-
#log_dir : "/tmp/log"
|
50
|
-
|
51
|
-
# Append log or not
|
52
|
-
#
|
53
|
-
# Default : ture
|
54
|
-
#
|
55
|
-
#log_append : false
|
56
|
-
|
57
|
-
# Log Level
|
58
|
-
#
|
59
|
-
# Default : "info"
|
60
|
-
# Value : "debug","info","wran","error","fatal"
|
61
|
-
#
|
62
|
-
#log_level : "debug"
|
63
|
-
|
64
|
-
# Print log-string both file and STDOUT
|
65
|
-
#
|
66
|
-
# Default : false
|
67
|
-
#
|
68
|
-
log_stdout : true
|
data/sample/log/empty
DELETED
File without changes
|
data/test/cases/test_cmd.rb
DELETED
@@ -1,120 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'rbatch'
|
3
|
-
|
4
|
-
class RuncherTest < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@config_dir = File.join(File.dirname(RBatch.program_name), "..", "config")
|
7
|
-
Dir::mkdir(@config_dir) if ! Dir.exists? @config_dir
|
8
|
-
confstr = ""
|
9
|
-
open( RBatch.common_config_path , "w" ){|f| f.write(confstr)}
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_cmd_exists
|
13
|
-
result = RBatch::cmd "ruby -e 'STDOUT.print 1; STDERR.print 2; exit 0;'"
|
14
|
-
assert_equal "1", result.stdout.chomp
|
15
|
-
assert_equal "2", result.stderr.chomp
|
16
|
-
assert_equal 0, result.status
|
17
|
-
end
|
18
|
-
def test_cmd_does_not_exist
|
19
|
-
assert_raise(Errno::ENOENT){
|
20
|
-
RBatch::cmd "not_exist_command"
|
21
|
-
}
|
22
|
-
end
|
23
|
-
def test_stdout_size_greater_than_65534
|
24
|
-
result = RBatch::cmd "ruby -e '100000.times{print 0}'"
|
25
|
-
assert_equal 100000, result.stdout.chomp.size
|
26
|
-
assert_equal "", result.stderr.chomp
|
27
|
-
assert_equal 0, result.status
|
28
|
-
end
|
29
|
-
def test_stdout_size_greater_than_65534_with_status_1
|
30
|
-
result = RBatch::cmd "ruby -e '100000.times{print 0}; exit 1'"
|
31
|
-
assert_equal 100000, result.stdout.chomp.size
|
32
|
-
assert_equal "", result.stderr.chomp
|
33
|
-
assert_equal 1, result.status
|
34
|
-
end
|
35
|
-
def test_status_code_is_1
|
36
|
-
result = RBatch::cmd "ruby -e 'STDOUT.print 1; STDERR.print 2; exit 1;'"
|
37
|
-
assert_equal "1", result.stdout.chomp
|
38
|
-
assert_equal "2", result.stderr.chomp
|
39
|
-
assert_equal 1, result.status
|
40
|
-
end
|
41
|
-
def test_status_code_is_greater_than_256
|
42
|
-
returncode = 300
|
43
|
-
result = RBatch::cmd "ruby -e 'STDOUT.print 1; STDERR.print 2; exit #{returncode};'"
|
44
|
-
assert_equal "1", result.stdout.chomp
|
45
|
-
assert_equal "2", result.stderr.chomp
|
46
|
-
case RUBY_PLATFORM
|
47
|
-
when /mswin|mingw/
|
48
|
-
assert_equal returncode, result.status
|
49
|
-
when /cygwin|linux/
|
50
|
-
assert_equal returncode % 256, result.status
|
51
|
-
end
|
52
|
-
end
|
53
|
-
def test_to_h
|
54
|
-
result = RBatch::cmd "ruby -e 'STDOUT.print 1; STDERR.print 2; exit 1;'"
|
55
|
-
assert_equal "1", result.to_h[:stdout]
|
56
|
-
assert_equal "2", result.to_h[:stderr]
|
57
|
-
assert_equal 1 , result.to_h[:status]
|
58
|
-
end
|
59
|
-
def test_to_s
|
60
|
-
result = RBatch::cmd "ruby -e 'STDOUT.print 1; STDERR.print 2; exit 1;'"
|
61
|
-
assert_equal "{:cmd_str=>\"ruby -e 'STDOUT.print 1; STDERR.print 2; exit 1;'\", :stdout=>\"1\", :stderr=>\"2\", :status=>1}", result.to_s
|
62
|
-
end
|
63
|
-
def test_nil_command
|
64
|
-
assert_raise(RBatch::CmdException){
|
65
|
-
RBatch::Cmd.new(nil)
|
66
|
-
}
|
67
|
-
end
|
68
|
-
def test_fullcmd_exists
|
69
|
-
result = RBatch::Cmd.new("ruby -e 'STDOUT.print 1; STDERR.print 2; exit 0;'").run
|
70
|
-
assert_equal "1", result.stdout.chomp
|
71
|
-
assert_equal "2", result.stderr.chomp
|
72
|
-
assert_equal 0, result.status
|
73
|
-
end
|
74
|
-
def test_opt_raise_true_status_1
|
75
|
-
cmd_str = "ruby -e 'STDOUT.print 1; STDERR.print 2; exit 1;'"
|
76
|
-
opt = {:raise => true}
|
77
|
-
assert_raise(RBatch::CmdException){
|
78
|
-
RBatch::Cmd.new(cmd_str,opt).run
|
79
|
-
}
|
80
|
-
end
|
81
|
-
def test_opt_raise_false_status_1
|
82
|
-
cmd_str = "ruby -e 'STDOUT.print 1; STDERR.print 2; exit 1;'"
|
83
|
-
opt = {:raise => false}
|
84
|
-
result = RBatch::Cmd.new(cmd_str,opt).run
|
85
|
-
assert_equal "1", result.stdout.chomp
|
86
|
-
assert_equal "2", result.stderr.chomp
|
87
|
-
assert_equal 1, result.status
|
88
|
-
end
|
89
|
-
def test_opt_raise_true_status_0
|
90
|
-
cmd_str = "ruby -e 'STDOUT.print 1; STDERR.print 2; exit 0;'"
|
91
|
-
opt = {:raise => true}
|
92
|
-
result = RBatch::Cmd.new(cmd_str,opt).run
|
93
|
-
assert_equal "1", result.stdout.chomp
|
94
|
-
assert_equal "2", result.stderr.chomp
|
95
|
-
assert_equal 0, result.status
|
96
|
-
end
|
97
|
-
def test_opt_raise_false_status_0
|
98
|
-
cmd_str = "ruby -e 'STDOUT.print 1; STDERR.print 2; exit 0;'"
|
99
|
-
opt = {:raise => false}
|
100
|
-
result = RBatch::Cmd.new(cmd_str,opt).run
|
101
|
-
assert_equal "1", result.stdout.chomp
|
102
|
-
assert_equal "2", result.stderr.chomp
|
103
|
-
assert_equal 0, result.status
|
104
|
-
end
|
105
|
-
def test_opt_raise_true_status_1_by_conf
|
106
|
-
confstr = "cmd_raise: true "
|
107
|
-
open( RBatch.common_config_path , "a" ){|f| f.write(confstr)}
|
108
|
-
cmd_str = "ruby -e 'STDOUT.print 1; STDERR.print 2; exit 1;'"
|
109
|
-
assert_raise(RBatch::CmdException){
|
110
|
-
RBatch::Cmd.new(cmd_str).run
|
111
|
-
}
|
112
|
-
end
|
113
|
-
def test_opt_raise_true_status_1_shortcut
|
114
|
-
cmd_str = "ruby -e 'STDOUT.print 1; STDERR.print 2; exit 1;'"
|
115
|
-
opt = {:raise => true}
|
116
|
-
assert_raise(RBatch::CmdException){
|
117
|
-
RBatch::cmd(cmd_str,opt)
|
118
|
-
}
|
119
|
-
end
|
120
|
-
end
|
data/test/cases/test_config.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'rbatch'
|
3
|
-
|
4
|
-
class RuncherTest < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@config_dir = File.join(File.dirname(RBatch.program_name), "..", "config")
|
7
|
-
@config_file = File.join(@config_dir , "test_config.yaml")
|
8
|
-
Dir::mkdir(@config_dir) if ! Dir.exists? @config_dir
|
9
|
-
end
|
10
|
-
|
11
|
-
def teardown
|
12
|
-
File.delete @config_file if File.exist? @config_file
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_require
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_config
|
19
|
-
open( @config_file , "w" ){|f| f.write("key: value")}
|
20
|
-
assert_equal "value", RBatch.config["key"]
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_read_error
|
24
|
-
assert_raise(Errno::ENOENT){
|
25
|
-
RBatch.config
|
26
|
-
}
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_double_read
|
30
|
-
open( @config_file , "w" ){|f| f.write("key: value")}
|
31
|
-
assert_equal "value", RBatch.config["key"]
|
32
|
-
assert_equal "value", RBatch.config["key"]
|
33
|
-
end
|
34
|
-
end
|